Files
faunosteo/apps/app/src/components/editor/annotations/KeyboardAdd.tsx
T

40 lines
1.1 KiB
TypeScript

import Button from '@/components/ui/Button'
import type { NewKind } from '@/editor/annotations/creation'
import { useT } from '@/i18n/useT'
const KINDS: readonly NewKind[] = ['point', 'zone', 'detail_trigger']
/**
* The keyboard creation path (C7): each button holds a pending element at the centre of
* the frame and opens the creation panel; every coordinate is then typed in the fields.
*/
export default function KeyboardAdd({
disabled,
linkDisabled,
onAdd,
}: {
/** No measured frame, or no category: nothing can be placed. */
disabled: boolean
/** No detail view directly under this view: no link can be placed. */
linkDisabled: boolean
onAdd: (kind: NewKind) => void
}) {
const t = useT()
return (
<div className="flex flex-wrap gap-2">
{KINDS.map((kind) => (
<Button
key={kind}
type="button"
variant="secondary"
size="sm"
disabled={disabled || (kind === 'detail_trigger' && linkDisabled)}
onClick={() => onAdd(kind)}
>
{t(`editor.annotations.add.${kind}`)}
</Button>
))}
</div>
)
}