import { useSentenceStore } from '../../stores/sentenceStore'; import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, DragEndEvent } from '@dnd-kit/core'; import { arrayMove, SortableContext, sortableKeyboardCoordinates, horizontalListSortingStrategy } from '@dnd-kit/sortable'; import { SortableToken } from './SortableToken'; import { X } from 'lucide-react'; import { Button } from '../ui/button'; interface TokenTrayProps { compact?: boolean; } export function TokenTray({ compact = false }: TokenTrayProps) { const { currentTokens, reorderTokens, removeToken, clearTokens } = useSentenceStore(); const sensors = useSensors( useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates, }) ); const handleDragEnd = (event: DragEndEvent) => { const { active, over } = event; if (over && active.id !== over.id) { const oldIndex = currentTokens.findIndex((token) => token.id === active.id); const newIndex = currentTokens.findIndex((token) => token.id === over.id); const newTokens = arrayMove(currentTokens, oldIndex, newIndex); reorderTokens(newTokens); } }; // Conditional styling based on compact mode const containerClass = compact ? "bg-white rounded-lg shadow-sm p-3" : "bg-white rounded-lg shadow p-6"; const headerClass = compact ? "text-lg font-semibold text-gray-900" : "text-xl font-semibold text-gray-900"; const gapClass = compact ? "gap-2" : "gap-3"; return (
Nema riječi u rečenici
Idite na Rječnik i dodajte riječi klikom na "Dodaj"
Savjet: Povucite i ispustite riječi za promjenu redoslijeda. Kliknite "Spremi" za spremanje rečenice u dokument.