Skip to content

Commit 585ed39

Browse files
committed
feat(bottom-bar): styling bottom bar components
1 parent 82fb356 commit 585ed39

File tree

4 files changed

+76
-13
lines changed

4 files changed

+76
-13
lines changed

electron/renderer/components/game/game-bottom-bar.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
import type { ReactNode } from 'react';
22
import { GameCommandInput } from './game-command-input.jsx';
33
import { GameCompass } from './game-compass.jsx';
4+
import { GameHands } from './game-hands.jsx';
45
import { GameRoundTime } from './game-roundtime.jsx';
56

67
export const GameBottomBar: React.FC = (): ReactNode => {
78
return (
89
<div
910
css={{
1011
display: 'flex',
11-
alignItems: 'center',
12+
flexDirection: 'column',
1213
gap: '5px',
1314
paddingTop: '5px',
1415
paddingBottom: '5px',
1516
paddingLeft: '5px',
16-
paddingRight: '10px',
17+
paddingRight: '5px',
1718
}}
1819
>
19-
<GameRoundTime />
20+
<div
21+
css={{
22+
display: 'flex',
23+
alignItems: 'center',
24+
gap: '5px',
25+
}}
26+
>
27+
<GameRoundTime />
28+
<GameCompass />
29+
<GameHands />
30+
</div>
2031
<GameCommandInput />
21-
<GameCompass />
2232
</div>
2333
);
2434
};

electron/renderer/components/game/game-command-input.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EuiFieldText } from '@elastic/eui';
1+
import { EuiFieldText, EuiIcon } from '@elastic/eui';
22
import type {
33
ChangeEvent,
44
KeyboardEvent,
@@ -42,6 +42,7 @@ export const GameCommandInput: React.FC = (): ReactNode => {
4242
value={input}
4343
compressed={true}
4444
fullWidth={true}
45+
prepend={<EuiIcon type="arrowRight" size="s" color="primary" />}
4546
tabIndex={0}
4647
onKeyDown={onKeyDown}
4748
onChange={onChange}

electron/renderer/components/game/game-compass.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { useSubscribe } from '../../hooks/pubsub.jsx';
88
import { runInBackground } from '../../lib/async/run-in-background.js';
99

1010
const compassStyle = css({
11+
position: 'relative',
1112
display: 'flex',
12-
flexWrap: 'wrap',
1313
justifyContent: 'center',
1414
alignItems: 'center',
15-
position: 'relative',
1615
width: '50px',
1716
height: '50px',
1817
});
@@ -30,13 +29,13 @@ const compassPointStyle = (compassPoint: CompassPoint) => {
3029
const { rotation } = compassPoint;
3130
return css({
3231
position: 'absolute',
33-
transform: `rotate(${rotation}deg) translate(20px) scale(1.2)`,
34-
transformOrigin: 'center',
35-
width: '12px',
36-
height: '12px',
3732
display: 'flex',
3833
justifyContent: 'center',
3934
alignItems: 'center',
35+
width: '10px',
36+
height: '10px',
37+
transform: `rotate(${rotation}deg) translate(15px) scale(.8)`,
38+
transformOrigin: 'center',
4039
});
4140
};
4241

@@ -93,7 +92,7 @@ export const GameCompass: React.FC = () => {
9392
return (
9493
<div key={compassPoint.name} css={compassPointStyle(compassPoint)}>
9594
<EuiIcon
96-
type="sortRight"
95+
type="frameNext"
9796
color="danger"
9897
cursor="pointer"
9998
onClick={() => {
@@ -107,7 +106,7 @@ export const GameCompass: React.FC = () => {
107106
}
108107
return (
109108
<div key={compassPoint.name} css={compassPointStyle(compassPoint)}>
110-
<EuiIcon type="sortRight" color="subdued" />
109+
<EuiIcon type="frameNext" color="subdued" />
111110
</div>
112111
);
113112
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useEuiTheme } from '@elastic/eui';
2+
import { useState } from 'react';
3+
import type { GameEvent } from '../../../common/game/types.js';
4+
import { GameEventType } from '../../../common/game/types.js';
5+
import { useSubscribe } from '../../hooks/pubsub.jsx';
6+
7+
export const GameHands: React.FC = () => {
8+
const { euiTheme } = useEuiTheme();
9+
10+
const [leftHand, setLeftHand] = useState<string>('Empty');
11+
const [rightHand, setRightHand] = useState<string>('Empty');
12+
const [spell, setSpell] = useState<string>('None');
13+
14+
useSubscribe(['game:event'], (gameEvent: GameEvent) => {
15+
switch (gameEvent.type) {
16+
case GameEventType.LEFT_HAND:
17+
setLeftHand(gameEvent.item);
18+
break;
19+
case GameEventType.RIGHT_HAND:
20+
setRightHand(gameEvent.item);
21+
break;
22+
case GameEventType.SPELL:
23+
setSpell(gameEvent.spell);
24+
break;
25+
}
26+
});
27+
28+
return (
29+
<div
30+
css={{
31+
display: 'block',
32+
justifyContent: 'center',
33+
alignContent: 'center',
34+
width: '300px',
35+
height: '100%',
36+
fontSize: euiTheme.size.m,
37+
}}
38+
>
39+
{[
40+
{ label: 'Left', value: leftHand },
41+
{ label: 'Right', value: rightHand },
42+
{ label: 'Spell', value: spell },
43+
].map(({ label, value }) => (
44+
<div key={label} css={{ display: 'flex', gap: '5px' }}>
45+
<b css={{ textAlign: 'right', minWidth: '45px' }}>{label}:</b>
46+
{value}
47+
</div>
48+
))}
49+
</div>
50+
);
51+
};
52+
53+
GameHands.displayName = 'GameHands';

0 commit comments

Comments
 (0)