@@ -3,20 +3,21 @@ import path from "node:path";
3
3
4
4
import { fileURLToPath } from "node:url" ;
5
5
import React from "react" ;
6
+ import { Color } from "./color" ;
6
7
7
8
const __filename = fileURLToPath ( import . meta. url ) ;
8
9
const __dirname = path . dirname ( __filename ) ;
9
10
10
- const styles = await fs . readFile ( path . join ( __dirname , "../../node_modules/tailwindcss/theme.css" ) , "utf-8" ) ;
11
+ let styles = await fs . readFile ( path . join ( __dirname , "../../node_modules/tailwindcss/theme.css" ) , "utf-8" ) ;
11
12
12
13
let colors : Record < string , Record < string , string > > = { } ;
13
14
for ( let line of styles . split ( "\n" ) ) {
14
15
if ( line . startsWith ( " --color-" ) ) {
15
- const [ key , value ] = line . split ( ":" ) . map ( ( part ) => part . trim ( ) . replace ( ";" , "" ) ) ;
16
- const match = key . match ( / ^ - - c o l o r - ( [ a - z ] + ) - ( \d + ) $ / ) ;
16
+ let [ key , value ] = line . split ( ":" ) . map ( ( part ) => part . trim ( ) . replace ( ";" , "" ) ) ;
17
+ let match = key . match ( / ^ - - c o l o r - ( [ a - z ] + ) - ( \d + ) $ / ) ;
17
18
18
19
if ( match ) {
19
- const [ , group , shade ] = match ;
20
+ let [ , group , shade ] = match ;
20
21
21
22
if ( ! colors [ group ] ) {
22
23
colors [ group ] = { } ;
@@ -49,11 +50,7 @@ export function ColorPalette() {
49
50
< p className = "font-medium text-gray-950 capitalize sm:pr-12 dark:text-white" > { key } </ p >
50
51
< div className = "grid grid-cols-11 gap-1.5 sm:gap-4" >
51
52
{ Object . keys ( shades ) . map ( ( shade , i ) => (
52
- < div
53
- key = { i }
54
- style = { { backgroundColor : `var(--color-${ key } -${ shade } )` } }
55
- className = "aspect-1/1 rounded-sm outline -outline-offset-1 outline-black/10 sm:rounded-md dark:outline-white/10"
56
- />
53
+ < Color key = { i } name = { key } shade = { shade } value = { shades [ shade ] } />
57
54
) ) }
58
55
</ div >
59
56
</ React . Fragment >
0 commit comments