Skip to content

Commit 592e0c5

Browse files
authored
fix: accessible badges for light & dark themes (#412)
1 parent 3746747 commit 592e0c5

5 files changed

Lines changed: 62 additions & 28 deletions

File tree

app/assets/main.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,25 @@
2222
--border-subtle: oklch(0.239 0 0);
2323
--border-hover: oklch(0.371 0 0);
2424

25+
/* accent color, set by user from settings */
2526
--accent: var(--accent-color, oklch(1 0 0));
2627
--accent-muted: var(--accent-color, oklch(0.922 0 0));
2728

29+
/* syntax highlighting colors */
2830
--syntax-fn: oklch(0.727 0.137 299.149);
2931
--syntax-str: oklch(0.829 0.088 252.458);
3032
--syntax-kw: oklch(0.721 0.162 15.494);
3133
--syntax-comment: oklch(0.551 0.019 250.976);
34+
35+
/* badge colors for background & text */
36+
--badge-orange: oklch(0.67 0.185 55);
37+
--badge-yellow: oklch(0.588 0.183 91);
38+
--badge-green: oklch(0.566 0.202 165);
39+
--badge-cyan: oklch(0.571 0.181 210);
40+
--badge-blue: oklch(0.579 0.191 252);
41+
--badge-indigo: oklch(0.573 0.262 276.966);
42+
--badge-purple: oklch(0.495 0.172 295);
43+
--badge-pink: oklch(0.584 0.189 343);
3244
}
3345

3446
:root[data-theme='light'] {
@@ -49,9 +61,18 @@
4961
--accent-muted: var(--accent-color, oklch(0.205 0 0));
5062

5163
--syntax-fn: oklch(0.502 0.188 294.988);
52-
--syntax-str: oklch(0.54 0.191 257.481);
64+
--syntax-str: oklch(0.425 0.152 252);
5365
--syntax-kw: oklch(0.588 0.193 20.469);
5466
--syntax-comment: oklch(0.551 0.019 250.976);
67+
68+
--badge-blue: oklch(0.579 0.191 252);
69+
--badge-yellow: oklch(0.588 0.183 91);
70+
--badge-green: oklch(0.566 0.202 165);
71+
--badge-indigo: oklch(0.457 0.24 277.023);
72+
--badge-purple: oklch(0.495 0.172 295);
73+
--badge-orange: oklch(0.67 0.185 55);
74+
--badge-pink: oklch(0.584 0.189 343);
75+
--badge-cyan: oklch(0.571 0.181 210);
5576
}
5677

5778
html {

app/components/VersionSelector.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ watch(
480480
<span>{{ currentVersion }}</span>
481481
<span
482482
v-if="currentVersion === latestVersion"
483-
class="text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 font-sans font-medium"
483+
class="text-xs px-1.5 py-0.5 rounded badge-green font-sans font-medium"
484484
>
485485
latest
486486
</span>
@@ -567,12 +567,8 @@ watch(
567567
<span
568568
v-for="tag in group.primaryVersion.tags"
569569
:key="tag"
570-
class="text-[10px] px-1.5 py-0.5 rounded font-sans font-medium"
571-
:class="
572-
tag === 'latest'
573-
? 'bg-emerald-500/10 text-emerald-400'
574-
: 'bg-bg-muted text-fg-subtle'
575-
"
570+
class="text-xs px-1.5 py-0.5 rounded font-sans font-medium"
571+
:class="tag === 'latest' ? 'badge-green' : 'badge-subtle'"
576572
>
577573
{{ tag }}
578574
</span>

app/pages/docs/[...path].vue

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
120120
</span>
121121
</div>
122122
<div class="flex items-center gap-3 shrink-0">
123-
<span
124-
class="text-xs px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20"
125-
>
123+
<span class="text-xs px-2 py-1 rounded badge-green border border-badge-green/50">
126124
API Docs
127125
</span>
128126
</div>
@@ -242,7 +240,7 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
242240
}
243241

244242
.docs-content .docs-symbol:target .docs-symbol-header {
245-
@apply bg-amber-500/10 -mx-3 px-3 py-1 rounded-md;
243+
@apply bg-badge-yellow/10 -mx-3 px-3 py-1 rounded-md;
246244
}
247245

248246
/* Symbol header (name + badges) */
@@ -264,28 +262,28 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
264262
}
265263

266264
.docs-content .docs-badge--function {
267-
@apply bg-blue-500/15 text-blue-400;
265+
@apply badge-blue;
268266
}
269267
.docs-content .docs-badge--class {
270-
@apply bg-amber-500/15 text-amber-400;
268+
@apply badge-yellow;
271269
}
272270
.docs-content .docs-badge--interface {
273-
@apply bg-emerald-500/15 text-emerald-400;
271+
@apply badge-green;
274272
}
275273
.docs-content .docs-badge--typeAlias {
276-
@apply bg-violet-500/15 text-violet-400;
274+
@apply badge-indigo;
277275
}
278276
.docs-content .docs-badge--variable {
279-
@apply bg-orange-500/15 text-orange-400;
277+
@apply badge-orange;
280278
}
281279
.docs-content .docs-badge--enum {
282-
@apply bg-pink-500/15 text-pink-400;
280+
@apply badge-pink;
283281
}
284282
.docs-content .docs-badge--namespace {
285-
@apply bg-cyan-500/15 text-cyan-400;
283+
@apply badge-cyan;
286284
}
287285
.docs-content .docs-badge--async {
288-
@apply bg-purple-500/15 text-purple-400;
286+
@apply badge-purple;
289287
}
290288

291289
/* Signature code block - now uses Shiki */
@@ -346,15 +344,15 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
346344

347345
/* Deprecation warning */
348346
.docs-content .docs-deprecated {
349-
@apply bg-amber-500/10 border border-amber-500/20 rounded-lg p-4 mb-5;
347+
@apply bg-badge-orange/20 border border-badge-orange rounded-lg p-4 mb-5;
350348
}
351349

352350
.docs-content .docs-deprecated strong {
353-
@apply text-amber-400 text-sm;
351+
@apply text-badge-orange text-sm;
354352
}
355353

356354
.docs-content .docs-deprecated p {
357-
@apply text-amber-300/80 text-sm mt-2 mb-0;
355+
@apply text-badge-orange text-sm mt-2 mb-0;
358356
}
359357

360358
/* Parameters, Returns, Examples, See Also sections */
@@ -407,12 +405,12 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
407405
}
408406

