feat: even cleaner filters

This commit is contained in:
TrèsAbhi committed 2023-12-06 12:48:19 -06:00
1 parent 84a1af8100
commit fb9c04c779
2 files changed
+98 -93

No files matched your search

@@ -27,7 +27,8 @@ export function Options() {
const tankopediaState = useTankopedia(); const tankopediaState = useTankopedia();
return ( return (
<Flex justify="center" wrap="wrap" gap="2"> <Flex justify="center" direction="column" gap="2">
<Flex gap="2" style={{ flex: 1 }} wrap="wrap">
<Button <Button
color="red" color="red"
onClick={() => onClick={() =>
@@ -44,7 +45,6 @@ export function Options() {
> >
Clear Clear
</Button> </Button>
<DropdownMenu.Root> <DropdownMenu.Root>
<DropdownMenu.Trigger> <DropdownMenu.Trigger>
<Button variant="soft"> <Button variant="soft">
@@ -71,7 +71,6 @@ export function Options() {
</DropdownMenu.RadioGroup> </DropdownMenu.RadioGroup>
</DropdownMenu.Content> </DropdownMenu.Content>
</DropdownMenu.Root> </DropdownMenu.Root>
<Flex style={{ flex: 1 }}> <Flex style={{ flex: 1 }}>
{TREE_TYPES.map((type, index) => ( {TREE_TYPES.map((type, index) => (
<Button <Button
@@ -110,7 +109,6 @@ export function Options() {
</Button> </Button>
))} ))}
</Flex> </Flex>
<Flex style={{ flex: 1 }}> <Flex style={{ flex: 1 }}>
{[...TANK_TYPES].reverse().map((type, index) => ( {[...TANK_TYPES].reverse().map((type, index) => (
<Button <Button
@@ -147,84 +145,6 @@ export function Options() {
</Button> </Button>
))} ))}
</Flex> </Flex>
<Flex className={styles.oneLineFilters} style={{ flex: 1 }}>
{[...TIERS].reverse().map((tier, index) => (
<Button
key={tier}
variant={
tankopediaState.filters.tiers.includes(tier) ? 'solid' : 'soft'
}
style={{
flex: 1,
margin: -0.5,
borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius: index === TIERS.length - 1 ? undefined : 0,
borderBottomRightRadius:
index === TIERS.length - 1 ? undefined : 0,
}}
onClick={() =>
mutateTankopedia((draft) => {
if (draft.filters.tiers.includes(tier)) {
draft.filters.tiers = draft.filters.tiers.filter(
(preexistingTier) => preexistingTier !== tier,
);
} else {
draft.filters.tiers.push(tier);
}
})
}
>
{TIER_ROMAN_NUMERALS[tier]}
</Button>
))}
</Flex>
<Flex className={styles.oneLineFilters} style={{ flex: 1 }}>
{nations.map((nation, index) => (
<Button
key={nation}
variant={
tankopediaState.filters.nations.includes(nation)
? 'solid'
: 'soft'
}
style={{
flex: 1,
margin: -0.5,
borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius:
index === nations.length - 1 ? undefined : 0,
borderBottomRightRadius:
index === nations.length - 1 ? undefined : 0,
}}
onClick={() =>
mutateTankopedia((draft) => {
if (draft.filters.nations.includes(nation)) {
draft.filters.nations = draft.filters.nations.filter(
(preexistingType) => preexistingType !== nation,
);
} else {
draft.filters.nations.push(nation);
}
})
}
>
<img
src={asset(`flags/circle/${nation}.webp`)}
style={{
width: '1em',
height: '1em',
scale: 2,
transform: 'translate(15%, 15%)',
}}
/>
</Button>
))}
</Flex>
<Flex <Flex
direction="column" direction="column"
className={styles.splitFilters} className={styles.splitFilters}
@@ -248,7 +168,9 @@ export function Options() {
borderTopLeftRadius: index === 0 ? undefined : 0, borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: 0, borderBottomLeftRadius: 0,
borderTopRightRadius: borderTopRightRadius:
index === TIERS.length - 6 ? undefined : 0, index === TIERS.length - Math.round(TIERS.length / 2) - 1
? undefined
: 0,
borderBottomRightRadius: 0, borderBottomRightRadius: 0,
}} }}
onClick={() => onClick={() =>
@@ -267,7 +189,6 @@ export function Options() {
</Button> </Button>
))} ))}
</Flex> </Flex>
<Flex> <Flex>
{[...TIERS] {[...TIERS]
.reverse() .reverse()
@@ -287,7 +208,9 @@ export function Options() {
borderBottomLeftRadius: index === 0 ? undefined : 0, borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius: 0, borderTopRightRadius: 0,
borderBottomRightRadius: borderBottomRightRadius:
index === TIERS.length - 6 ? undefined : 0, index === TIERS.length - Math.round(TIERS.length / 2) - 1
? undefined
: 0,
}} }}
onClick={() => onClick={() =>
mutateTankopedia((draft) => { mutateTankopedia((draft) => {
@@ -306,7 +229,6 @@ export function Options() {
))} ))}
</Flex> </Flex>
</Flex> </Flex>
<Flex <Flex
direction="column" direction="column"
className={styles.splitFilters} className={styles.splitFilters}
@@ -327,7 +249,9 @@ export function Options() {
borderTopLeftRadius: index === 0 ? undefined : 0, borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: 0, borderBottomLeftRadius: 0,
borderTopRightRadius: borderTopRightRadius:
index === nations.length - 5 ? undefined : 0, index === nations.length - Math.round(nations.length / 2)
? undefined
: 0,
borderBottomRightRadius: borderBottomRightRadius:
index === nations.length - 1 ? undefined : 0, index === nations.length - 1 ? undefined : 0,
}} }}
@@ -373,7 +297,90 @@ export function Options() {
borderTopRightRadius: borderTopRightRadius:
index === nations.length - 1 ? undefined : 0, index === nations.length - 1 ? undefined : 0,
borderBottomRightRadius: borderBottomRightRadius:
index === nations.length - 6 ? undefined : 0, index ===
nations.length - Math.round(nations.length / 2) - 1
? undefined
: 0,
}}
onClick={() =>
mutateTankopedia((draft) => {
if (draft.filters.nations.includes(nation)) {
draft.filters.nations = draft.filters.nations.filter(
(preexistingType) => preexistingType !== nation,
);
} else {
draft.filters.nations.push(nation);
}
})
}
>
<img
src={asset(`flags/circle/${nation}.webp`)}
style={{
width: '1em',
height: '1em',
scale: 2,
transform: 'translate(15%, 15%)',
}}
/>
</Button>
))}
</Flex>
</Flex>
</Flex>
<Flex gap="2" style={{ flex: 1 }} wrap="wrap">
<Flex className={styles.oneLineFilters} style={{ flex: 1 }}>
{[...TIERS].reverse().map((tier, index) => (
<Button
key={tier}
variant={
tankopediaState.filters.tiers.includes(tier) ? 'solid' : 'soft'
}
style={{
flex: 1,
margin: -0.5,
borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius:
index === TIERS.length - 1 ? undefined : 0,
borderBottomRightRadius:
index === TIERS.length - 1 ? undefined : 0,
}}
onClick={() =>
mutateTankopedia((draft) => {
if (draft.filters.tiers.includes(tier)) {
draft.filters.tiers = draft.filters.tiers.filter(
(preexistingTier) => preexistingTier !== tier,
);
} else {
draft.filters.tiers.push(tier);
}
})
}
>
{TIER_ROMAN_NUMERALS[tier]}
</Button>
))}
</Flex>
<Flex className={styles.oneLineFilters} style={{ flex: 1 }}>
{nations.map((nation, index) => (
<Button
key={nation}
variant={
tankopediaState.filters.nations.includes(nation)
? 'solid'
: 'soft'
}
style={{
flex: 1,
margin: -0.5,
borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius:
index === nations.length - 1 ? undefined : 0,
borderBottomRightRadius:
index === nations.length - 1 ? undefined : 0,
}} }}
onClick={() => onClick={() =>
mutateTankopedia((draft) => { mutateTankopedia((draft) => {
+3 -5
View File
@@ -28,14 +28,13 @@ import { theme } from '../../../stitches.config';
import mutateTankopedia, { import mutateTankopedia, {
TankopediaSortBy, TankopediaSortBy,
TankopediaSortDirection, TankopediaSortDirection,
TankopediaTestTankDisplay,
useTankopedia, useTankopedia,
} from '../../../stores/tankopedia'; } from '../../../stores/tankopedia';
import { Options } from './components/Options'; import { Options } from './components/Options';
import { PageTurner } from './components/PageTurner'; import { PageTurner } from './components/PageTurner';
import * as styles from './page.css'; import * as styles from './page.css';
const TANKS_PER_PAGE = 3 * 2 ** 4; const TANKS_PER_PAGE = 3 * 2 ** 3;
export default function Page() { export default function Page() {
const tankopediaState = useTankopedia(); const tankopediaState = useTankopedia();
@@ -102,7 +101,7 @@ export default function Page() {
return ( return (
<PageWrapper size="wide" color="purple"> <PageWrapper size="wide" color="purple">
<Suspense fallback={<Text>Loading...</Text>}> <Suspense fallback={<Text>Loading...</Text>}>
<Flex direction="column" gap="6"> <Flex direction="column" gap="4">
<Flex gap="2"> <Flex gap="2">
<TextField.Root style={{ flex: 1 }}> <TextField.Root style={{ flex: 1 }}>
<TextField.Slot> <TextField.Slot>
@@ -174,10 +173,10 @@ export default function Page() {
</DropdownMenu.RadioGroup> </DropdownMenu.RadioGroup>
</DropdownMenu.Content> </DropdownMenu.Content>
</DropdownMenu.Root> </DropdownMenu.Root>
</Flex> </Flex>
<Options /> <Options />
</Flex>
<PageTurner <PageTurner
page={page} page={page}
@@ -185,7 +184,6 @@ export default function Page() {
tanksPerPage={TANKS_PER_PAGE} tanksPerPage={TANKS_PER_PAGE}
searchedList={searchedList} searchedList={searchedList}
/> />
</Flex>
<Flex wrap="wrap" gap="3" justify="center"> <Flex wrap="wrap" gap="3" justify="center">
{searchedList {searchedList