diff --git a/components/admin/guide-section-editor.tsx b/components/admin/guide-section-editor.tsx index 84a002c..76c0632 100644 --- a/components/admin/guide-section-editor.tsx +++ b/components/admin/guide-section-editor.tsx @@ -68,6 +68,12 @@ import { import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Checkbox } from "@/components/ui/checkbox"; +import { + ColorPicker, + ColorPickerEyeDropper, + ColorPickerHue, + ColorPickerSelection, +} from "@/components/ui/color-picker"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Card, @@ -105,6 +111,7 @@ import { FieldSet, } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Select, SelectContent, @@ -4894,53 +4901,66 @@ function ExtraEditor({ guide, extraSectionId, initial, characters, weapons, arti ) || undefined} > สีพื้นหลัง - { - if (row.backgroundColor !== null) return; - setSections( - sections.map((item, index) => - index === sectionIndex - ? { - ...item, - rows: item.rows.map((candidate, inner) => - inner === rowIndex - ? { - ...candidate, - backgroundColor: DEFAULT_EXTRA_BACKGROUND_COLOR, - } - : candidate, - ), - } - : item, - ), - ); - }} - onChange={(event) => - setSections( - sections.map((item, index) => - index === sectionIndex - ? { - ...item, - rows: item.rows.map((candidate, inner) => - inner === rowIndex - ? { ...candidate, backgroundColor: event.target.value } - : candidate, - ), - } - : item, - ), - ) - } - /> + + + + + } + /> + + { + if (!Array.isArray(color)) return; + const backgroundColor = `#${color + .slice(0, 3) + .map((channel) => + Math.round(channel).toString(16).padStart(2, "0"), + ) + .join("")}`.toUpperCase(); + setSections( + sections.map((item, index) => + index === sectionIndex + ? { + ...item, + rows: item.rows.map((candidate, inner) => + inner === rowIndex + ? { ...candidate, backgroundColor } + : candidate, + ), + } + : item, + ), + ); + }} + > + + + + + +