Skip to content

Commit 8c667dc

Browse files
authored
Merge pull request #1 from erdemuslu/feature/is-color
Feature/is color
2 parents 06476f2 + 609538c commit 8c667dc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/utils/is-color.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ const IS_COLOR_FN = /^(rgba?|hsla?|hwb|color|(ok)?(lab|lch)|light-dark|color-mix
203203
export function isColor(value: string, theme?: CustomThemeConfig): boolean {
204204
if (!value) return false
205205

206-
let isThemeColor = false
207-
208-
if (theme) {
209-
const [trueValue,] = segment(value, '/')
210-
isThemeColor = !!trueValue.split('-').reduce((acc, val) => acc[val], theme.colors as any);
211-
}
206+
const isThemeColor =
207+
theme &&
208+
!!segment(value, "/")?.[0]
209+
.split("-")
210+
.reduce((acc, val) => acc[val], theme.colors as any);
212211

213212
return (
214213
value.charCodeAt(0) === HASH || IS_COLOR_FN.test(value) || NAMED_COLORS.has(value.toLowerCase()) || isThemeColor
215214
)
216-
}
215+
}

0 commit comments

Comments
 (0)