Skip to content

Commit 338a97d

Browse files
authored
fix: correct dark value in getLightDarkValue() for --rh-color-surface (#170)
* fix: correct dark value in getLightDarkValue() for --rh-color-surface * docs: fix theme color token samp to use the last array value * chore: undo accidentally pushed changes
1 parent c6571b8 commit 338a97d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.changeset/tame-symbols-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rhds/tokens": patch
3+
---
4+
5+
Fixed dark value for `--rh-color-surface` in light-dark()

lib/11ty/preview-page-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export async function PreviewPagePlugin(eleventyConfig: UserConfig) {
207207
<td class="sample theme-token">
208208
<div class="values">
209209
<samp style="background-color: var(--${derefValue(token.original.$value.at(0))});"></samp>
210-
<samp style="background-color: var(--${derefValue(token.original.$value.at(1))});"></samp>
210+
<samp style="background-color: var(--${derefValue(token.original.$value.at(-1))});"></samp>
211211
</div>
212212
</td>
213213
<td class="token name">

lib/transforms/color.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ export function getLightDarkValue(token: Token) {
6161
if (typeof token.$value === 'string' && token.$value.startsWith('light-dark')) {
6262
return token.$value;
6363
} else {
64-
const [light, dark] = token.$value;
65-
const [lightRef, darkRef] = token.original.$value;
64+
const [light] = token.$value;
65+
const dark = token.$value.at(-1);
66+
const [lightRef] = token.original.$value;
67+
const darkRef = token.original.$value.at(-1);
6668
return `light-dark(${deref(lightRef, light)}, ${deref(darkRef, dark)})`;
6769
}
6870
}

0 commit comments

Comments
 (0)