Skip to content

Commit 47f5a6b

Browse files
committed
fix(web): docs sidebar and code highlighting improvements
- Make doc sidebar section titles non-selectable and non-interactive - Fix ESM compatibility in tailwind config (require -> import) - Fix React 19 key prop warning in code-demo component - Add visually hidden SheetTitle for accessibility compliance
1 parent 8dd0ff2 commit 47f5a6b

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

web/src/app/docs/layout.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import { useState, useEffect, useRef } from 'react'
66

77
import { DocSidebar, sections } from '@/components/docs/doc-sidebar'
88
import { Button } from '@/components/ui/button'
9-
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'
9+
import {
10+
Sheet,
11+
SheetContent,
12+
SheetTitle,
13+
SheetTrigger,
14+
} from '@/components/ui/sheet'
15+
import { VisuallyHidden } from '@radix-ui/react-visually-hidden'
1016

1117
export default function DocsLayout({
1218
children,
@@ -96,6 +102,9 @@ export default function DocsLayout({
96102
side="bottom"
97103
className="h-[80vh] p-6 pt-12 overflow-y-auto"
98104
>
105+
<VisuallyHidden>
106+
<SheetTitle>Documentation Navigation</SheetTitle>
107+
</VisuallyHidden>
99108
<DocSidebar onNavigate={() => setOpen(false)} />
100109
</SheetContent>
101110
<SheetTrigger asChild>

web/src/components/docs/doc-sidebar.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ export function DocSidebar({
119119
<div key={group.label} className="space-y-3">
120120
{/* Group header */}
121121
<div
122-
className={cn(
123-
'px-3 flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground/70',
124-
groupIndex > 0 && 'pt-2 border-t border-border/50',
125-
)}
122+
className="px-3 flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground/70 select-none pointer-events-none"
126123
>
127124
<group.icon className="h-3.5 w-3.5" />
128125
{group.label}
@@ -132,22 +129,11 @@ export function DocSidebar({
132129
<div className="space-y-4">
133130
{group.sections.map((section) => (
134131
<div key={section.href} className="space-y-1">
135-
<Link
136-
href={section.href}
137-
target={section.external ? '_blank' : undefined}
138-
onClick={() => {
139-
const sheet = document.querySelector('[data-state="open"]')
140-
if (sheet) sheet.setAttribute('data-state', 'closed')
141-
onNavigate?.()
142-
}}
143-
className={cn(
144-
'block px-3 py-2 hover:bg-accent rounded-md transition-all text-sm font-medium',
145-
pathname === section.href &&
146-
'bg-accent text-accent-foreground',
147-
)}
132+
<div
133+
className="block px-3 py-2 text-sm font-medium select-none"
148134
>
149135
{section.title}
150-
</Link>
136+
</div>
151137
{section.subsections && section.subsections.length > 0 && (
152138
<div className="ml-4 space-y-1">
153139
{section.subsections.map((subsection) => (

web/src/components/docs/mdx/code-demo.tsx

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,31 @@ export function CodeDemo({ children, language, rawContent }: CodeDemoProps) {
236236
color: tokenColor || style.color,
237237
}}
238238
>
239-
{tokens.map((line, i) => (
240-
<div key={i} {...getLineProps({ line })}>
241-
{line.map((token, key) => {
242-
const tokenProps = getTokenProps({ token, key })
243-
// Override colors for special languages in render loop
244-
const color = tokenColor || tokenProps.style?.color
239+
{tokens.map((line, i) => {
240+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
241+
const { key: _lineKey, ...lineProps } = getLineProps({ line })
242+
return (
243+
<div key={i} {...lineProps}>
244+
{line.map((token, tokenIndex) => {
245+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
246+
const { key: _tokenKey, ...tokenProps } = getTokenProps({ token, key: tokenIndex })
247+
// Override colors for special languages in render loop
248+
const color = tokenColor || tokenProps.style?.color
245249

246-
return (
247-
<span
248-
key={key}
249-
{...tokenProps}
250-
style={{
251-
...tokenProps.style,
252-
color,
253-
}}
254-
/>
255-
)
256-
})}
257-
</div>
258-
))}
250+
return (
251+
<span
252+
key={tokenIndex}
253+
{...tokenProps}
254+
style={{
255+
...tokenProps.style,
256+
color,
257+
}}
258+
/>
259+
)
260+
})}
261+
</div>
262+
)
263+
})}
259264
</pre>
260265
)
261266
}}

web/tailwind.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { Config } from 'tailwindcss'
2+
import tailwindcssAnimate from 'tailwindcss-animate'
3+
import typography from '@tailwindcss/typography'
24

35
const config = {
46
darkMode: ['class'],
@@ -183,7 +185,7 @@ const config = {
183185
},
184186
},
185187
},
186-
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')],
188+
plugins: [tailwindcssAnimate, typography],
187189
} satisfies Config
188190

189191
export default config

0 commit comments

Comments
 (0)