MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / nestedCssToClassNames

Function nestedCssToClassNames

packages/extension/utils/tailwind.ts:1204–1227  ·  view source on GitHub ↗
(style: NestedStyleMap)

Source from the content-addressed store, hash-verified

1202}
1203
1204export function nestedCssToClassNames(style: NestedStyleMap): string[] {
1205 const base: Record<string, string> = {}
1206 const nestedEntries: Array<{ selector: string; style: Record<string, string> }> = []
1207
1208 for (const [key, value] of Object.entries(style)) {
1209 if (typeof value === 'string') {
1210 base[key] = value
1211 continue
1212 }
1213 if (!value || typeof value !== 'object' || Array.isArray(value)) continue
1214 nestedEntries.push({ selector: key, style: value })
1215 }
1216
1217 const classNames = cssToClassNamesWithArbitraryProperties(base)
1218
1219 for (const entry of nestedEntries) {
1220 const variant = nestedSelectorToVariant(entry.selector)
1221 if (!variant) continue
1222 const nestedClassNames = cssToClassNamesWithArbitraryProperties(entry.style)
1223 classNames.push(...nestedClassNames.map((className) => `${variant}:${className}`))
1224 }
1225
1226 return Array.from(new Set(classNames))
1227}
1228
1229export function joinClassNames(classNames: string[]): string {
1230 return classNames.filter(Boolean).join(' ')

Callers 2

tailwind.test.tsFile · 0.90
styleToClassNamesFunction · 0.90

Tested by

no test coverage detected