diff --git a/src/app/tools/tankopedia/components/List/index.css.tsx b/src/app/tools/tankopedia/components/List/index.css.tsx new file mode 100644 index 000000000..0d2846c87 --- /dev/null +++ b/src/app/tools/tankopedia/components/List/index.css.tsx @@ -0,0 +1,30 @@ +import { style } from '@vanilla-extract/css'; +import { theme } from '../../../../../stitches.config'; + +export const listing = style({}); + +export const listingShadow = style({ + boxShadow: `inset 0 -128px 128px -128px ${theme.colors.appBackground1}`, + + [`.${listing}:hover &`]: { + boxShadow: `inset 0 0 128px -128px ${theme.colors.appBackground1}`, + }, +}); + +export const listingLabel = style({ + transition: `transform ${theme.durations.regular}`, + transform: 'translateY(0)', + + [`.${listing}:hover &`]: { + transform: 'translateY(200%)', + }, +}); + +export const listingImage = style({ + transition: `transform ${theme.durations.regular}`, + transform: 'translateX(25%) translateY(0)', + + [`.${listing}:hover &`]: { + transform: 'translateX(25%) translateY(10%)', + }, +}); diff --git a/src/app/tools/tankopedia/components/List/index.tsx b/src/app/tools/tankopedia/components/List/index.tsx new file mode 100644 index 000000000..2919b7e37 --- /dev/null +++ b/src/app/tools/tankopedia/components/List/index.tsx @@ -0,0 +1,107 @@ +'use client'; + +import { slateDark } from '@radix-ui/colors'; +import { MagnifyingGlassIcon } from '@radix-ui/react-icons'; +import { Card, Flex, Inset, Text, TextField } from '@radix-ui/themes'; +import { use, useRef } from 'react'; +import { Search } from 'react-fuzzysort'; +import { tankIcon } from '../../../../../core/blitzkrieg/tankIcon'; +import { tanks } from '../../../../../core/blitzkrieg/tankopedia'; +import { theme } from '../../../../../stitches.config'; +import * as styles from './index.css'; + +export function List() { + const awaitedTanks = use( + tanks.then((tanks) => tanks.sort((a, b) => b.tier - a.tier)), + ); + const input = useRef(null); + + return ( + <> + + + + + + + + {awaitedTanks.length > 0 && ( + + ({ + node: ( + + + + + +
+ + + {tank.name_short ?? + tank.name ?? + `Unknown tank ${tank.id}`} + + + + + ), + query: `${ + tank.name_short ?? tank.name ?? `Unknown tank ${tank.id}` + } ${tank.tree_type} ${ + tank.type === 'AT-SPG' ? 'tank destroyer' : tank.type + } ${tank.id}`, + }))} + /> + + )} + + ); +} diff --git a/src/app/tools/tankopedia/page.tsx b/src/app/tools/tankopedia/page.tsx index 1bd4b686f..ca38f7641 100644 --- a/src/app/tools/tankopedia/page.tsx +++ b/src/app/tools/tankopedia/page.tsx @@ -1,131 +1,14 @@ -'use client'; - -import { blackA, slateDark } from '@radix-ui/colors'; -import { Card, Inset, Text } from '@radix-ui/themes'; -import { useEffect, useState } from 'react'; +import { Text } from '@radix-ui/themes'; +import { Suspense } from 'react'; import PageWrapper from '../../../components/PageWrapper'; -import { tankIcon } from '../../../core/blitzkrieg/tankIcon'; -import { - BlitzkriegTankopediaEntry, - tanks, -} from '../../../core/blitzkrieg/tankopedia'; - -const sortedTanks = tanks.then((tanks) => - tanks.sort((a, b) => b.tier - a.tier), -); +import { List } from './components/List'; export default function Page() { - const [tanks, setTanks] = useState([]); - - useEffect(() => { - (async () => setTanks(await sortedTanks))(); - }, []); - return ( - - {tanks.map((tank) => ( - - - - { - // get image width - const target = event.target as HTMLImageElement; - const { naturalWidth } = target; - - if (naturalWidth === 256) { - target.style.transform = 'translateX(25%)'; - } - }} - /> - -
- - - {tank.name_short ?? tank.name ?? `Unknown tank ${tank.id}`} - - - - - ))} + + Loading...}> + + ); } - -{ - /* - - {tank.tree_type !== 'tech-tree' && ( - - {tank.tree_type === 'collector' ? 'Collector' : 'Premium'} - - )} - - {(() => { - if (tank.type === 'AT-SPG') return 'Tank Destroyer'; - if (tank.type === 'lightTank') return 'Light Tank'; - if (tank.type === 'mediumTank') return 'Medium Tank'; - if (tank.type === 'heavyTank') return 'Heavy Tank'; - })()} - - - */ -} diff --git a/src/components/PageWrapper.tsx b/src/components/PageWrapper.tsx index 666937af3..df8f10e84 100644 --- a/src/components/PageWrapper.tsx +++ b/src/components/PageWrapper.tsx @@ -3,28 +3,30 @@ import { ComponentProps } from 'react'; interface PageWrapperProps extends ComponentProps { color?: ComponentProps['accentColor']; + size?: 'regular' | 'wide'; } export default function PageWrapper({ style, color, + size = 'regular', ...props }: PageWrapperProps) { return ( );