MCPcopy Create free account
hub / github.com/bytebase/bytebase / callCssVariable

Function callCssVariable

frontend/src/utils/css.ts:65–83  ·  view source on GitHub ↗
(
  name: string,
  convertColorFromTailwindToHex = true
)

Source from the content-addressed store, hash-verified

63 * @returns
64 */
65export const callCssVariable = (
66 name: string,
67 convertColorFromTailwindToHex = true
68) => {
69 const value = getComputedStyle(document.documentElement)
70 .getPropertyValue(name)
71 .trim();
72 if (convertColorFromTailwindToHex) {
73 const matches = value.match(/^(\d+) (\d+) (\d+)$/);
74 if (matches) {
75 const r = parseInt(matches[1], 10);
76 const g = parseInt(matches[2], 10);
77 const b = parseInt(matches[3], 10);
78 return rgbToHex(r, g, b);
79 }
80 }
81
82 return value;
83};

Callers 1

buildAdviceHoverMessageFunction · 0.90

Calls 2

parseIntFunction · 0.85
rgbToHexFunction · 0.85

Tested by

no test coverage detected