Skip to content

Commit 680cf5c

Browse files
doc: add break word all for better ux (#753)
* doc: add break word all for better ux * doc: Remove styles from API docs * style: Keep inline in sm+ and scroll/ellipsis on overflow --------- Co-authored-by: François Best <github@francoisbest.com>
1 parent 2ee7dc5 commit 680cf5c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

demo-tabs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function Demo() {
2424
onChange={e => setHello(e.target.value || null)}
2525
data-interacted={Boolean(hello)}
2626
/>
27-
<p>Hello, {hello || 'anonymous visitor'}!</p>
27+
<p className="break-all">Hello, {hello || 'anonymous visitor'}!</p>
2828
</>
2929
)
3030
}

packages/docs/src/app/(pages)/_landing/demo.client.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export function Demo() {
2525
onChange={e => setHello(e.target.value || null)}
2626
data-interacted={Boolean(hello)}
2727
/>
28-
<p>Hello, {hello || 'anonymous visitor'}!</p>
28+
<p className="sm:overflow-x-auto sm:text-ellipsis sm:text-nowrap">
29+
Hello, {hello || 'anonymous visitor'}!
30+
</p>
2931
</>
3032
)
3133
}

packages/docs/src/app/(pages)/_landing/demo.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import { CodeBlock } from '@/src/components/code-block'
22
import fs from 'node:fs/promises'
3+
import { format } from 'prettier'
34
import { Suspense } from 'react'
45
import { Demo } from './demo.client'
56

67
export async function LandingDemo() {
78
const demoFilePath =
89
process.cwd() + '/src/app/(pages)/_landing/demo.client.tsx'
910
const demoFile = await fs.readFile(demoFilePath, 'utf8')
11+
// Poor man's AST manipulation
1012
const demoCode = demoFile
13+
.replace(/className=".+"/g, '') // Strip styling
1114
.split('\n')
12-
.filter(
13-
line =>
14-
!line.includes('className="') && !line.includes('data-interacted=')
15-
)
15+
.filter(line => !line.includes('data-interacted='))
1616
.join('\n')
17+
const formattedCode = await format(demoCode, {
18+
parser: 'typescript'
19+
})
1720
return (
1821
<>
1922
<Suspense
@@ -26,7 +29,7 @@ export async function LandingDemo() {
2629
<LookAtTheURL />
2730
</div>
2831
</Suspense>
29-
<CodeBlock code={demoCode} />
32+
<CodeBlock code={formattedCode} />
3033
</>
3134
)
3235
}

0 commit comments

Comments
 (0)