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