409407
.docs-content .docs-link {
410-
@apply text-blue-400 hover:text-blue-300 underline underline-offset-2;
408+
@apply text-badge-blue hover:text-badge-blue/80 underline underline-offset-2;
411409
}
412410

413411
/* Symbol cross-reference links */
414412
.docs-content .docs-symbol-link {
415-
@apply text-emerald-400 hover:text-emerald-300 underline underline-offset-2;
413+
@apply text-badge-green hover:text-badge-green/80 underline underline-offset-2;
416414
}
417415

418416
/* Unknown symbol references shown as code */

test/nuxt/components/VersionSelector.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ describe('VersionSelector', () => {
509509
// Find the latest tag span
510510
const latestTags = component.findAll('span').filter(s => s.text() === 'latest')
511511
expect(latestTags.length).toBeGreaterThan(0)
512-
// Should have emerald styling
513-
const hasEmeraldStyling = latestTags.some(t => t.classes().some(c => c.includes('emerald')))
514-
expect(hasEmeraldStyling).toBe(true)
512+
// Should have green styling
513+
const hasGreenStyling = latestTags.some(t => t.classes().some(c => c.includes('green')))
514+
expect(hasGreenStyling).toBe(true)
515515
})
516516
})
517517

uno.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ export default defineConfig({
5959
kw: 'var(--syntax-kw)',
6060
comment: 'var(--syntax-comment)',
6161
},
62+
badge: {
63+
orange: 'var(--badge-orange)',
64+
yellow: 'var(--badge-yellow)',
65+
green: 'var(--badge-green)',
66+
cyan: 'var(--badge-cyan)',
67+
blue: 'var(--badge-blue)',
68+
indigo: 'var(--badge-indigo)',
69+
purple: 'var(--badge-purple)',
70+
pink: 'var(--badge-pink)',
71+
},
6272
// Playground provider brand colors
6373
provider: {
6474
stackblitz: '#1389FD',
@@ -141,6 +151,15 @@ export default defineConfig({
141151
'tag',
142152
'inline-flex items-center px-2 py-0.5 text-xs font-mono text-fg-muted bg-bg-muted border border-border rounded transition-colors duration-200 hover:(text-fg border-border-hover)',
143153
],
154+
['badge-orange', 'bg-badge-orange/10 text-badge-orange'],
155+
['badge-yellow', 'bg-badge-yellow/10 text-badge-yellow'],
156+
['badge-green', 'bg-badge-green/10 text-badge-green'],
157+
['badge-cyan', 'bg-badge-cyan/10 text-badge-cyan'],
158+
['badge-blue', 'bg-badge-blue/10 text-badge-blue'],
159+
['badge-indigo', 'bg-badge-indigo/10 text-badge-indigo'],
160+
['badge-purple', 'bg-badge-purple/10 text-badge-purple'],
161+
['badge-pink', 'bg-badge-pink/10 text-badge-pink'],
162+
['badge-subtle', 'bg-bg-subtle text-fg-subtle'],
144163

145164
// Code blocks
146165
[

0 commit comments

Comments
 (0)