File size: 1,574 Bytes
3b81d2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
"use client"

import Image from "next/image"

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"
import { LayoutName, allLayoutLabels, defaultLayout, layoutIcons } from "@/app/layouts"

export function SelectLayout({
  defaultValue = defaultLayout,
  onLayoutChange,
  disabled = false,
  layouts = [],
}: {
  defaultValue?: string | undefined
  onLayoutChange?: ((name: LayoutName) => void)
  disabled?: boolean
  layouts: string[]
}) {
  return (
    <Select
      defaultValue={defaultValue}
      onValueChange={(name) => { onLayoutChange?.(name as LayoutName) }}
      disabled={disabled}
      >
      <SelectTrigger className="flex-grow bg-gray-100 text-gray-700 dark:bg-gray-100 dark:text-gray-700">
        <SelectValue className="text-2xs md:text-sm" placeholder="Layout" />
      </SelectTrigger>
      <SelectContent>
        {layouts.map(key =>
          <SelectItem key={key} value={key} className="w-full">
            <div className="space-x-6 flex flex-row items-center justify-between">
              <div className="flex">{
                (allLayoutLabels as any)[key]
              }</div>
           
              {(layoutIcons as any)[key]
                ? <Image
                    className="rounded-sm opacity-75"
                    src={(layoutIcons as any)[key]}
                    width={20}
                    height={18}
                    alt={key}
                /> : null}
            </div>
          </SelectItem>
        )}
      </SelectContent>
    </Select>
  )
}