feat: complete functionality

This commit is contained in:
TrèsAbhi committed 2024-05-21 14:18:21 -05:00
1 parent 3631fb3cab
commit 7c950e1121
4 files changed
+131 -21

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

After

Width:  |  Height:  |  Size: 277 KiB

+1
View File
@@ -70,6 +70,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
appearance="dark" appearance="dark"
panelBackground="solid" panelBackground="solid"
radius="full" radius="full"
accentColor="amber"
suppressHydrationWarning suppressHydrationWarning
suppressContentEditableWarning suppressContentEditableWarning
> >
+129 -21
View File
@@ -1,11 +1,16 @@
'use client'; 'use client';
import { CaretRightIcon, MagnifyingGlassIcon } from '@radix-ui/react-icons'; import {
CaretRightIcon,
Cross2Icon,
MagnifyingGlassIcon,
} from '@radix-ui/react-icons';
import { import {
Button, Button,
Card, Card,
Flex, Flex,
Heading, Heading,
IconButton,
Spinner, Spinner,
Text, Text,
TextField, TextField,
@@ -16,6 +21,7 @@ import { useRef, useState } from 'react';
import { Link } from '../components/Link'; import { Link } from '../components/Link';
import { NAVBAR_HEIGHT } from '../components/Navbar'; import { NAVBAR_HEIGHT } from '../components/Navbar';
import PageWrapper from '../components/PageWrapper'; import PageWrapper from '../components/PageWrapper';
import { UNLOCALIZED_REGION_NAMES_SHORT } from '../constants/regions';
import searchPlayersAcrossRegions, { import searchPlayersAcrossRegions, {
AccountListWithServer, AccountListWithServer,
} from '../core/blitz/searchPlayersAcrossRegions'; } from '../core/blitz/searchPlayersAcrossRegions';
@@ -24,10 +30,14 @@ import {
tankDefinitions, tankDefinitions,
tankNames, tankNames,
} from '../core/blitzkit/tankDefinitions'; } from '../core/blitzkit/tankDefinitions';
import { tankIcon } from '../core/blitzkit/tankIcon'; import { TIER_ROMAN_NUMERALS } from '../core/blitzkit/tankDefinitions/constants';
import { useWideFormat } from '../hooks/useWideFormat';
import { theme } from '../stitches.config'; import { theme } from '../stitches.config';
const DISCRIMINATOR_WIDTH = 32;
export default function Page() { export default function Page() {
const wideFormat = useWideFormat(512);
const [showSearch, setShowSearch] = useState(false); const [showSearch, setShowSearch] = useState(false);
const [searching, setSearching] = useState(false); const [searching, setSearching] = useState(false);
const [searchResults, setSearchResults] = useState<null | { const [searchResults, setSearchResults] = useState<null | {
@@ -44,9 +54,9 @@ export default function Page() {
const awaitedTankNames = await tankNames; const awaitedTankNames = await tankNames;
const tanks = go(sanitized, awaitedTankNames, { const tanks = go(sanitized, awaitedTankNames, {
keys: ['combined'], keys: ['combined'],
limit: 9, limit: 6,
}); });
const players = await searchPlayersAcrossRegions(sanitized, 9); const players = await searchPlayersAcrossRegions(sanitized, 6);
setSearchResults({ setSearchResults({
tanks: tanks.map((tank) => awaitedTankDefinitions[tank.obj.id]), tanks: tanks.map((tank) => awaitedTankDefinitions[tank.obj.id]),
@@ -77,7 +87,7 @@ export default function Page() {
background: 'url(/assets/banners/home.webp)', background: 'url(/assets/banners/home.webp)',
backgroundSize: 'cover', backgroundSize: 'cover',
backgroundRepeat: 'no-repeat', backgroundRepeat: 'no-repeat',
backgroundPosition: 'bottom', backgroundPosition: 'center',
}} }}
/> />
<div <div
@@ -146,6 +156,23 @@ export default function Page() {
<TextField.Slot> <TextField.Slot>
<MagnifyingGlassIcon /> <MagnifyingGlassIcon />
</TextField.Slot> </TextField.Slot>
{showSearch && (
<TextField.Slot>
<IconButton
variant="ghost"
color="gray"
onClick={() => {
if (!search.current) return;
search.current.value = '';
setShowSearch(false);
}}
>
<Cross2Icon />
</IconButton>
</TextField.Slot>
)}
</TextField.Root> </TextField.Root>
{showSearch && ( {showSearch && (
@@ -167,14 +194,33 @@ export default function Page() {
{!searching && searchResults && ( {!searching && searchResults && (
<> <>
<Flex gap="6"> <Flex
<Flex direction="column" gap="2" style={{ flex: 1 }}> gap={wideFormat ? '6' : '2'}
justify="center"
direction={wideFormat ? 'row' : 'column'}
>
<Flex
direction="column"
gap="2"
style={{
flex: 1,
maxWidth: wideFormat ? '50%' : undefined,
}}
>
<Link <Link
underline="hover" underline="hover"
color="gray"
href="/tools/tankopedia" href="/tools/tankopedia"
color="gray"
style={{
width: '100%',
}}
> >
<Flex align="center"> <Flex
align="center"
style={{
width: '100%',
}}
>
Tankopedia Tankopedia
<CaretRightIcon /> <CaretRightIcon />
</Flex> </Flex>
@@ -189,6 +235,7 @@ export default function Page() {
href={`/tools/tankopedia/${tank.id}`} href={`/tools/tankopedia/${tank.id}`}
> >
<Button <Button
tabIndex={-1}
size="2" size="2"
variant="ghost" variant="ghost"
color="gray" color="gray"
@@ -196,18 +243,22 @@ export default function Page() {
justifyContent: 'flex-start', justifyContent: 'flex-start',
width: '100%', width: '100%',
color: 'inherit', color: 'inherit',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}} }}
> >
<Flex align="center" gap="2"> <Flex align="center" gap="2">
<img <Text
src={tankIcon(tank.id, 'small')} color="gray"
size="1"
style={{ style={{
height: 16, width: DISCRIMINATOR_WIDTH,
width: 32, textAlign: 'left',
objectFit: 'contain',
objectPosition: 'left',
}} }}
/> >
{TIER_ROMAN_NUMERALS[tank.tier]}
</Text>
{tank.name} {tank.name}
</Flex> </Flex>
@@ -215,18 +266,75 @@ export default function Page() {
</Link> </Link>
</Text> </Text>
))} ))}
{searchResults.tanks.length === 0 && (
<Text color="gray" size="2">
No tanks found
</Text>
)}
</Flex> </Flex>
</Flex> </Flex>
<Flex direction="column" gap="2" style={{ flex: 1 }}> <Flex
direction="column"
gap="2"
style={{
flex: 1,
maxWidth: wideFormat ? '50%' : undefined,
}}
>
<Text color="gray">Players</Text> <Text color="gray">Players</Text>
<Flex direction="column"> <Flex direction="column">
{searchResults.players.map((player) => ( {searchResults.players.map((player) => (
<Link href={`/`} size="2"> <Text>
{player.nickname} <Link
</Link> underline="none"
style={{ color: 'inherit' }}
href={`/tools/session/?id=${player.account_id}`}
>
<Button
tabIndex={-1}
size="2"
variant="ghost"
color="gray"
style={{
justifyContent: 'flex-start',
width: '100%',
color: 'inherit',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
<Flex align="center" gap="2">
<Text
color="gray"
size="1"
style={{
width: DISCRIMINATOR_WIDTH,
textAlign: 'left',
}}
>
{
UNLOCALIZED_REGION_NAMES_SHORT[
player.region
]
}
</Text>
{player.nickname}
</Flex>
</Button>
</Link>
</Text>
))} ))}
{searchResults.players.length === 0 && (
<Text color="gray" size="2">
No players found
</Text>
)}
</Flex> </Flex>
</Flex> </Flex>
</Flex> </Flex>
@@ -239,7 +347,7 @@ export default function Page() {
</Flex> </Flex>
<PageWrapper noFlex1> <PageWrapper noFlex1>
hello there! ignore my existence pretty please :&#41; {/* hello there! ignore my existence pretty please :&#41; */}
</PageWrapper> </PageWrapper>
<div style={{ flex: 1 }} /> <div style={{ flex: 1 }} />
+1
View File
@@ -16,6 +16,7 @@ export function Link({ href, children, target, onClick, ...props }: LinkProps) {
{...props} {...props}
> >
<NextLink <NextLink
tabIndex={-1}
href={href} href={href}
target={target} target={target}
onClick={onClick} onClick={onClick}