From 37adc04cda572b092d24086beb50dc5670a3c45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:32:43 -0500 Subject: [PATCH] feat: drag handles --- .../website/src/components/PlaylistOrder.tsx | 132 ++---------------- .../src/components/PlaylistTankEntry.tsx | 64 +++++++++ 2 files changed, 72 insertions(+), 124 deletions(-) create mode 100644 packages/website/src/components/PlaylistTankEntry.tsx diff --git a/packages/website/src/components/PlaylistOrder.tsx b/packages/website/src/components/PlaylistOrder.tsx index 37519dd3e..c73238131 100644 --- a/packages/website/src/components/PlaylistOrder.tsx +++ b/packages/website/src/components/PlaylistOrder.tsx @@ -1,20 +1,7 @@ -import { - ChevronUpIcon, - DoubleArrowDownIcon, - DoubleArrowUpIcon, - MinusCircledIcon, -} from "@radix-ui/react-icons"; -import { - Button, - Checkbox, - ChevronDownIcon, - Flex, - IconButton, - Table, -} from "@radix-ui/themes"; +import { Button, Flex, Table } from "@radix-ui/themes"; import { useLocale } from "../hooks/useLocale"; import { Playlist } from "../stores/playlist"; -import { TankRowHeaderCell } from "./TankRowHeaderCell"; +import { PlaylistTankEntry } from "./PlaylistTankEntry"; export function PlaylistOrder() { const { strings } = useLocale(); @@ -47,115 +34,12 @@ export function PlaylistOrder() { {list.map(({ tank, checked }, index) => ( - - { - Playlist.mutate((draft) => { - draft.list![index].checked = !checked; - }); - }} - > - - - - - - - - { - Playlist.mutate((draft) => { - draft.list!.splice(index, 1); - }); - }} - style={{ - borderTopRightRadius: 0, - borderBottomRightRadius: 0, - }} - > - - - - { - const item = list[index]; - Playlist.mutate((draft) => { - draft.list!.splice(index, 1); - draft.list!.push(item); - }); - }} - > - - - - { - const item = list[index]; - Playlist.mutate((draft) => { - draft.list!.splice(index, 1); - draft.list!.unshift(item); - }); - }} - > - - - - { - const item = list[index]; - Playlist.mutate((draft) => { - const newIndex = index + 1; - draft.list!.splice(index, 1); - draft.list!.splice(newIndex, 0, item); - }); - }} - > - - - - { - 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, - }} - > - - - - - + ))} diff --git a/packages/website/src/components/PlaylistTankEntry.tsx b/packages/website/src/components/PlaylistTankEntry.tsx new file mode 100644 index 000000000..1e4c2a517 --- /dev/null +++ b/packages/website/src/components/PlaylistTankEntry.tsx @@ -0,0 +1,64 @@ +import type { TankDefinition } from "@blitzkit/core"; +import { DragHandleDots2Icon, MinusCircledIcon } from "@radix-ui/react-icons"; +import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes"; +import { Playlist } from "../stores/playlist"; +import { TankRowHeaderCell } from "./TankRowHeaderCell"; + +interface Props { + tank: TankDefinition; + checked: boolean; + index: number; +} + +export function PlaylistTankEntry({ tank, checked, index }: Props) { + return ( + + { + Playlist.mutate((draft) => { + draft.list![index].checked = !checked; + }); + }} + > + + + + + + + + { + Playlist.mutate((draft) => { + draft.list!.splice(index, 1); + }); + }} + > + + + + + + + + + + + + ); +}