Home / File/ merge-theme.ts — ui Source File

merge-theme.ts — ui Source File

Architecture documentation for merge-theme.ts, a typescript file in the ui codebase. 2 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  12447887_bd7b_5eba_2717_085623b94c4c["merge-theme.ts"]
  ceec689a_1334_a657_3c35_094070222b09["schema"]
  12447887_bd7b_5eba_2717_085623b94c4c --> ceec689a_1334_a657_3c35_094070222b09
  f14cf7ca_f213_afc2_bc66_ebc0fb7d9834["config"]
  12447887_bd7b_5eba_2717_085623b94c4c --> f14cf7ca_f213_afc2_bc66_ebc0fb7d9834
  style 12447887_bd7b_5eba_2717_085623b94c4c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { registryItemSchema, type RegistryItem } from "shadcn/schema"

import { BASE_COLORS, THEMES } from "@/registry/config"

export function buildTheme(baseColorName: string, themeName: string) {
  const baseColor = BASE_COLORS.find((c) => c.name === baseColorName)
  const theme = THEMES.find((t) => t.name === themeName)

  if (!baseColor || !theme) {
    throw new Error(
      `Base color "${baseColorName}" or theme "${themeName}" not found`
    )
  }

  const mergedTheme: RegistryItem = {
    name: `${baseColor.name}-${theme.name}`,
    title: `${baseColor.title} ${theme.title}`,
    type: "registry:theme",
    cssVars: {
      light: {
        ...baseColor.cssVars?.light,
        ...theme.cssVars?.light,
      },
      dark: {
        ...baseColor.cssVars?.dark,
        ...theme.cssVars?.dark,
      },
    },
  }

  return registryItemSchema.parse(mergedTheme)
}

Domain

Subdomains

Functions

Dependencies

  • config
  • schema

Frequently Asked Questions

What does merge-theme.ts do?
merge-theme.ts is a source file in the ui codebase, written in typescript. It belongs to the DesignEngine domain, StateManagement subdomain.
What functions are defined in merge-theme.ts?
merge-theme.ts defines 1 function(s): buildTheme.
What does merge-theme.ts depend on?
merge-theme.ts imports 2 module(s): config, schema.
Where is merge-theme.ts in the architecture?
merge-theme.ts is located at apps/v4/app/(create)/lib/merge-theme.ts (domain: DesignEngine, subdomain: StateManagement, directory: apps/v4/app/(create)/lib).

Analyze Your Own Codebase

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

Try Supermodel Free