Skip to content

Commit

Permalink
feat: add oklch color format support for /colors (#6441)
Browse files Browse the repository at this point in the history
  • Loading branch information
jccdev45 authored Jan 24, 2025
1 parent 5f7957a commit ddf761e
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/www/lib/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const colorSchema = z.object({
rgb: z.string(),
hsl: z.string(),
foreground: z.string(),
oklch: z.string(),
})

const colorPaletteSchema = z.object({
Expand All @@ -26,6 +27,7 @@ export function getColorFormat(color: Color) {
hex: color.hex,
rgb: color.rgb,
hsl: color.hsl,
oklch: color.oklch,
}
}

Expand Down Expand Up @@ -57,6 +59,10 @@ export function getColors() {
/^hsl\(([\d.]+),([\d.]+%),([\d.]+%)\)$/,
"$1 $2 $3"
),
oklch: color.oklch.replace(
/^oklch\(([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\)$/,
"$1 $2 $3"
),
foreground: getForegroundFromBackground(rgb),
}
}),
Expand Down
Loading

0 comments on commit ddf761e

Please sign in to comment.