-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalignment-selector.tsx
54 lines (51 loc) · 1.73 KB
/
alignment-selector.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import type { Alignment } from '@/lib/types'
import {
AlignEndHorizontal,
AlignHorizontalJustifyCenter,
AlignHorizontalJustifyStart,
AlignStartHorizontal,
AlignVerticalJustifyEnd,
} from 'lucide-react'
interface AlignmentSelectorProps {
alignment: Alignment
onAlignmentChange: (alignment: Alignment) => void
}
const alignmentIcons: Record<Alignment, React.ReactNode> = {
'top-left': <AlignStartHorizontal className="h-4 w-4" />,
'top-center': <AlignVerticalJustifyEnd className="h-4 w-4 scale-y-[-1]" />,
'top-right': <AlignStartHorizontal className="h-4 w-4 scale-x-[-1]" />,
'middle-left': <AlignHorizontalJustifyStart className="h-4 w-4" />,
'middle-center': <AlignHorizontalJustifyCenter className="h-4 w-4" />,
'middle-right': (
<AlignHorizontalJustifyStart className="h-4 w-4 scale-x-[-1]" />
),
'bottom-left': <AlignEndHorizontal className="h-4 w-4" />,
'bottom-center': <AlignVerticalJustifyEnd className="h-4 w-4" />,
'bottom-right': <AlignEndHorizontal className="h-4 w-4 scale-x-[-1]" />,
}
export function AlignmentSelector({
alignment,
onAlignmentChange,
}: AlignmentSelectorProps) {
return (
<Select value={alignment} onValueChange={onAlignmentChange}>
<SelectTrigger className="h-6 px-1 w-auto gap-1 bg-primary text-primary-foreground">
<SelectValue>{alignmentIcons[alignment]}</SelectValue>
</SelectTrigger>
<SelectContent side="top" className="min-w-0">
{Object.entries(alignmentIcons).map(([key, icon]) => (
<SelectItem key={key} value={key}>
{icon}
</SelectItem>
))}
</SelectContent>
</Select>
)
}