镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit c9bc43b

Browse files
committed
style: build the color fast-path overlay from a diff map
1 parent 1a0d618 commit c9bc43b

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎packages/crosswind/src/generator.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,12 +1486,11 @@ function processConfig(config: CrosswindConfig): ProcessedConfig {
14861486
}
14871487
const spacingValues = spacingCustom ? { ...SPACING_VALUES, ...config.theme.spacing } : SPACING_VALUES
14881488

1489-
let colorsOverlay: Record<string, string> | null = null
1489+
const colorDiffs: Record<string, string> = {}
14901490
for (const [name, value] of Object.entries(config.theme.colors)) {
14911491
if (typeof value === 'string') {
14921492
if (COMMON_COLORS[name] !== undefined && COMMON_COLORS[name] !== value) {
1493-
colorsOverlay ??= { ...COMMON_COLORS }
1494-
colorsOverlay[name] = value
1493+
colorDiffs[name] = value
14951494
}
14961495
}
14971496
else if (value && typeof value === 'object') {
@@ -1500,12 +1499,12 @@ function processConfig(config: CrosswindConfig): ProcessedConfig {
15001499
continue
15011500
const key = shade === 'DEFAULT' ? name : `${name}-${shade}`
15021501
if (COMMON_COLORS[key] !== undefined && COMMON_COLORS[key] !== shadeValue) {
1503-
colorsOverlay ??= { ...COMMON_COLORS }
1504-
colorsOverlay[key] = shadeValue
1502+
colorDiffs[key] = shadeValue
15051503
}
15061504
}
15071505
}
15081506
}
1507+
const commonColors = Object.keys(colorDiffs).length > 0 ? { ...COMMON_COLORS, ...colorDiffs } : COMMON_COLORS
15091508

15101509
// Radius/shadow static entries can't be patched cheaply (multi-property
15111510
// outputs), so a customized theme skips the static map and lets the
@@ -1523,7 +1522,7 @@ function processConfig(config: CrosswindConfig): ProcessedConfig {
15231522
config,
15241523
variantEnabled: config.variants as unknown as Record<string, boolean>,
15251524
spacingValues,
1526-
commonColors: colorsOverlay ?? COMMON_COLORS,
1525+
commonColors,
15271526
skipStaticRadius,
15281527
skipStaticShadow,
15291528
screenBreakpoints: new Map(Object.entries(config.theme.screens)),

0 commit comments

Comments
 (0)