apply-config-to-theme.ts — tailwindcss Source File
Architecture documentation for apply-config-to-theme.ts, a typescript file in the tailwindcss codebase. 4 imports, 7 dependents.
Entity Profile
Dependency Diagram
graph LR 245c850a_c551_a2cf_854e_bba95b5a1339["apply-config-to-theme.ts"] 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"] 245c850a_c551_a2cf_854e_bba95b5a1339 --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a 80295787_127f_69e6_91b3_4bea3a484544["theme.ts"] 245c850a_c551_a2cf_854e_bba95b5a1339 --> 80295787_127f_69e6_91b3_4bea3a484544 e64872c9_9835_78a8_455b_ad5e699f9543["ThemeOptions"] 245c850a_c551_a2cf_854e_bba95b5a1339 --> e64872c9_9835_78a8_455b_ad5e699f9543 c1272aed_91bb_73df_0746_d55fa9b302fd["types.ts"] 245c850a_c551_a2cf_854e_bba95b5a1339 --> c1272aed_91bb_73df_0746_d55fa9b302fd b2ba3368_7330_fe20_4543_9cafa8cfedc0["migrate-js-config.ts"] b2ba3368_7330_fe20_4543_9cafa8cfedc0 --> 245c850a_c551_a2cf_854e_bba95b5a1339 4ccbfbad_b80c_422a_38fe_dc35ee118e8d["migrate-preflight.ts"] 4ccbfbad_b80c_422a_38fe_dc35ee118e8d --> 245c850a_c551_a2cf_854e_bba95b5a1339 de8dd9be_8c47_4694_db3b_393c549a926a["migrate-theme-to-var.ts"] de8dd9be_8c47_4694_db3b_393c549a926a --> 245c850a_c551_a2cf_854e_bba95b5a1339 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e["canonicalize-candidates.ts"] 7d350d81_5de1_f9f3_5b2c_19ec8fd3c37e --> 245c850a_c551_a2cf_854e_bba95b5a1339 daaadd53_16ee_21c6_12d9_8feaac80a91b["apply-compat-hooks.ts"] daaadd53_16ee_21c6_12d9_8feaac80a91b --> 245c850a_c551_a2cf_854e_bba95b5a1339 15f6e0f9_47e6_d527_cc67_b512886528af["apply-config-to-theme.test.ts"] 15f6e0f9_47e6_d527_cc67_b512886528af --> 245c850a_c551_a2cf_854e_bba95b5a1339 20b59de8_11c6_2432_2a83_24f6f6e741a7["plugin-functions.ts"] 20b59de8_11c6_2432_2a83_24f6f6e741a7 --> 245c850a_c551_a2cf_854e_bba95b5a1339 style 245c850a_c551_a2cf_854e_bba95b5a1339 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { DesignSystem } from '../design-system'
import { ThemeOptions } from '../theme'
import type { ResolvedConfig } from './config/types'
function resolveThemeValue(value: unknown, subValue: string | null = null): string | null {
if (
Array.isArray(value) &&
value.length === 2 &&
typeof value[1] === 'object' &&
typeof value[1] !== null
) {
return subValue ? (value[1][subValue] ?? null) : value[0]
} else if (Array.isArray(value) && subValue === null) {
return value.join(', ')
} else if (typeof value === 'string' && subValue === null) {
return value
}
return null
}
export function applyConfigToTheme(
designSystem: DesignSystem,
{ theme }: ResolvedConfig,
replacedThemeKeys: Set<string>,
) {
for (let replacedThemeKey of replacedThemeKeys) {
let name = keyPathToCssProperty([replacedThemeKey])
if (!name) continue
designSystem.theme.clearNamespace(`--${name}`, ThemeOptions.DEFAULT)
}
for (let [path, value] of themeableValues(theme)) {
if (typeof value !== 'string' && typeof value !== 'number') {
continue
}
// Replace `<alpha-value>` with `1`
if (typeof value === 'string') {
value = value.replace(/<alpha-value>/g, '1')
}
// Convert `opacity` namespace from decimal to percentage values
if (path[0] === 'opacity' && (typeof value === 'number' || typeof value === 'string')) {
let numValue = typeof value === 'string' ? parseFloat(value) : value
if (numValue >= 0 && numValue <= 1) {
value = numValue * 100 + '%'
}
}
let name = keyPathToCssProperty(path)
if (!name) continue
designSystem.theme.add(
`--${name}`,
'' + value,
ThemeOptions.INLINE | ThemeOptions.REFERENCE | ThemeOptions.DEFAULT,
)
// ... (244 more lines)
Domain
Subdomains
Functions
Types
Dependencies
Imported By
- packages/tailwindcss/src/compat/apply-compat-hooks.ts
- packages/tailwindcss/src/compat/apply-config-to-theme.test.ts
- packages/tailwindcss/src/canonicalize-candidates.ts
- packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts
- packages/@tailwindcss-upgrade/src/codemods/css/migrate-preflight.ts
- packages/@tailwindcss-upgrade/src/codemods/template/migrate-theme-to-var.ts
- packages/tailwindcss/src/compat/plugin-functions.ts
Source
Frequently Asked Questions
What does apply-config-to-theme.ts do?
apply-config-to-theme.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, TemplateAnalysis subdomain.
What functions are defined in apply-config-to-theme.ts?
apply-config-to-theme.ts defines 7 function(s): applyConfigToTheme, isValidThemePrimitive, isValidThemeTuple, keyPathToCssProperty, resolveThemeValue, themeableValues, walk.
What does apply-config-to-theme.ts depend on?
apply-config-to-theme.ts imports 4 module(s): ThemeOptions, design-system.ts, theme.ts, types.ts.
What files import apply-config-to-theme.ts?
apply-config-to-theme.ts is imported by 7 file(s): apply-compat-hooks.ts, apply-config-to-theme.test.ts, canonicalize-candidates.ts, migrate-js-config.ts, migrate-preflight.ts, migrate-theme-to-var.ts, plugin-functions.ts.
Where is apply-config-to-theme.ts in the architecture?
apply-config-to-theme.ts is located at packages/tailwindcss/src/compat/apply-config-to-theme.ts (domain: UpgradeToolkit, subdomain: TemplateAnalysis, directory: packages/tailwindcss/src/compat).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free