fix numbers being interpreted as colors
parent
f809595659
commit
7978c9e6dc
|
@ -9,7 +9,7 @@ import {
|
|||
} from 'vscode-languageserver'
|
||||
const dlv = require('dlv')
|
||||
import removeMeta from '../util/removeMeta'
|
||||
import { getColor, getColorFromString } from '../util/color'
|
||||
import { getColor, getColorFromValue } from '../util/color'
|
||||
import { isHtmlContext } from '../util/html'
|
||||
import { isCssContext } from '../util/css'
|
||||
import { findLast, findJsxStrings, arrFindLast } from '../util/find'
|
||||
|
@ -269,7 +269,7 @@ function provideCssHelperCompletions(
|
|||
return {
|
||||
isIncomplete: false,
|
||||
items: Object.keys(obj).map((item, index) => {
|
||||
let color = getColorFromString(obj[item])
|
||||
let color = getColorFromValue(obj[item])
|
||||
const replaceDot: boolean =
|
||||
item.indexOf('.') !== -1 && separator && separator.endsWith('.')
|
||||
const insertClosingBrace: boolean =
|
||||
|
|
|
@ -61,11 +61,12 @@ export function getColor(
|
|||
return { documentation: colorStrings[0] }
|
||||
}
|
||||
|
||||
export function getColorFromString(str: string): string {
|
||||
if (str === 'transparent') {
|
||||
export function getColorFromValue(value: unknown): string {
|
||||
if (typeof value !== 'string') return null
|
||||
if (value === 'transparent') {
|
||||
return 'rgba(0, 0, 0, 0.01)'
|
||||
}
|
||||
const color = new TinyColor(str)
|
||||
const color = new TinyColor(value)
|
||||
if (color.isValid) {
|
||||
return color.toRgbString()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue