feat(ui): add LateralityPicker modal component
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
93b079feb7
commit
20d60b939a
1 file changed
+62
@@ -0,0 +1,62 @@
|
||||
import Dialog from '@/components/ui/Dialog'
|
||||
import Button from '@/components/ui/Button'
|
||||
import type { LateralSide } from '@/domain/schema/observation'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface LateralityPickerProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
onSelect: (sides: LateralSide[]) => void
|
||||
title: string
|
||||
existingSides: LateralSide[]
|
||||
}
|
||||
|
||||
export default function LateralityPicker({
|
||||
open,
|
||||
onClose,
|
||||
onSelect,
|
||||
title,
|
||||
existingSides,
|
||||
}: LateralityPickerProps) {
|
||||
const t = useT()
|
||||
const hasLeft = existingSides.includes('left')
|
||||
const hasRight = existingSides.includes('right')
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} title={title} size="sm">
|
||||
<div className="space-y-4">
|
||||
<p className="text-sm text-[var(--color-ink-muted)]">
|
||||
{t('lateral.which_side')}
|
||||
</p>
|
||||
<div className="flex gap-3 justify-center">
|
||||
<Button
|
||||
variant={hasLeft ? 'ghost' : 'primary'}
|
||||
disabled={hasLeft}
|
||||
onClick={() => onSelect(['left'])}
|
||||
>
|
||||
{t('lateral.left')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={hasRight ? 'ghost' : 'primary'}
|
||||
disabled={hasRight}
|
||||
onClick={() => onSelect(['right'])}
|
||||
>
|
||||
{t('lateral.right')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={hasLeft && hasRight ? 'ghost' : 'primary'}
|
||||
disabled={hasLeft && hasRight}
|
||||
onClick={() => {
|
||||
const sides: LateralSide[] = []
|
||||
if (!hasLeft) sides.push('left')
|
||||
if (!hasRight) sides.push('right')
|
||||
onSelect(sides)
|
||||
}}
|
||||
>
|
||||
{t('lateral.both')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user