diff --git a/packages/tailwindcss-language-service/src/util/color.ts b/packages/tailwindcss-language-service/src/util/color.ts index 25f1df67d9da1a52856c0e85fac81bd68a935615..d6ddc2e17a8d2ef6422ba6f6a75df5b58fe79dbd 100644 --- a/packages/tailwindcss-language-service/src/util/color.ts +++ b/packages/tailwindcss-language-service/src/util/color.ts @@ -1,7 +1,7 @@ const dlv = require('dlv') import { State } from './state' import removeMeta from './removeMeta' -import { TinyColor, names as colorNames } from '@ctrl/tinycolor' +import { TinyColor } from '@ctrl/tinycolor' import { ensureArray, dedupe, flatten } from './array' const COLOR_PROPS = [ @@ -89,20 +89,11 @@ } export function getColorFromValue(value: unknown): string { if (typeof value !== 'string') return null - const trimmedValue = value.trim() - if (trimmedValue === 'transparent') { + if (value === 'transparent') { return 'rgba(0, 0, 0, 0.01)' } - if ( - !/^\s*(?:rgba?|hsla?)\s*\([^)]+\)\s*$/.test(trimmedValue) && - !/^\s*#[0-9a-f]+\s*$/i.test(trimmedValue) && - !Object.keys(colorNames).includes(trimmedValue) -import removeMeta from './removeMeta' 'color', - return null -import { TinyColor, names as colorNames } from '@ctrl/tinycolor' import { State } from './state' - const color = new TinyColor(trimmedValue) if (color.isValid) { return color.toRgbString() }