Home / Function/ getColors() — ui Function Reference

getColors() — ui Function Reference

Architecture documentation for the getColors() function in colors.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  99de8c20_3740_56dc_5dbd_6723bac57629["getColors()"]
  955bc1fa_55c7_f589_a22c_805b535067fd["colors.ts"]
  99de8c20_3740_56dc_5dbd_6723bac57629 -->|defined in| 955bc1fa_55c7_f589_a22c_805b535067fd
  6b606878_0d79_8de6_e626_663ec772f427["getForegroundFromBackground()"]
  99de8c20_3740_56dc_5dbd_6723bac57629 -->|calls| 6b606878_0d79_8de6_e626_663ec772f427
  style 99de8c20_3740_56dc_5dbd_6723bac57629 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/lib/colors.ts lines 36–75

export function getColors() {
  const tailwindColors = colorPaletteSchema.array().parse(
    Object.entries(colors)
      .map(([name, color]) => {
        if (!Array.isArray(color)) {
          return null
        }

        return {
          name,
          colors: color.map((color) => {
            const rgb = color.rgb.replace(
              /^rgb\((\d+),(\d+),(\d+)\)$/,
              "$1 $2 $3"
            )

            return {
              ...color,
              name,
              id: `${name}-${color.scale}`,
              className: `${name}-${color.scale}`,
              rgb,
              hsl: color.hsl.replace(
                /^hsl\(([\d.]+),([\d.]+%),([\d.]+%)\)$/,
                "$1 $2 $3"
              ),
              oklch: color.oklch.replace(
                /^oklch\(([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\)$/,
                "$1 $2 $3"
              ),
              foreground: getForegroundFromBackground(rgb),
            }
          }),
        }
      })
      .filter(Boolean)
  )

  return tailwindColors
}

Subdomains

Frequently Asked Questions

What does getColors() do?
getColors() is a function in the ui codebase, defined in deprecated/www/lib/colors.ts.
Where is getColors() defined?
getColors() is defined in deprecated/www/lib/colors.ts at line 36.
What does getColors() call?
getColors() calls 1 function(s): getForegroundFromBackground.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free