mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 19:49:50 +01:00
feat: action button
This commit is contained in:
1 parent
ef173758aa
commit
cc957466fc
3 files changed
+123
-6
No files matched your search
@@ -1,4 +1,17 @@
|
|||||||
import { Button, Checkbox, Flex, Table } from "@radix-ui/themes";
|
import {
|
||||||
|
ChevronUpIcon,
|
||||||
|
DoubleArrowDownIcon,
|
||||||
|
DoubleArrowUpIcon,
|
||||||
|
MinusCircledIcon,
|
||||||
|
} from "@radix-ui/react-icons";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
ChevronDownIcon,
|
||||||
|
Flex,
|
||||||
|
IconButton,
|
||||||
|
Table,
|
||||||
|
} from "@radix-ui/themes";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../hooks/useLocale";
|
||||||
import { Playlist } from "../stores/playlist";
|
import { Playlist } from "../stores/playlist";
|
||||||
import { TankRowHeaderCell } from "./TankRowHeaderCell";
|
import { TankRowHeaderCell } from "./TankRowHeaderCell";
|
||||||
@@ -28,17 +41,120 @@ export function PlaylistOrder() {
|
|||||||
<Table.ColumnHeaderCell>
|
<Table.ColumnHeaderCell>
|
||||||
{strings.website.tools.playlist.table.tank}
|
{strings.website.tools.playlist.table.tank}
|
||||||
</Table.ColumnHeaderCell>
|
</Table.ColumnHeaderCell>
|
||||||
|
<Table.ColumnHeaderCell />
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Header>
|
</Table.Header>
|
||||||
|
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
{list.map(({ tank }) => (
|
{list.map(({ tank, checked }, index) => (
|
||||||
<Table.Row>
|
<Table.Row key={tank.id}>
|
||||||
<Table.Cell>
|
<Table.Cell
|
||||||
<Checkbox variant="classic" checked={Math.random() > 0.5} />
|
onClick={() => {
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
draft.list![index].checked = !checked;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Checkbox variant="classic" checked={checked} />
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
|
|
||||||
<TankRowHeaderCell tank={tank} />
|
<TankRowHeaderCell tank={tank} />
|
||||||
|
|
||||||
|
<Table.Cell>
|
||||||
|
<Flex align="center" height="100%" px="2" mb="-1">
|
||||||
|
<IconButton
|
||||||
|
variant="soft"
|
||||||
|
size="1"
|
||||||
|
onClick={() => {
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
draft.list!.splice(index, 1);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
borderTopRightRadius: 0,
|
||||||
|
borderBottomRightRadius: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MinusCircledIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
radius="none"
|
||||||
|
disabled={index === list.length - 1}
|
||||||
|
variant="soft"
|
||||||
|
size="1"
|
||||||
|
color="gray"
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
const item = list[index];
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
draft.list!.splice(index, 1);
|
||||||
|
draft.list!.push(item);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DoubleArrowDownIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
radius="none"
|
||||||
|
disabled={index === 0}
|
||||||
|
variant="soft"
|
||||||
|
size="1"
|
||||||
|
color="gray"
|
||||||
|
onClick={() => {
|
||||||
|
const item = list[index];
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
draft.list!.splice(index, 1);
|
||||||
|
draft.list!.unshift(item);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DoubleArrowUpIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
radius="none"
|
||||||
|
disabled={index === list.length - 1}
|
||||||
|
variant="soft"
|
||||||
|
size="1"
|
||||||
|
color="gray"
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
const item = list[index];
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
const newIndex = index + 1;
|
||||||
|
draft.list!.splice(index, 1);
|
||||||
|
draft.list!.splice(newIndex, 0, item);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
disabled={index === 0}
|
||||||
|
variant="soft"
|
||||||
|
size="1"
|
||||||
|
color="gray"
|
||||||
|
highContrast
|
||||||
|
onClick={() => {
|
||||||
|
const item = list[index];
|
||||||
|
Playlist.mutate((draft) => {
|
||||||
|
const newIndex = index - 1;
|
||||||
|
draft.list!.splice(index, 1);
|
||||||
|
draft.list!.splice(newIndex, 0, item);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
borderTopLeftRadius: 0,
|
||||||
|
borderBottomLeftRadius: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Flex>
|
||||||
|
</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
))}
|
))}
|
||||||
</Table.Body>
|
</Table.Body>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const tanks = Object.values(tankDefinitions.tanks);
|
|||||||
|
|
||||||
export async function generatePlaylist() {
|
export async function generatePlaylist() {
|
||||||
const id = App.state.logins.wargaming?.id;
|
const id = App.state.logins.wargaming?.id;
|
||||||
const filtered = await filterTanks(TankFilters.state, tanks);
|
const filtered = await filterTanks(TankFilters.state, tanks, id);
|
||||||
const statsList = id ? await getTankStats(idToRegion(id), id) : undefined;
|
const statsList = id ? await getTankStats(idToRegion(id), id) : undefined;
|
||||||
const stats: Record<number, IndividualTankStats> = {};
|
const stats: Record<number, IndividualTankStats> = {};
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export interface Playlist {
|
|||||||
tank: TankDefinition;
|
tank: TankDefinition;
|
||||||
battles?: number;
|
battles?: number;
|
||||||
wins?: number;
|
wins?: number;
|
||||||
|
checked: boolean;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user