Home

tailwind-ctp-intellisense @ab8baace620fb78812b1f4566f9f02637ca2c624 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / src / util.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as fs from 'fs'
import Color from 'color'
import tmp from 'tmp'

export function createTempFile(content: string, options = {}): Promise<string> {
  return new Promise((resolve, reject) => {
    tmp.file(options, (err, path) => {
      if (err) return reject(err)
      fs.writeFile(path, content, { encoding: 'utf8' }, err => {
        if (err) return reject(err)
        resolve(path)
      })
    })
  })
}

export function getSvgColorFromValue(value: string): string {
  if (typeof value !== 'string') return null

  if (value === 'transparent') {
    return 'none'
  }

  try {
    let parsed = Color(value)
    if (parsed.valpha === 0) return 'none'
    return parsed.rgb().string()
  } catch (err) {
    return null
  }
}