Skip to content

Commit

Permalink
tweak GameIcon component & update Vending layout
Browse files Browse the repository at this point in the history
  • Loading branch information
intercepti0n committed Nov 26, 2023
1 parent 13d3037 commit d077489
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
5 changes: 4 additions & 1 deletion tgui/packages/tgui/components/GameIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Box } from './Box';

type GameIconProps = {
html: string;
className?: string;
Expand All @@ -11,7 +13,8 @@ export const GameIcon = (props: GameIconProps) => {
const iconSrc = html.match('src=["\'](.*)["\']')![1];

return (
<img
<Box
as="img"
key={key}
{...props}
className={`game-icon ${className || ''}`}
Expand Down
53 changes: 32 additions & 21 deletions tgui/packages/tgui/interfaces/Vending.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { capitalize } from 'common/string';
import { capitalize } from '../../common/string';
import { useBackend } from '../backend';
import { BlockQuote, Box, Button, Icon, LabeledList, Modal, NoticeBox, Section, Stack } from '../components';
import { GameIcon } from '../components/GameIcon';
Expand Down Expand Up @@ -138,28 +138,39 @@ const product = (product: ProductData, context: any) => {
<Stack.Item grow>
<Button
fluid
ellipsis
onClick={() => act('vend', { key: product.key })}>
<Stack fill align="center">
<Stack.Item>
<GameIcon html={product.icon} className="Vending--game-icon" />
</Stack.Item>
<Stack.Item grow={4} textAlign="left" className="Vending--text">
{product.name}
</Stack.Item>
<Stack.Item grow textAlign="right" className="Vending--text">
{product.amount}
<Icon name="box" pl="0.6em" />
</Stack.Item>
{(product.price > 0 && (
height="100%"
verticalAlignContent="middle"
content={
<Stack fill align="center">
<Stack.Item
style={{
'display': 'flex',
'align-items': 'center',
'justify-content': 'center',
}}>
<GameIcon
html={product.icon}
className="Vending--game-icon"
/>
</Stack.Item>
<Stack.Item grow={4} textAlign="left" className="Vending--text">
{product.name}
</Stack.Item>
<Stack.Item grow textAlign="right" className="Vending--text">
{product.price}
<Icon name="money-bill" pl="0.6em" />
{product.amount}
<Icon name="box" pl="0.6em" />
</Stack.Item>
)) ||
null}
</Stack>
</Button>
{(product.price > 0 && (
<Stack.Item grow textAlign="right" className="Vending--text">
{product.price}
<Icon name="money-bill" pl="0.6em" />
</Stack.Item>
)) ||
null}
</Stack>
}
onClick={() => act('vend', { key: product.key })}
/>
</Stack.Item>
{(data.isManaging && (
<>
Expand Down
4 changes: 2 additions & 2 deletions tgui/packages/tgui/styles/interfaces/Vending.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
height: 5.9ch;
}
&--game-icon {
width: 2.5rem;
align-items: center;
height: 2.5rem;
width: auto;
}
&--modal {
width: 30rem;
Expand Down

0 comments on commit d077489

Please sign in to comment.