diff --git a/apps/showcase/src/App.tsx b/apps/showcase/src/App.tsx index 5aa71f7..61f8807 100644 --- a/apps/showcase/src/App.tsx +++ b/apps/showcase/src/App.tsx @@ -46,7 +46,7 @@ export default function App() { return (
-
diff --git a/src/index.css b/src/index.css index d36f95b..9b5d5bd 100644 --- a/src/index.css +++ b/src/index.css @@ -54,7 +54,6 @@ --ui-density: 1; --ui-border-width: 1px; --ui-shadow-strength: 0; - --ui-surface-contrast: 0; --ui-font-scale: 1; --ui-heading-weight: 600; --ui-motion: 1; @@ -248,11 +247,6 @@ padding: calc(0.625rem * var(--ui-density)) calc(0.75rem * var(--ui-density)); } [data-slot="card"] { - background: color-mix( - in oklch, - var(--card), - var(--foreground) calc(var(--ui-surface-contrast) * 1%) - ); box-shadow: 0 calc(0.4rem * var(--ui-shadow-strength)) calc(1.8rem * var(--ui-shadow-strength)) rgb(0 0 0 / calc(0.12 * var(--ui-shadow-strength))); diff --git a/src/theme/BaseThemeSelector.tsx b/src/theme/BaseThemeSelector.tsx index 2ac0b20..def173a 100644 --- a/src/theme/BaseThemeSelector.tsx +++ b/src/theme/BaseThemeSelector.tsx @@ -45,7 +45,12 @@ export function ThemeSelector({ return ( <> -
+
{themes.map((theme) => (
-
-
- ); -} diff --git a/src/theme/pickers/StylePicker.tsx b/src/theme/pickers/StylePicker.tsx index 2fa903b..17dda87 100644 --- a/src/theme/pickers/StylePicker.tsx +++ b/src/theme/pickers/StylePicker.tsx @@ -1,4 +1,4 @@ -import { useId, useState, type ReactNode } from "react"; +import { useId, useState, type ComponentProps, type ReactNode } from "react"; import { ChevronDown, RotateCcw } from "lucide-react"; import { Button } from "../../cmp/button"; @@ -14,8 +14,8 @@ import { Slider } from "../../cmp/slider"; import { ThemeSelector } from "../BaseThemeSelector"; import { useTheme } from "../Provider"; import type { ThemeDesign, ThemeFontFamily } from "../types"; +import { MAX_BORDER_RADIUS, MIN_BORDER_RADIUS } from "../utils"; import { Base16Picker } from "./Base16Picker"; -import { BorderRadiusPicker } from "./BorderRadiusPicker"; import { CustomCssPicker } from "./CustomCssPicker"; import { PolarityPicker } from "./PolarityPicker"; import { PrimaryPicker } from "./PrimaryPicker"; @@ -30,32 +30,23 @@ function Section({ title, children }: { title: string; children: ReactNode }) { ); } -function DesignSlider({ +function ThemeSlider({ label, - field, + value, min, max, step, + onValueChange, format = (value) => String(value), }: { label: string; - field: keyof Pick< - ThemeDesign, - | "density" - | "borderWidth" - | "shadowStrength" - | "surfaceContrast" - | "fontScale" - | "headingWeight" - | "motion" - >; + value: number; min: number; max: number; step: number; + onValueChange: (value: number) => void; format?: (value: number) => string; }) { - const { themeDesign, setThemeDesign } = useTheme(); - const value = themeDesign[field]; const id = useId(); return (
@@ -75,16 +66,39 @@ function DesignSlider({ step={step} value={[value]} onValueChange={(next) => - setThemeDesign((current) => ({ - ...current, - [field]: Array.isArray(next) ? (next[0] ?? value) : next, - })) + onValueChange(Array.isArray(next) ? (next[0] ?? value) : next) } />
); } +function DesignSlider({ + field, + ...props +}: Omit, "value" | "onValueChange"> & { + field: keyof Pick< + ThemeDesign, + | "density" + | "borderWidth" + | "shadowStrength" + | "fontScale" + | "headingWeight" + | "motion" + >; +}) { + const { themeDesign, setThemeDesign } = useTheme(); + return ( + + setThemeDesign((current) => ({ ...current, [field]: value })) + } + /> + ); +} + export function ThemeCustomizer({ value, onValueChange, @@ -97,6 +111,8 @@ export function ThemeCustomizer({ const { themeDesign, setThemeDesign, + themeBorderRadius, + setThemeBorderRadius, parentTheme, isThemeCustomized, resetThemePreset, @@ -113,7 +129,7 @@ export function ThemeCustomizer({
-
+
`${v}px`} /> - - `${value.toFixed(3)}rem`} + onValueChange={setThemeBorderRadius} />
-
+