mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: cleaner clear button
This commit is contained in:
1 parent
e20d65d218
commit
bdc013b4c8
2 files changed
+450
-433
No files matched your search
@@ -756,7 +756,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"tank_search": {
|
"tank_search": {
|
||||||
"clear_filters": "Clear",
|
"clear_filters": "Clear filters",
|
||||||
"search_bar_hint": "Search tanks...",
|
"search_bar_hint": "Search tanks...",
|
||||||
"recent": "Recently viewed",
|
"recent": "Recently viewed",
|
||||||
"select_all": "Select all",
|
"select_all": "Select all",
|
||||||
|
|||||||
@@ -6,17 +6,16 @@ import {
|
|||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { useStore } from '@nanostores/react';
|
import { useStore } from '@nanostores/react';
|
||||||
import { ReloadIcon } from '@radix-ui/react-icons';
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
|
||||||
Flex,
|
Flex,
|
||||||
IconButton,
|
IconButton,
|
||||||
Inset,
|
Inset,
|
||||||
|
Link,
|
||||||
Popover,
|
Popover,
|
||||||
Text,
|
Text,
|
||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import { times } from 'lodash-es';
|
import { isEqual, times } from 'lodash-es';
|
||||||
import { awaitableGameDefinitions } from '../../../core/awaitables/gameDefinitions';
|
import { awaitableGameDefinitions } from '../../../core/awaitables/gameDefinitions';
|
||||||
import { Var } from '../../../core/radix/var';
|
import { Var } from '../../../core/radix/var';
|
||||||
import { useLocale } from '../../../hooks/useLocale';
|
import { useLocale } from '../../../hooks/useLocale';
|
||||||
@@ -121,493 +120,511 @@ function ShellFilter({ index, premium }: { index: number; premium?: boolean }) {
|
|||||||
export function FilterControl({ compact }: FilterControlProps) {
|
export function FilterControl({ compact }: FilterControlProps) {
|
||||||
const tankFilters = useStore($tankFilters);
|
const tankFilters = useStore($tankFilters);
|
||||||
const { strings } = useLocale();
|
const { strings } = useLocale();
|
||||||
|
const clearable = !isEqual(tankFilters, initialTankFilters);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex direction="column" align="center">
|
||||||
height="fit-content"
|
|
||||||
gap="2"
|
|
||||||
align={{ initial: 'start', md: 'center' }}
|
|
||||||
justify="center"
|
|
||||||
>
|
|
||||||
<Flex
|
<Flex
|
||||||
direction={compact ? 'row' : { initial: 'row', md: 'column' }}
|
height="fit-content"
|
||||||
overflow="hidden"
|
gap="2"
|
||||||
style={{ borderRadius: 'var(--radius-5)' }}
|
align={{ initial: 'start', md: 'center' }}
|
||||||
|
justify="center"
|
||||||
>
|
>
|
||||||
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
|
<Flex
|
||||||
{times(5, (index) => {
|
flexShrink="0"
|
||||||
const tier = index + 1;
|
direction={compact ? 'row' : { initial: 'row', md: 'column' }}
|
||||||
const selected = tankFilters.tiers?.includes(tier);
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-5)' }}
|
||||||
return (
|
>
|
||||||
<IconButton
|
|
||||||
key={tier}
|
|
||||||
variant={selected ? 'solid' : 'soft'}
|
|
||||||
radius="none"
|
|
||||||
color={selected ? undefined : 'gray'}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.tiers.includes(tier)) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'tiers',
|
|
||||||
tankFilters.tiers.filter((t) => t !== tier),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('tiers', [...tankFilters.tiers, tier]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
|
||||||
</IconButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
display={{ initial: 'none', md: 'block' }}
|
|
||||||
style={{
|
|
||||||
height: Var('space-1'),
|
|
||||||
backgroundColor: Var('gray-a3'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
|
|
||||||
{times(5, (index) => {
|
|
||||||
const tier = index + 6;
|
|
||||||
const selected = tankFilters.tiers?.includes(tier);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IconButton
|
|
||||||
key={tier}
|
|
||||||
variant={selected ? 'solid' : 'soft'}
|
|
||||||
radius="none"
|
|
||||||
color={selected ? undefined : 'gray'}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.tiers.includes(tier)) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'tiers',
|
|
||||||
tankFilters.tiers.filter((t) => t !== tier),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('tiers', [...tankFilters.tiers, tier]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
|
||||||
</IconButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
direction={compact ? 'row' : { initial: 'row', md: 'column' }}
|
|
||||||
overflow="hidden"
|
|
||||||
style={{ borderRadius: 'var(--radius-5)' }}
|
|
||||||
>
|
|
||||||
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
|
|
||||||
{gameDefinitions.nations
|
|
||||||
.slice(0, Math.ceil(gameDefinitions.nations.length / 2))
|
|
||||||
.map((nation) => {
|
|
||||||
const selected = tankFilters.nations?.includes(nation);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IconButton
|
|
||||||
key={nation}
|
|
||||||
variant={selected ? 'solid' : 'soft'}
|
|
||||||
color={selected ? undefined : 'gray'}
|
|
||||||
highContrast
|
|
||||||
radius="none"
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.nations.includes(nation)) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'nations',
|
|
||||||
tankFilters.nations.filter((n) => n !== nation),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('nations', [
|
|
||||||
...tankFilters.nations,
|
|
||||||
nation,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
style={{ width: '1em', height: '1em' }}
|
|
||||||
src={asset(`flags/circle/${nation}.webp`)}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
display={{ initial: 'none', md: 'block' }}
|
|
||||||
style={{
|
|
||||||
height: Var('space-1'),
|
|
||||||
backgroundColor: Var('gray-a3'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
|
|
||||||
{gameDefinitions.nations
|
|
||||||
.slice(Math.ceil(gameDefinitions.nations.length / 2))
|
|
||||||
.map((nation) => {
|
|
||||||
const selected = tankFilters.nations?.includes(nation);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IconButton
|
|
||||||
key={nation}
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
variant={selected ? 'solid' : 'soft'}
|
|
||||||
color={selected ? undefined : 'gray'}
|
|
||||||
highContrast
|
|
||||||
radius="none"
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.nations.includes(nation)) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'nations',
|
|
||||||
tankFilters.nations.filter((n) => n !== nation),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('nations', [
|
|
||||||
...tankFilters.nations,
|
|
||||||
nation,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
style={{ width: '1em', height: '1em' }}
|
|
||||||
src={asset(`flags/circle/${nation}.webp`)}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex
|
|
||||||
direction={{ initial: 'row', md: 'column' }}
|
|
||||||
align="start"
|
|
||||||
gap={{ initial: '2', md: '1' }}
|
|
||||||
>
|
|
||||||
<Flex gap="2" align="start">
|
|
||||||
<Flex
|
<Flex
|
||||||
overflow="hidden"
|
|
||||||
style={{ borderRadius: 'var(--radius-full)' }}
|
|
||||||
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
>
|
||||||
{TANK_CLASSES.map((tankClass) => {
|
{times(5, (index) => {
|
||||||
const Icon = classIcons[tankClass];
|
const tier = index + 1;
|
||||||
const selected = tankFilters.classes?.includes(tankClass);
|
const selected = tankFilters.tiers?.includes(tier);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
key={tankClass}
|
key={tier}
|
||||||
variant={selected ? 'solid' : 'soft'}
|
variant={selected ? 'solid' : 'soft'}
|
||||||
radius="none"
|
radius="none"
|
||||||
color={selected ? undefined : 'gray'}
|
color={selected ? undefined : 'gray'}
|
||||||
highContrast
|
highContrast
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (tankFilters.classes.includes(tankClass)) {
|
if (tankFilters.tiers.includes(tier)) {
|
||||||
$tankFilters.setKey(
|
$tankFilters.setKey(
|
||||||
'classes',
|
'tiers',
|
||||||
tankFilters.classes.filter((c) => c !== tankClass),
|
tankFilters.tiers.filter((t) => t !== tier),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$tankFilters.setKey('classes', [
|
$tankFilters.setKey('tiers', [
|
||||||
...tankFilters.classes,
|
...tankFilters.tiers,
|
||||||
tankClass,
|
tier,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon style={{ width: '1em', height: '1em' }} />
|
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
display={{ initial: 'none', md: 'block' }}
|
||||||
|
style={{
|
||||||
|
height: Var('space-1'),
|
||||||
|
backgroundColor: Var('gray-a3'),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
overflow="hidden"
|
|
||||||
style={{ borderRadius: 'var(--radius-full)' }}
|
|
||||||
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
>
|
||||||
<IconButton
|
{times(5, (index) => {
|
||||||
variant={
|
const tier = index + 6;
|
||||||
tankFilters.gunType.includes('regular') ? 'solid' : 'soft'
|
const selected = tankFilters.tiers?.includes(tier);
|
||||||
}
|
|
||||||
radius="none"
|
|
||||||
color={
|
|
||||||
tankFilters.gunType.includes('regular') ? undefined : 'gray'
|
|
||||||
}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.gunType.includes('regular')) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'gunType',
|
|
||||||
tankFilters.gunType.filter((t) => t !== 'regular'),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('gunType', [
|
|
||||||
...tankFilters.gunType,
|
|
||||||
'regular',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GunRegularIcon style={{ width: '1em', height: '1em' }} />
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
variant={
|
|
||||||
tankFilters.gunType.includes('auto_loader') ? 'solid' : 'soft'
|
|
||||||
}
|
|
||||||
radius="none"
|
|
||||||
color={
|
|
||||||
tankFilters.gunType.includes('auto_loader') ? undefined : 'gray'
|
|
||||||
}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.gunType.includes('auto_loader')) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'gunType',
|
|
||||||
tankFilters.gunType.filter((t) => t !== 'auto_loader'),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('gunType', [
|
|
||||||
...tankFilters.gunType,
|
|
||||||
'auto_loader',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GunAutoloaderIcon style={{ width: '1em', height: '1em' }} />
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
variant={
|
|
||||||
tankFilters.gunType.includes('auto_reloader') ? 'solid' : 'soft'
|
|
||||||
}
|
|
||||||
radius="none"
|
|
||||||
color={
|
|
||||||
tankFilters.gunType.includes('auto_reloader')
|
|
||||||
? undefined
|
|
||||||
: 'gray'
|
|
||||||
}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.gunType.includes('auto_reloader')) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'gunType',
|
|
||||||
tankFilters.gunType.filter((t) => t !== 'auto_reloader'),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('gunType', [
|
|
||||||
...tankFilters.gunType,
|
|
||||||
'auto_reloader',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GunAutoreloaderIcon style={{ width: '1em', height: '1em' }} />
|
|
||||||
</IconButton>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Box display={{ initial: 'none', md: 'block' }}>
|
return (
|
||||||
<Button
|
<IconButton
|
||||||
color="red"
|
key={tier}
|
||||||
onClick={() => {
|
variant={selected ? 'solid' : 'soft'}
|
||||||
$tankFilters.set(initialTankFilters);
|
radius="none"
|
||||||
$tankopediaSort.set(initialTankopediaSort);
|
color={selected ? undefined : 'gray'}
|
||||||
}}
|
highContrast
|
||||||
>
|
onClick={() => {
|
||||||
<ReloadIcon />
|
if (tankFilters.tiers.includes(tier)) {
|
||||||
{strings.website.common.tank_search.clear_filters}
|
$tankFilters.setKey(
|
||||||
</Button>
|
'tiers',
|
||||||
</Box>
|
tankFilters.tiers.filter((t) => t !== tier),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('tiers', [
|
||||||
|
...tankFilters.tiers,
|
||||||
|
tier,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex gap="2" align="start">
|
<Flex
|
||||||
|
flexShrink="0"
|
||||||
|
direction={compact ? 'row' : { initial: 'row', md: 'column' }}
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-5)' }}
|
||||||
|
>
|
||||||
<Flex
|
<Flex
|
||||||
overflow="hidden"
|
|
||||||
style={{ borderRadius: 'var(--radius-full)' }}
|
|
||||||
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
>
|
||||||
<IconButton
|
{gameDefinitions.nations
|
||||||
variant={
|
.slice(0, Math.ceil(gameDefinitions.nations.length / 2))
|
||||||
tankFilters.types?.includes(TankType.RESEARCHABLE)
|
.map((nation) => {
|
||||||
? 'solid'
|
const selected = tankFilters.nations?.includes(nation);
|
||||||
: 'soft'
|
|
||||||
}
|
return (
|
||||||
radius="none"
|
<IconButton
|
||||||
color={
|
key={nation}
|
||||||
tankFilters.types?.includes(TankType.RESEARCHABLE)
|
variant={selected ? 'solid' : 'soft'}
|
||||||
? undefined
|
color={selected ? undefined : 'gray'}
|
||||||
: 'gray'
|
highContrast
|
||||||
}
|
radius="none"
|
||||||
highContrast
|
onClick={() => {
|
||||||
onClick={() => {
|
if (tankFilters.nations.includes(nation)) {
|
||||||
if (tankFilters.types.includes(TankType.RESEARCHABLE)) {
|
$tankFilters.setKey(
|
||||||
$tankFilters.setKey(
|
'nations',
|
||||||
'types',
|
tankFilters.nations.filter((n) => n !== nation),
|
||||||
tankFilters.types.filter(
|
);
|
||||||
(t) => t !== TankType.RESEARCHABLE,
|
} else {
|
||||||
),
|
$tankFilters.setKey('nations', [
|
||||||
);
|
...tankFilters.nations,
|
||||||
} else {
|
nation,
|
||||||
$tankFilters.setKey('types', [
|
]);
|
||||||
...tankFilters.types,
|
}
|
||||||
TankType.RESEARCHABLE,
|
}}
|
||||||
]);
|
>
|
||||||
}
|
<img
|
||||||
}}
|
style={{ width: '1em', height: '1em' }}
|
||||||
|
src={asset(`flags/circle/${nation}.webp`)}
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
display={{ initial: 'none', md: 'block' }}
|
||||||
|
style={{
|
||||||
|
height: Var('space-1'),
|
||||||
|
backgroundColor: Var('gray-a3'),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
|
>
|
||||||
|
{gameDefinitions.nations
|
||||||
|
.slice(Math.ceil(gameDefinitions.nations.length / 2))
|
||||||
|
.map((nation) => {
|
||||||
|
const selected = tankFilters.nations?.includes(nation);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IconButton
|
||||||
|
key={nation}
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
variant={selected ? 'solid' : 'soft'}
|
||||||
|
color={selected ? undefined : 'gray'}
|
||||||
|
highContrast
|
||||||
|
radius="none"
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.nations.includes(nation)) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'nations',
|
||||||
|
tankFilters.nations.filter((n) => n !== nation),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('nations', [
|
||||||
|
...tankFilters.nations,
|
||||||
|
nation,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
style={{ width: '1em', height: '1em' }}
|
||||||
|
src={asset(`flags/circle/${nation}.webp`)}
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
direction={{ initial: 'row', md: 'column' }}
|
||||||
|
align="start"
|
||||||
|
gap={{ initial: '2', md: '1' }}
|
||||||
|
>
|
||||||
|
<Flex gap="2" align="start">
|
||||||
|
<Flex
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-full)' }}
|
||||||
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
>
|
||||||
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
{TANK_CLASSES.map((tankClass) => {
|
||||||
</IconButton>
|
const Icon = classIcons[tankClass];
|
||||||
<IconButton
|
const selected = tankFilters.classes?.includes(tankClass);
|
||||||
variant={
|
|
||||||
tankFilters.types?.includes(TankType.PREMIUM) ? 'solid' : 'soft'
|
return (
|
||||||
}
|
<IconButton
|
||||||
radius="none"
|
key={tankClass}
|
||||||
color={
|
variant={selected ? 'solid' : 'soft'}
|
||||||
tankFilters.types?.includes(TankType.PREMIUM) ? 'amber' : 'gray'
|
radius="none"
|
||||||
}
|
color={selected ? undefined : 'gray'}
|
||||||
highContrast
|
highContrast
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (tankFilters.types.includes(TankType.PREMIUM)) {
|
if (tankFilters.classes.includes(tankClass)) {
|
||||||
$tankFilters.setKey(
|
$tankFilters.setKey(
|
||||||
'types',
|
'classes',
|
||||||
tankFilters.types.filter((t) => t !== TankType.PREMIUM),
|
tankFilters.classes.filter((c) => c !== tankClass),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$tankFilters.setKey('types', [
|
$tankFilters.setKey('classes', [
|
||||||
...tankFilters.types,
|
...tankFilters.classes,
|
||||||
TankType.PREMIUM,
|
tankClass,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
<Icon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</IconButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-full)' }}
|
||||||
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
>
|
||||||
<Text
|
<IconButton
|
||||||
|
variant={
|
||||||
|
tankFilters.gunType.includes('regular') ? 'solid' : 'soft'
|
||||||
|
}
|
||||||
|
radius="none"
|
||||||
|
color={
|
||||||
|
tankFilters.gunType.includes('regular') ? undefined : 'gray'
|
||||||
|
}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.gunType.includes('regular')) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'gunType',
|
||||||
|
tankFilters.gunType.filter((t) => t !== 'regular'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('gunType', [
|
||||||
|
...tankFilters.gunType,
|
||||||
|
'regular',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GunRegularIcon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
variant={
|
||||||
|
tankFilters.gunType.includes('auto_loader') ? 'solid' : 'soft'
|
||||||
|
}
|
||||||
|
radius="none"
|
||||||
|
color={
|
||||||
|
tankFilters.gunType.includes('auto_loader')
|
||||||
|
? undefined
|
||||||
|
: 'gray'
|
||||||
|
}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.gunType.includes('auto_loader')) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'gunType',
|
||||||
|
tankFilters.gunType.filter((t) => t !== 'auto_loader'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('gunType', [
|
||||||
|
...tankFilters.gunType,
|
||||||
|
'auto_loader',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GunAutoloaderIcon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
variant={
|
||||||
|
tankFilters.gunType.includes('auto_reloader')
|
||||||
|
? 'solid'
|
||||||
|
: 'soft'
|
||||||
|
}
|
||||||
|
radius="none"
|
||||||
|
color={
|
||||||
|
tankFilters.gunType.includes('auto_reloader')
|
||||||
|
? undefined
|
||||||
|
: 'gray'
|
||||||
|
}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.gunType.includes('auto_reloader')) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'gunType',
|
||||||
|
tankFilters.gunType.filter((t) => t !== 'auto_reloader'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('gunType', [
|
||||||
|
...tankFilters.gunType,
|
||||||
|
'auto_reloader',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GunAutoreloaderIcon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</IconButton>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-full)' }}
|
||||||
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
|
>
|
||||||
|
<ShellFilter index={0} />
|
||||||
|
<ShellFilter index={1} premium />
|
||||||
|
<ShellFilter index={2} />
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex gap="2" align="start">
|
||||||
|
<Flex
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: 'var(--radius-full)' }}
|
||||||
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
variant={
|
||||||
|
tankFilters.types?.includes(TankType.RESEARCHABLE)
|
||||||
|
? 'solid'
|
||||||
|
: 'soft'
|
||||||
|
}
|
||||||
|
radius="none"
|
||||||
|
color={
|
||||||
|
tankFilters.types?.includes(TankType.RESEARCHABLE)
|
||||||
|
? undefined
|
||||||
|
: 'gray'
|
||||||
|
}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.types.includes(TankType.RESEARCHABLE)) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'types',
|
||||||
|
tankFilters.types.filter(
|
||||||
|
(t) => t !== TankType.RESEARCHABLE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('types', [
|
||||||
|
...tankFilters.types,
|
||||||
|
TankType.RESEARCHABLE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</IconButton>
|
||||||
|
<IconButton
|
||||||
|
variant={
|
||||||
|
tankFilters.types?.includes(TankType.PREMIUM)
|
||||||
|
? 'solid'
|
||||||
|
: 'soft'
|
||||||
|
}
|
||||||
|
radius="none"
|
||||||
color={
|
color={
|
||||||
tankFilters.types?.includes(TankType.PREMIUM)
|
tankFilters.types?.includes(TankType.PREMIUM)
|
||||||
? undefined
|
? 'amber'
|
||||||
: 'amber'
|
: 'gray'
|
||||||
}
|
}
|
||||||
style={{ display: 'flex', justifyContent: 'center' }}
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.types.includes(TankType.PREMIUM)) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'types',
|
||||||
|
tankFilters.types.filter((t) => t !== TankType.PREMIUM),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('types', [
|
||||||
|
...tankFilters.types,
|
||||||
|
TankType.PREMIUM,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
<Text
|
||||||
</Text>
|
color={
|
||||||
</IconButton>
|
tankFilters.types?.includes(TankType.PREMIUM)
|
||||||
<IconButton
|
? undefined
|
||||||
variant={
|
: 'amber'
|
||||||
tankFilters.types?.includes(TankType.COLLECTOR)
|
}
|
||||||
? 'solid'
|
style={{ display: 'flex', justifyContent: 'center' }}
|
||||||
: 'soft'
|
>
|
||||||
}
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
||||||
radius="none"
|
</Text>
|
||||||
color={
|
</IconButton>
|
||||||
tankFilters.types?.includes(TankType.COLLECTOR)
|
<IconButton
|
||||||
? 'blue'
|
variant={
|
||||||
: 'gray'
|
tankFilters.types?.includes(TankType.COLLECTOR)
|
||||||
}
|
? 'solid'
|
||||||
highContrast
|
: 'soft'
|
||||||
onClick={() => {
|
|
||||||
if (tankFilters.types.includes(TankType.COLLECTOR)) {
|
|
||||||
$tankFilters.setKey(
|
|
||||||
'types',
|
|
||||||
tankFilters.types.filter((t) => t !== TankType.COLLECTOR),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$tankFilters.setKey('types', [
|
|
||||||
...tankFilters.types,
|
|
||||||
TankType.COLLECTOR,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}}
|
radius="none"
|
||||||
>
|
|
||||||
<Text
|
|
||||||
color={
|
color={
|
||||||
tankFilters.types?.includes(TankType.COLLECTOR)
|
tankFilters.types?.includes(TankType.COLLECTOR)
|
||||||
? undefined
|
? 'blue'
|
||||||
: 'blue'
|
: 'gray'
|
||||||
}
|
}
|
||||||
style={{ display: 'flex', justifyContent: 'center' }}
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
if (tankFilters.types.includes(TankType.COLLECTOR)) {
|
||||||
|
$tankFilters.setKey(
|
||||||
|
'types',
|
||||||
|
tankFilters.types.filter((t) => t !== TankType.COLLECTOR),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$tankFilters.setKey('types', [
|
||||||
|
...tankFilters.types,
|
||||||
|
TankType.COLLECTOR,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
<Text
|
||||||
</Text>
|
color={
|
||||||
</IconButton>
|
tankFilters.types?.includes(TankType.COLLECTOR)
|
||||||
</Flex>
|
? undefined
|
||||||
|
: 'blue'
|
||||||
|
}
|
||||||
|
style={{ display: 'flex', justifyContent: 'center' }}
|
||||||
|
>
|
||||||
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
||||||
|
</Text>
|
||||||
|
</IconButton>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
style={{ borderRadius: 'var(--radius-full)' }}
|
style={{ borderRadius: 'var(--radius-full)' }}
|
||||||
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
variant={tankFilters.testing === 'include' ? 'solid' : 'soft'}
|
|
||||||
radius="none"
|
|
||||||
color={tankFilters.testing === 'include' ? undefined : 'gray'}
|
|
||||||
highContrast
|
|
||||||
onClick={() => {
|
|
||||||
$tankFilters.setKey('testing', 'include');
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ExperimentIcon
|
<IconButton
|
||||||
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
variant={tankFilters.testing === 'include' ? 'solid' : 'soft'}
|
||||||
/>
|
radius="none"
|
||||||
</IconButton>
|
color={tankFilters.testing === 'include' ? undefined : 'gray'}
|
||||||
<IconButton
|
highContrast
|
||||||
variant={tankFilters.testing === 'exclude' ? 'solid' : 'soft'}
|
onClick={() => {
|
||||||
radius="none"
|
$tankFilters.setKey('testing', 'include');
|
||||||
color={tankFilters.testing === 'exclude' ? undefined : 'gray'}
|
}}
|
||||||
highContrast
|
>
|
||||||
onClick={() => {
|
<ExperimentIcon
|
||||||
$tankFilters.setKey('testing', 'exclude');
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
||||||
}}
|
/>
|
||||||
>
|
</IconButton>
|
||||||
<ScienceOffIcon
|
<IconButton
|
||||||
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
variant={tankFilters.testing === 'exclude' ? 'solid' : 'soft'}
|
||||||
/>
|
radius="none"
|
||||||
</IconButton>
|
color={tankFilters.testing === 'exclude' ? undefined : 'gray'}
|
||||||
<IconButton
|
highContrast
|
||||||
variant={tankFilters.testing === 'only' ? 'solid' : 'soft'}
|
onClick={() => {
|
||||||
radius="none"
|
$tankFilters.setKey('testing', 'exclude');
|
||||||
color={tankFilters.testing === 'only' ? undefined : 'gray'}
|
}}
|
||||||
highContrast
|
>
|
||||||
onClick={() => {
|
<ScienceOffIcon
|
||||||
$tankFilters.setKey('testing', 'only');
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
||||||
}}
|
/>
|
||||||
>
|
</IconButton>
|
||||||
<ScienceIcon
|
<IconButton
|
||||||
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
variant={tankFilters.testing === 'only' ? 'solid' : 'soft'}
|
||||||
/>
|
radius="none"
|
||||||
</IconButton>
|
color={tankFilters.testing === 'only' ? undefined : 'gray'}
|
||||||
</Flex>
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
<Flex
|
$tankFilters.setKey('testing', 'only');
|
||||||
overflow="hidden"
|
}}
|
||||||
style={{ borderRadius: 'var(--radius-full)' }}
|
>
|
||||||
direction={compact ? 'column' : { md: 'row', initial: 'column' }}
|
<ScienceIcon
|
||||||
>
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
||||||
<ShellFilter index={0} />
|
/>
|
||||||
<ShellFilter index={1} premium />
|
</IconButton>
|
||||||
<ShellFilter index={2} />
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Box display={{ initial: 'block', md: 'none' }} ml="4">
|
{clearable && (
|
||||||
<IconButton
|
<Link
|
||||||
color="red"
|
color="red"
|
||||||
onClick={() => {
|
underline="always"
|
||||||
|
mt="4"
|
||||||
|
href="#"
|
||||||
|
onClick={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
$tankFilters.set(initialTankFilters);
|
$tankFilters.set(initialTankFilters);
|
||||||
$tankopediaSort.set(initialTankopediaSort);
|
$tankopediaSort.set(initialTankopediaSort);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ReloadIcon />
|
{strings.website.common.tank_search.clear_filters}
|
||||||
</IconButton>
|
</Link>
|
||||||
</Box>
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user