mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-28 04:59:50 +01:00
feat: simplify
This commit is contained in:
1 parent
f837aaf40a
commit
87438abaa3
1 file changed
+66
-1
@@ -7,7 +7,11 @@ import {
|
|||||||
TankType,
|
TankType,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import { TrashIcon } from "@radix-ui/react-icons";
|
import {
|
||||||
|
LockClosedIcon,
|
||||||
|
LockOpen2Icon,
|
||||||
|
TrashIcon,
|
||||||
|
} from "@radix-ui/react-icons";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
@@ -15,11 +19,14 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
IconButton,
|
IconButton,
|
||||||
Text,
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
type FlexProps,
|
||||||
} from "@radix-ui/themes";
|
} from "@radix-ui/themes";
|
||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
import type { ComponentProps, ReactNode } from "react";
|
import type { ComponentProps, ReactNode } from "react";
|
||||||
import { awaitableGameDefinitions } from "../../../core/awaitables/gameDefinitions";
|
import { awaitableGameDefinitions } from "../../../core/awaitables/gameDefinitions";
|
||||||
import { useLocale } from "../../../hooks/useLocale";
|
import { useLocale } from "../../../hooks/useLocale";
|
||||||
|
import { App } from "../../../stores/app";
|
||||||
import { TankFilters, type CaseType } from "../../../stores/tankFilters";
|
import { TankFilters, type CaseType } from "../../../stores/tankFilters";
|
||||||
import { classIcons } from "../../ClassIcon";
|
import { classIcons } from "../../ClassIcon";
|
||||||
import { GunAutoloaderIcon } from "../../GunAutoloaderIcon";
|
import { GunAutoloaderIcon } from "../../GunAutoloaderIcon";
|
||||||
@@ -69,6 +76,7 @@ export function FilterControl() {
|
|||||||
<ClassFilter />
|
<ClassFilter />
|
||||||
<GunTypeFilter />
|
<GunTypeFilter />
|
||||||
<ShellFilter />
|
<ShellFilter />
|
||||||
|
<OwnershipFilter />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -587,3 +595,60 @@ function IndividualShellFilter({
|
|||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OwnershipFilter() {
|
||||||
|
const wargaming = App.use((state) => state.logins.wargaming);
|
||||||
|
const { strings } = useLocale();
|
||||||
|
|
||||||
|
return wargaming ? (
|
||||||
|
<OwnershipFilterInternal />
|
||||||
|
) : (
|
||||||
|
<Tooltip content={strings.website.common.tank_search.login}>
|
||||||
|
<OwnershipFilterInternal />
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OwnershipFilterInternal(props: FlexProps) {
|
||||||
|
const wargaming = App.use((state) => state.logins.wargaming);
|
||||||
|
const showOwned = TankFilters.use((state) => state.showOwned);
|
||||||
|
const showUnowned = TankFilters.use((state) => state.showUnowned);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex
|
||||||
|
overflow="hidden"
|
||||||
|
style={{ borderRadius: "var(--radius-full)" }}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
disabled={!wargaming}
|
||||||
|
variant={showOwned ? "solid" : "soft"}
|
||||||
|
radius="none"
|
||||||
|
color={showOwned ? undefined : "gray"}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
TankFilters.mutate((draft) => {
|
||||||
|
draft.showOwned = !draft.showOwned;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LockOpen2Icon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
disabled={!wargaming}
|
||||||
|
variant={showUnowned ? "solid" : "soft"}
|
||||||
|
radius="none"
|
||||||
|
color={showUnowned ? undefined : "gray"}
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
TankFilters.mutate((draft) => {
|
||||||
|
draft.showUnowned = !draft.showUnowned;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LockClosedIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user