Skip to content

Commit b580a6e

Browse files
author
Christopher Strauss
committed
zoom links
1 parent 65337cd commit b580a6e

File tree

3 files changed

+78
-54
lines changed

3 files changed

+78
-54
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import {
2+
IconContext,
3+
} from "react-icons"
4+
import {
5+
FaVolumeMute,
6+
FaVolumeUp,
7+
FaSearchPlus,
8+
FaSearchMinus,
9+
} from "react-icons/fa"
10+
import {
11+
useMuteStore,
12+
} from "src/store.js"
13+
import {
14+
useViewStateStore,
15+
} from "src/layout.js"
16+
17+
export function BoardSettings() {
18+
return (
19+
<div className="absolute pl-2 pt-1 flex flex-col items-center">
20+
<MuteIcon />
21+
<Zoom />
22+
</div>
23+
)
24+
}
25+
26+
function MuteIcon() {
27+
let toggleMuted = useMuteStore((state) => state.toggleMuted)
28+
let muted = useMuteStore(state => state.muted)
29+
return (
30+
<button onClick={toggleMuted}>
31+
<IconContext.Provider value={{
32+
size: "1.5em",
33+
}}>
34+
{muted ? <FaVolumeMute /> : <FaVolumeUp />}
35+
</IconContext.Provider>
36+
</button>
37+
)
38+
}
39+
40+
function Zoom() {
41+
let zoom = useViewStateStore(state => state.zoom)
42+
let setZoom = useViewStateStore(state => state.setZoom)
43+
return (
44+
<>
45+
<button
46+
className="mt-[0.25rem]"
47+
onClick={() => setZoom(zoom + 1)}>
48+
<IconContext.Provider value={{
49+
size: "1.5em",
50+
}}>
51+
<FaSearchPlus />
52+
</IconContext.Provider>
53+
</button>
54+
<button onClick={() => setZoom(0)}>
55+
<span className="text-2xl">{Math.trunc(zoom)}</span>
56+
</button>
57+
<button
58+
className="mt-[0.125rem]"
59+
onClick={() => setZoom(zoom - 1)}>
60+
<IconContext.Provider value={{
61+
size: "1.5em",
62+
}}>
63+
<FaSearchMinus />
64+
</IconContext.Provider>
65+
</button>
66+
</>
67+
)
68+
}

src/main/client/src/feature/game/Game.jsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
import {
2323
FaVolumeMute,
2424
FaVolumeUp,
25+
FaSearchPlus,
26+
FaSearchMinus,
2527
} from "react-icons/fa"
2628
import {
2729
vw,
@@ -64,6 +66,9 @@ import {
6466
createGameState,
6567
isReviewing,
6668
} from "./state.js"
69+
import {
70+
BoardSettings,
71+
} from "./BoardSettings.jsx"
6772

6873
export function Game() {
6974
let [gameState, setGameState] = useState(initialState())
@@ -72,7 +77,7 @@ export function Game() {
7277
<div
7378
style={{ width: vw() - sidebarWidth }}
7479
className="h-full">
75-
<MuteIcon />
80+
<BoardSettings />
7681
<Board gameState={gameState} setGameState={setGameState} />
7782
<GamePanel gameState={gameState} setGameState={setGameState} />
7883
</div>
@@ -389,20 +394,3 @@ function getRadius(radius) {
389394
}
390395
return diameter / 2
391396
}
392-
393-
function MuteIcon() {
394-
let toggleMuted = useMuteStore((state) => state.toggleMuted)
395-
let muted = useMuteStore(state => state.muted)
396-
return (
397-
<div className="absolute left-2 top-2">
398-
<button onClick={toggleMuted}>
399-
<IconContext.Provider value={{
400-
size: "1.5em",
401-
className: "pl-[4px]",
402-
}}>
403-
{muted ? <FaVolumeMute /> : <FaVolumeUp /> }
404-
</IconContext.Provider>
405-
</button>
406-
</div>
407-
)
408-
}

src/main/client/src/feature/game/GamePanel.jsx

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import {
66
useParams,
77
useNavigate,
88
} from "react-router-dom"
9-
import {
10-
FaAngleLeft,
11-
FaAngleRight,
12-
} from "react-icons/fa"
139
import {
1410
IoMdExit,
1511
} from "react-icons/io"
@@ -26,9 +22,6 @@ import {
2622
import {
2723
useAuthStore,
2824
} from "src/store.js"
29-
import {
30-
useViewStateStore,
31-
} from "src/layout.js"
3225
import {
3326
Chat,
3427
} from "src/component/Chat.jsx"
@@ -58,8 +51,6 @@ export const GamePanel = ({gameState, setGameState}) => {
5851

5952
function Panel({gameState, setGameState}) {
6053
let {gameId} = useParams()
61-
let zoom = useViewStateStore(state => state.zoom)
62-
let setZoom = useViewStateStore(state => state.setZoom)
6354
let stompClient = useContext(StompContext)
6455
let auth = useAuthStore(state => state.auth)
6556
let {black, white, viewPos, counting, board} = gameState
@@ -101,28 +92,10 @@ function Panel({gameState, setGameState}) {
10192
}
10293
return (
10394
<>
104-
<div className="flex-none flex w-full gap-x-2">
105-
<button
106-
onClick={() => setZoom(zoom - 1)}>
107-
<IconContext.Provider value={{
108-
size: "1.25em",
109-
className: "pl-[4px]",
110-
}}>
111-
<FaAngleLeft />
112-
</IconContext.Provider>
113-
</button>
114-
<button onClick={() => setZoom(0)}>
115-
<span>Zoom: {Math.trunc(zoom)}</span>
116-
</button>
117-
<button
118-
onClick={() => setZoom(zoom + 1)}>
119-
<IconContext.Provider value={{
120-
size: "1.25em",
121-
className: "pr-[4px]",
122-
}}>
123-
<FaAngleRight />
124-
</IconContext.Provider>
125-
</button>
95+
<div className="flex-none flex w-full gap-x-1">
96+
<div>{white}</div>
97+
<div>vs</div>
98+
<div>{black}</div>
12699
<div className="grow" />
127100
<button title="Leave the game" onClick={onExit}>
128101
<IconContext.Provider value={{
@@ -133,11 +106,6 @@ function Panel({gameState, setGameState}) {
133106
</IconContext.Provider>
134107
</button>
135108
</div>
136-
<div className="flex-none flex gap-x-1">
137-
<div>{white}</div>
138-
<div>vs</div>
139-
<div>{black}</div>
140-
</div>
141109
{(gameHasEnded(gameState) || isKibitz(gameState, auth)) ? (
142110
<div className="flex-none flex gap-x-1 items-center">
143111
<Button title="Back"

0 commit comments

Comments
 (0)