feat: start of tank page

This commit is contained in:
TrèsAbhi committed 2023-12-06 17:58:26 -06:00
1 parent e7bfe81940
commit 3d5dd54ec0
4 files changed
+45 -29

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ interface ToolsLayoutProps {
export default function ToolsLayout({ children }: ToolsLayoutProps) {
const pathname = usePathname();
const toolId = pathname.split('/').at(-1);
const toolId = pathname.split('/').at(2);
const tool = TOOLS.find((tool) => tool.id === toolId);
return (
+21
View File
@@ -0,0 +1,21 @@
import { Flex, Heading } from '@radix-ui/themes';
import { use } from 'react';
import { Flag } from '../../../../components/Flag';
import PageWrapper from '../../../../components/PageWrapper';
import { tankDefinitions } from '../../../../core/blitzkrieg/definitions/tanks';
// get [id] form the path
export default function Page({ params }: { params: { id: string } }) {
const id = parseInt(params.id);
const awaitedTankDefinitions = use(tankDefinitions);
const definition = awaitedTankDefinitions[id];
return (
<PageWrapper>
<Flex gap="2" align="center">
<Flag nation={definition.nation} />
<Heading>{definition.name}</Heading>
</Flex>
</PageWrapper>
);
}
@@ -3,6 +3,7 @@
import { CaretDownIcon } from '@radix-ui/react-icons';
import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
import { use } from 'react';
import { Flag } from '../../../../../components/Flag';
import {
TANK_TYPES,
TREE_TYPES,
@@ -10,7 +11,6 @@ import {
TREE_TYPE_IMAGES,
TreeTypeEnum,
} from '../../../../../components/Tanks';
import { asset } from '../../../../../core/blitzkrieg/asset';
import {
NATIONS,
TIERS,
@@ -267,15 +267,7 @@ export function Options() {
})
}
>
<img
src={asset(`flags/circle/${nation}.webp`)}
style={{
width: '1em',
height: '1em',
scale: 2,
transform: 'translate(15%, 15%)',
}}
/>
<Flag nation={nation} />
</Button>
))}
</Flex>
@@ -314,15 +306,7 @@ export function Options() {
})
}
>
<img
src={asset(`flags/circle/${nation}.webp`)}
style={{
width: '1em',
height: '1em',
scale: 2,
transform: 'translate(15%, 15%)',
}}
/>
<Flag nation={nation} />
</Button>
))}
</Flex>
@@ -394,15 +378,7 @@ export function Options() {
})
}
>
<img
src={asset(`flags/circle/${nation}.webp`)}
style={{
width: '1em',
height: '1em',
scale: 2,
transform: 'translate(15%, 15%)',
}}
/>
<Flag nation={nation} />
</Button>
))}
</Flex>
+19
View File
@@ -0,0 +1,19 @@
import { asset } from '../core/blitzkrieg/asset';
interface FlagProps {
nation: string;
}
export function Flag({ nation }: FlagProps) {
return (
<div
style={{
width: 22,
height: 22,
overflow: 'hidden',
}}
>
<img src={asset(`flags/circle/${nation}.webp`)} alt={nation} />
</div>
);
}