diff --git a/src/components/OrderableList.tsx b/src/components/OrderableList.tsx index c539909..a896480 100644 --- a/src/components/OrderableList.tsx +++ b/src/components/OrderableList.tsx @@ -14,6 +14,11 @@ export default function LanguageSwitcher(props: Props): JSX.Element { props.onChange?.(items); }, [items]); + function updateOrder(sourceIndex: number, targetIndex: number) { + const newItems = arrayMove([...items], sourceIndex, targetIndex); + setItems(new Map(newItems)); + } + return (
{[...items].map(([key, value], index) => ( @@ -50,16 +55,37 @@ export default function LanguageSwitcher(props: Props): JSX.Element { event.dataTransfer.getData("text"), 10 ); - const newItems = arrayMove([...items], sourceIndex, targetIndex); - setItems(new Map(newItems)); + updateOrder(sourceIndex, targetIndex); }} - className="grid place-content-center place-items-center + className="grid grid-cols-[auto_1fr] place-content-center border-[1px] transition-all hover:text-light hover:bg-dark hover:drop-shadow-shade-lg border-dark bg-light text-dark - rounded-full px-4 pt-[0.4rem] pb-[0.5rem] cursor-grab select-none" + rounded-full cursor-grab select-none px-1 py-2 pr-4 gap-2" key={key} draggable > +
+ {index > 0 && ( + { + updateOrder(index, index - 1); + }} + > + arrow_drop_up + + )} + {index < items.size - 1 && ( + { + updateOrder(index, index + 1); + }} + > + arrow_drop_down + + )} +
{value}