Files
faunosteo/apps/app/src/components/editor/fields/MoveButtons.tsx
T

42 lines
900 B
TypeScript

import { useT } from '@/i18n/useT'
import ActionButton from './ActionButton'
/** ↑ / ↓ for a list row: one `move` per press; absent while read-only. */
export default function MoveButtons({
index,
count,
readOnly,
onMove,
}: {
index: number
count: number
readOnly: boolean
onMove: (position: number) => void
}) {
const t = useT()
return (
<>
<ActionButton
readOnly={readOnly}
variant="ghost"
size="sm"
aria-label={t('editor.action.move_up')}
disabled={index === 0}
onClick={() => onMove(index - 1)}
>
↑
</ActionButton>
<ActionButton
readOnly={readOnly}
variant="ghost"
size="sm"
aria-label={t('editor.action.move_down')}
disabled={index >= count - 1}
onClick={() => onMove(index + 1)}
>
↓
</ActionButton>
</>
)
}