mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: change tank functionality
This commit is contained in:
1 parent
e835498e59
commit
b8f3c3eece
2 files changed
+42
-7
No files matched your search
@@ -1,10 +1,13 @@
|
|||||||
import { UpdateIcon } from '@radix-ui/react-icons';
|
import { UpdateIcon } from '@radix-ui/react-icons';
|
||||||
import { Button, Flex, Heading } from '@radix-ui/themes';
|
import { Button, Dialog, Flex, Heading } from '@radix-ui/themes';
|
||||||
import { TREE_TYPE_ICONS } from '../../../../../components/Tanks';
|
import { TREE_TYPE_ICONS } from '../../../../../components/Tanks';
|
||||||
import { useDuel } from '../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../stores/duel';
|
||||||
|
import { TankSearch } from '../../components/TankSearch';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
export function Title() {
|
export function Title() {
|
||||||
const protagonist = useDuel((state) => state.protagonist!);
|
const protagonist = useDuel((state) => state.protagonist!);
|
||||||
|
const [changeTankDialogOpen, setChangeTankDialogOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex gap="6" justify="center" align="center" style={{ padding: 16 }}>
|
<Flex gap="6" justify="center" align="center" style={{ padding: 16 }}>
|
||||||
@@ -35,9 +38,41 @@ export function Title() {
|
|||||||
</Heading>
|
</Heading>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Button variant="ghost">
|
<Dialog.Root
|
||||||
Change <UpdateIcon />
|
open={changeTankDialogOpen}
|
||||||
</Button>
|
onOpenChange={setChangeTankDialogOpen}
|
||||||
|
>
|
||||||
|
<Dialog.Trigger>
|
||||||
|
<Button variant="ghost">
|
||||||
|
Change <UpdateIcon />
|
||||||
|
</Button>
|
||||||
|
</Dialog.Trigger>
|
||||||
|
|
||||||
|
<Dialog.Content>
|
||||||
|
<Flex gap="4" direction="column">
|
||||||
|
<Flex
|
||||||
|
direction="column"
|
||||||
|
gap="4"
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
justify="center"
|
||||||
|
>
|
||||||
|
<TankSearch
|
||||||
|
compact
|
||||||
|
onSelect={(tank) => {
|
||||||
|
mutateDuel((draft) => {
|
||||||
|
draft.protagonist!.tank = tank;
|
||||||
|
draft.protagonist!.turret = tank.turrets.at(-1)!;
|
||||||
|
draft.protagonist!.gun =
|
||||||
|
draft.protagonist!.turret.guns.at(-1)!;
|
||||||
|
draft.protagonist!.shell = draft.protagonist!.gun.shells[0];
|
||||||
|
});
|
||||||
|
setChangeTankDialogOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
</Dialog.Content>
|
||||||
|
</Dialog.Root>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -91,8 +91,6 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
align="start"
|
align="start"
|
||||||
justify="center"
|
justify="center"
|
||||||
>
|
>
|
||||||
<Characteristics />
|
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
gap="4"
|
gap="4"
|
||||||
direction="column"
|
direction="column"
|
||||||
@@ -105,6 +103,8 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
<TankSandbox />
|
<TankSandbox />
|
||||||
<AntagonistBar />
|
<AntagonistBar />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
<Characteristics />
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user