feat: some cleanup

This commit is contained in:
TrèsAbhi committed 2025-10-14 21:53:58 -05:00
1 parent ea048da7a2
commit ade238966b
7 files changed
+118 -113

No files matched your search

+2
View File
@@ -863,6 +863,7 @@
"reset": "Reset", "reset": "Reset",
"shuffle": "Shuffle", "shuffle": "Shuffle",
"remove": "Remove played", "remove": "Remove played",
"tracking": "BlitzKit is tracking your playlist",
"sort": { "sort": {
"button": "Sort by", "button": "Sort by",
@@ -879,6 +880,7 @@
"unrecorded": "--", "unrecorded": "--",
"wins": "Wins" "wins": "Wins"
}, },
"no_login_warning": "You are not logged in. BlitzKit will not keep track of your played tanks.", "no_login_warning": "You are not logged in. BlitzKit will not keep track of your played tanks.",
"generate": "Generate playlist", "generate": "Generate playlist",
"name": "Playlist", "name": "Playlist",
@@ -1,6 +1,6 @@
import { fisherYates } from "@blitzkit/core"; import { fisherYates } from "@blitzkit/core";
import { CaretDownIcon } from "@radix-ui/react-icons"; import { CaretDownIcon } from "@radix-ui/react-icons";
import { Button, DropdownMenu, Flex } from "@radix-ui/themes"; import { Button, DropdownMenu, Flex, Spinner } from "@radix-ui/themes";
import { useLocale } from "../hooks/useLocale"; import { useLocale } from "../hooks/useLocale";
import { App } from "../stores/app"; import { App } from "../stores/app";
import { Playlist } from "../stores/playlist"; import { Playlist } from "../stores/playlist";
@@ -10,83 +10,96 @@ export function PlaylistActions() {
const wargaming = App.use((state) => state.logins.wargaming); const wargaming = App.use((state) => state.logins.wargaming);
return ( return (
<Flex gap="2"> <>
<Button <Flex gap="2">
variant="outline" <Button
color="red" size={{ initial: "1", xs: "2" }}
onClick={() => { variant="outline"
Playlist.mutate((draft) => { color="red"
draft.list = undefined; onClick={() => {
}); Playlist.mutate((draft) => {
}} draft.list = undefined;
> });
{strings.website.tools.playlist.reset} }}
</Button> >
{strings.website.tools.playlist.reset}
</Button>
<Button <Button
variant={wargaming ? "outline" : undefined} size={{ initial: "1", xs: "2" }}
onClick={() => { variant={wargaming ? "outline" : undefined}
Playlist.mutate((draft) => { onClick={() => {
if (draft.list) fisherYates(draft.list); Playlist.mutate((draft) => {
}); if (draft.list) fisherYates(draft.list);
}} });
> }}
{strings.website.tools.playlist.shuffle} >
</Button> {strings.website.tools.playlist.shuffle}
</Button>
{wargaming && (
<>
<Button
size={{ initial: "1", xs: "2" }}
variant="outline"
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.filter(
(entry) =>
!entry.now ||
!entry.then ||
entry.now.battles === entry.then.battles
);
});
}}
>
{strings.website.tools.playlist.remove}
</Button>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button size={{ initial: "1", xs: "2" }}>
{strings.website.tools.playlist.sort.button}
<CaretDownIcon />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) => (a.then?.last ?? 0) - (b.then?.last ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.last_played}
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) =>
(a.then?.battles ?? 0) - (b.then?.battles ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.least_played}
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</>
)}
</Flex>
{wargaming && ( {wargaming && (
<> <Flex gap="2" align="center">
<Button <Spinner />
variant="outline" {strings.website.tools.playlist.tracking}
onClick={() => { </Flex>
Playlist.mutate((draft) => {
draft.list = draft.list?.filter(
(entry) =>
!entry.now ||
!entry.then ||
entry.now.battles === entry.then.battles
);
});
}}
>
{strings.website.tools.playlist.remove}
</Button>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button>
{strings.website.tools.playlist.sort.button}
<CaretDownIcon />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) => (a.then?.last ?? 0) - (b.then?.last ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.last_played}
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) => (a.then?.battles ?? 0) - (b.then?.battles ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.least_played}
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</>
)} )}
</Flex> </>
); );
} }
@@ -20,6 +20,7 @@ export function PlaylistTable() {
height: "100%", height: "100%",
width: "100%", width: "100%",
borderRadius: 0, borderRadius: 0,
whiteSpace: "nowrap",
}} }}
variant="surface" variant="surface"
> >
@@ -35,6 +35,7 @@ export const PlaylistTankEntry = memo<Props>(
}} }}
> >
<Checkbox <Checkbox
size="3"
variant="classic" variant="classic"
checked={ checked={
(checked === undefined && (checked === undefined &&
@@ -5,7 +5,6 @@ export function StickyRowHeaderCell({ style, ...props }: RowHeaderCellProps) {
return ( return (
<Table.RowHeaderCell <Table.RowHeaderCell
style={{ style={{
display: "flex",
position: "sticky", position: "sticky",
left: 0, left: 0,
backgroundColor: "var(--color-panel)", backgroundColor: "var(--color-panel)",
@@ -1,4 +1,5 @@
import { type TankDefinition, tankIcon, TankType } from "@blitzkit/core"; import { type TankDefinition, tankIcon, TankType } from "@blitzkit/core";
import { Box, Flex } from "@radix-ui/themes";
import { useLocale } from "../hooks/useLocale"; import { useLocale } from "../hooks/useLocale";
import { classIcons } from "./ClassIcon"; import { classIcons } from "./ClassIcon";
import { ExperimentIcon } from "./ExperimentIcon"; import { ExperimentIcon } from "./ExperimentIcon";
@@ -15,20 +16,6 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
return ( return (
<StickyRowHeaderCell style={{ overflow: "hidden" }}> <StickyRowHeaderCell style={{ overflow: "hidden" }}>
<LinkI18n locale={locale} href={`/tanks/${tank.slug}`} tabIndex={-1}>
<img
alt={unwrap(tank.name)}
draggable={false}
src={tankIcon(tank.id)}
style={{
margin: "calc(-1 * var(--table-cell-padding)) 0",
height: "calc(100% + 2 * var(--table-cell-padding))",
aspectRatio: "4 / 3",
objectFit: "cover",
}}
/>
</LinkI18n>
<LinkI18n <LinkI18n
locale={locale} locale={locale}
color={ color={
@@ -42,28 +29,34 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
underline="hover" underline="hover"
wrap="nowrap" wrap="nowrap"
href={`/tanks/${tank.slug}`} href={`/tanks/${tank.slug}`}
style={{ style={{ height: "100%" }}
paddingLeft: "var(--space-2)",
display: "flex",
alignItems: "center",
gap: "var(--space-1)",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
size={{ initial: "1", sm: "2" }} size={{ initial: "1", sm: "2" }}
> >
<Icon <Flex height="100%" align="center" gap="1">
width="1em" <Box
height="1em" draggable={false}
style={{ minWidth: "1em", minHeight: "1em" }} height="calc(100% + 2 * var(--table-cell-padding))"
/> style={{
aspectRatio: "4 / 3",
backgroundImage: `url(${tankIcon(tank.id)})`,
backgroundSize: "cover",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
}}
/>
{tank.testing && ( <Icon
<ExperimentIcon style={{ width: "1em", height: "1em" }} /> width="1em"
)} height="1em"
style={{ minWidth: "1em", minHeight: "1em" }}
/>
{unwrap(tank.name)} {tank.testing && (
<ExperimentIcon style={{ width: "1em", height: "1em" }} />
)}
{unwrap(tank.name)}
</Flex>
</LinkI18n> </LinkI18n>
</StickyRowHeaderCell> </StickyRowHeaderCell>
); );
+1 -5
View File
@@ -3,10 +3,6 @@
"compilerOptions": { "compilerOptions": {
"jsx": "react-jsx", "jsx": "react-jsx",
"jsxImportSource": "react", "jsxImportSource": "react",
"types": [ "types": ["vite/client"]
"vite/client",
"vite-plugin-pwa/info.d.ts",
"vite-plugin-pwa/client.d.ts"
]
} }
} }