@@ -4,11 +4,12 @@ import {
4
4
objectFromEntries ,
5
5
pickObject ,
6
6
omitObject ,
7
- tones ,
8
7
isObject ,
9
8
runIfFunc ,
10
9
isFunction ,
11
10
merge ,
11
+ isArray ,
12
+ tones ,
12
13
} from "@yamada-ui/utils"
13
14
import type { CSSUIObject , ThemeProps , UIStyle , UIStyleProps } from "./css"
14
15
import { analyzeBreakpoints , createVars } from "./css"
@@ -142,7 +143,7 @@ const createTokens = (
142
143
const defaultTokenEntries : [ string , VarToken ] [ ] = Object . entries (
143
144
flattenObject ( defaultTokenMap , Infinity , omitKeys ) ,
144
145
) . map ( ( [ token , value ] ) => {
145
- const enhancedToken = { isSemantic : false , value }
146
+ const enhancedToken : VarToken = { isSemantic : false , value }
146
147
147
148
return [ token , enhancedToken ]
148
149
} )
@@ -151,15 +152,26 @@ const createTokens = (
151
152
) . reduce (
152
153
( prev , [ token , value ] ) => {
153
154
if ( token . startsWith ( "colorSchemes." ) ) {
154
- const [ , semanticToken ] = token . split ( "." )
155
+ const [ , semanticToken , tone ] = token . split ( "." )
155
156
156
- tones . forEach ( ( tone ) => {
157
- const enhancedToken = { isSemantic : true , value : ` ${ value } . ${ tone } ` }
157
+ if ( tone ) {
158
+ const enhancedToken = { isSemantic : false , value }
158
159
159
160
prev . push ( [ `colors.${ semanticToken } .${ tone } ` , enhancedToken ] )
160
- } )
161
+ } else {
162
+ tones . forEach ( ( tone ) => {
163
+ const enhancedToken : VarToken = {
164
+ isSemantic : true ,
165
+ value : isArray ( value )
166
+ ? [ `${ value [ 0 ] } .${ tone } ` , `${ value [ 1 ] } .${ tone } ` ]
167
+ : `${ value } .${ tone } ` ,
168
+ }
169
+
170
+ prev . push ( [ `colors.${ semanticToken } .${ tone } ` , enhancedToken ] )
171
+ } )
172
+ }
161
173
} else {
162
- const enhancedToken = { isSemantic : true , value }
174
+ const enhancedToken : VarToken = { isSemantic : true , value }
163
175
164
176
prev . push ( [ token , enhancedToken ] )
165
177
}
0 commit comments