fix: use link for big tank search

This commit is contained in:
TrèsAbhi committed 2024-04-01 21:57:54 -05:00
1 parent 6cef753053
commit 31055f1d66
1 file changed
+95 -88
@@ -14,6 +14,7 @@ import {
TextField, TextField,
} from '@radix-ui/themes'; } from '@radix-ui/themes';
import { go } from 'fuzzysort'; import { go } from 'fuzzysort';
import Link from 'next/link';
import { use, useEffect, useMemo, useRef, useState } from 'react'; import { use, useEffect, useMemo, useRef, useState } from 'react';
import { TreeType } from '../../../../../components/Tanks'; import { TreeType } from '../../../../../components/Tanks';
import { TANK_CLASSES } from '../../../../../components/Tanks/components/Item/constants'; import { TANK_CLASSES } from '../../../../../components/Tanks/components/Item/constants';
@@ -807,117 +808,123 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
<Flex wrap="wrap" gap="2" justify={compact ? 'between' : 'center'}> <Flex wrap="wrap" gap="2" justify={compact ? 'between' : 'center'}>
{!compact && {!compact &&
searchResultsPageSlice.map((tank) => ( searchResultsPageSlice.map((tank) => (
<Card <Link
key={tank.id} href={`/tools/tankopedia/${tank.id}`}
onClick={() => onSelect(tank)}
className={styles.listing}
style={{ style={{
flex: 1, flex: 1,
cursor: 'pointer',
height: 64,
minWidth: 256, minWidth: 256,
}} }}
> >
<Inset <Card
key={tank.id} key={tank.id}
className={styles.listing}
style={{ style={{
minHeight: 64, cursor: 'pointer',
position: 'relative', height: 64,
display: 'flex', width: '100%',
}} }}
> >
<img <Inset
className={styles.flag} key={tank.id}
src={asset(`flags/scratched/${tank.nation}.webp`)}
style={{ style={{
width: '100%', minHeight: 64,
height: '100%', position: 'relative',
objectFit: 'contain', display: 'flex',
position: 'absolute',
}} }}
/>
<div
className={styles.listingShadow}
style={{
width: '100%',
height: '100%',
position: 'absolute',
transition: `box-shadow ${theme.durations.regular}`,
}}
/>
<div
style={{
width: 256,
height: 128,
}}
className={styles.listingImage}
> >
<img <img
src={tankIcon(tank.id)} className={styles.flag}
src={asset(`flags/scratched/${tank.nation}.webp`)}
style={{ style={{
width: '100%',
height: '100%',
objectFit: 'contain', objectFit: 'contain',
objectPosition: 'left center', position: 'absolute',
}} }}
/> />
</div>
<Flex <div
align="center" className={styles.listingShadow}
justify="between" style={{
className={styles.listingLabel} width: '100%',
style={{ height: '100%',
position: 'absolute', position: 'absolute',
bottom: 8, transition: `box-shadow ${theme.durations.regular}`,
padding: '0 12px', }}
width: '100%', />
boxSizing: 'border-box',
}} <div
> style={{
<Flex align="center" justify="center" gap="1"> width: 256,
height: 128,
}}
className={styles.listingImage}
>
<img <img
src={ src={tankIcon(tank.id)}
(tank.treeType === 'collector'
? TANK_ICONS_COLLECTOR
: tank.treeType === 'premium'
? TANK_ICONS_PREMIUM
: TANK_ICONS)[tank.class]
}
style={{ width: '1em', height: '1em' }}
/>
<Text
size="4"
color={
tank.treeType === 'collector'
? 'blue'
: tank.treeType === 'premium'
? 'amber'
: undefined
}
weight="medium"
style={{ style={{
color: objectFit: 'contain',
tank.treeType === 'researchable' objectPosition: 'left center',
? slateDark.slate12
: undefined,
whiteSpace: 'nowrap',
maxWidth: 160,
display: 'block',
textOverflow: 'ellipsis',
overflow: 'hidden',
}} }}
> />
{tank.name} </div>
<Flex
align="center"
justify="between"
className={styles.listingLabel}
style={{
position: 'absolute',
bottom: 8,
padding: '0 12px',
width: '100%',
boxSizing: 'border-box',
}}
>
<Flex align="center" justify="center" gap="1">
<img
src={
(tank.treeType === 'collector'
? TANK_ICONS_COLLECTOR
: tank.treeType === 'premium'
? TANK_ICONS_PREMIUM
: TANK_ICONS)[tank.class]
}
style={{ width: '1em', height: '1em' }}
/>
<Text
size="4"
color={
tank.treeType === 'collector'
? 'blue'
: tank.treeType === 'premium'
? 'amber'
: undefined
}
weight="medium"
style={{
color:
tank.treeType === 'researchable'
? slateDark.slate12
: undefined,
whiteSpace: 'nowrap',
maxWidth: 160,
display: 'block',
textOverflow: 'ellipsis',
overflow: 'hidden',
}}
>
{tank.name}
</Text>
</Flex>
<Text size="4" color="gray" highContrast={false}>
{TIER_ROMAN_NUMERALS[tank.tier]}
</Text> </Text>
</Flex> </Flex>
</Inset>
<Text size="4" color="gray" highContrast={false}> </Card>
{TIER_ROMAN_NUMERALS[tank.tier]} </Link>
</Text>
</Flex>
</Inset>
</Card>
))} ))}
{compact && ( {compact && (