"use client"; import { IconButton } from "@azmr/ui/button"; import { Icon } from "@azmr/ui/icons"; import { MotionProvider, Reorder, springs } from "@azmr/ui/motion"; import { ArrowDown, ArrowUp, GripVertical } from "lucide-react"; import { useState } from "react"; const initial = ["Write the brief", "Design the tokens", "Build the components", "Ship the docs"]; export default function ReorderDemo() { const [items, setItems] = useState(initial); // Dragging is not available to everyone, so every move also has buttons. const move = (index: number, by: -1 | 1) => { const next = [...items]; const target = index + by; if (target < 0 || target >= next.length) return; [next[index], next[target]] = [next[target] as string, next[index] as string]; setItems(next); }; return ( {items.map((item, index) => ( {item} } label={`Move "${item}" up`} size="sm" disabled={index === 0} onClick={() => move(index, -1)} /> } label={`Move "${item}" down`} size="sm" disabled={index === items.length - 1} onClick={() => move(index, 1)} /> ))} ); }