|
2 | 2 |
|
3 | 3 | import { useEffect, useState } from 'react';
|
4 | 4 | import Chroma from 'chroma-js';
|
| 5 | +import Color from 'colorjs.io'; |
5 | 6 |
|
6 | 7 | import { createPngNoiseBackground } from '@/lib/noise';
|
7 | 8 |
|
8 | 9 | const hexToOklchString = (hex: string) => {
|
9 |
| - const color = Chroma(hex); |
10 |
| - const oklab = color.oklab(); |
11 |
| - |
12 |
| - return oklab.map((value: any) => value.toFixed(2)).join(' '); |
| 10 | + return new Color(hex).oklch; |
13 | 11 | };
|
14 | 12 |
|
15 | 13 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
@@ -51,8 +49,9 @@ const AccentColorStyleInjector = () => {
|
51 | 49 | const lightOklch = hexToOklchString(lightColor);
|
52 | 50 | const darkOklch = hexToOklchString(darkColor);
|
53 | 51 |
|
54 |
| - const [hl, sl, ll] = lightOklch.split(' '); |
55 |
| - const [hd, sd, ld] = darkOklch.split(' '); |
| 52 | + const [hl, sl, ll] = lightOklch; |
| 53 | + const [hd, sd, ld] = darkOklch; |
| 54 | + console.log(lightColor, hl, sl, ll); |
56 | 55 |
|
57 | 56 | const [lightBgImage, darkBgImage] = await Promise.all([
|
58 | 57 | createPngNoiseBackground(lightColor),
|
|
0 commit comments