From b126858d8e1b77a30c5081625ca2733a705f9ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Thu, 16 Jan 2025 12:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=87=AA=E5=8A=A8=E8=89=B2?= =?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E7=9A=84=E5=9F=BA=E6=9C=AC=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 + src/pages/Palette.module.css | 47 +++++++++++++++ src/pages/Palette.tsx | 111 +++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 src/pages/Palette.module.css create mode 100644 src/pages/Palette.tsx diff --git a/src/App.tsx b/src/App.tsx index 7f91fc7..54cf8a3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,6 +10,7 @@ import { LightenDarken } from './pages/LightenDarken'; import { MainLayout } from './pages/MainLayout'; import { Mixer } from './pages/Mixer'; import { NewScheme } from './pages/NewScheme'; +import { AutomaticPalette } from './pages/Palette'; import { SchemeDetail } from './pages/SchemeDetail'; import { SchemeNotFound } from './pages/SchemeNotFound'; import { Schemes } from './pages/Schemes'; @@ -39,6 +40,7 @@ const routes = createBrowserRouter([ { path: 'tints-shades', element: }, { path: 'lighten-darken', element: }, { path: 'mixer', element: }, + { path: 'palette', element: }, { path: 'wacg', element: }, { path: 'compare', element: }, { diff --git a/src/pages/Palette.module.css b/src/pages/Palette.module.css new file mode 100644 index 0000000..54a8322 --- /dev/null +++ b/src/pages/Palette.module.css @@ -0,0 +1,47 @@ +@layer pages { + .palette_workspace { + flex-direction: column; + } + .palette_section { + width: 100%; + flex: 1; + display: flex; + flex-direction: row; + align-items: stretch; + gap: var(--spacing-m); + } + .function_side { + display: flex; + flex-direction: column; + gap: var(--spacing-m); + font-size: var(--font-size-s); + .mode_navigation { + display: flex; + flex-direction: column; + align-items: stretch; + gap: var(--spacing-s); + } + h5 { + padding-block: var(--spacing-m); + font-size: var(--font-size-m); + } + } + .palette_content { + flex: 1; + padding: 0 var(--spacing-m); + display: flex; + flex-direction: column; + gap: var(--spacing-s); + h5 { + padding-block: var(--spacing-m); + font-size: var(--font-size-m); + } + .color_value_mode { + display: flex; + flex-direction: row; + align-items: center; + gap: var(--spacing-s); + font-size: var(--font-size-s); + } + } +} diff --git a/src/pages/Palette.tsx b/src/pages/Palette.tsx new file mode 100644 index 0000000..dac505b --- /dev/null +++ b/src/pages/Palette.tsx @@ -0,0 +1,111 @@ +import cx from 'clsx'; +import { useAtom } from 'jotai'; +import { useEffect, useMemo, useState } from 'react'; +import { ColorPicker } from '../components/ColorPicker'; +import { HSegmentedControl } from '../components/HSegmentedControl'; +import { Labeled } from '../components/Labeled'; +import { LabeledPicker } from '../components/LabeledPicker'; +import { ScrollArea } from '../components/ScrollArea'; +import { Switch } from '../components/Switch'; +import { currentPickedColor } from '../stores/colors'; +import styles from './Palette.module.css'; + +export function AutomaticPalette() { + const [selectedColor, setSelectedColor] = useAtom(currentPickedColor); + const [useReferenceColor, setUseReferenceColor] = useState(false); + const [swatchAmount, setSwatchAmount] = useState(5); + const maxBias = useMemo( + () => (swatchAmount > 3 ? Math.floor(swatchAmount / 2) - 1 : 0), + [swatchAmount], + ); + const [referenceBias, setReferenceBias] = useState(0); + const [minLightness, setMinLightness] = useState(10); + const [maxLightness, setMaxLightness] = useState(90); + const [mode, setMode] = useState<'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch'>('hex'); + + useEffect(() => { + if (useReferenceColor) { + setReferenceBias(0); + } + }, [swatchAmount, useReferenceColor]); + + return ( +
+
+

Automatic Palette

+

+ Automatically generate a color palette suitable for UI color matching according to the + given color algorithm. +

+
+ +
+ +
+
Generated Palette
+
+ + +
+
+
+
+
+ ); +}