Skip to content

Commit f74b869

Browse files
committedJan 30, 2025
style: Keep inline in sm+ and scroll/ellipsis on overflow
1 parent 97f03ea commit f74b869

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed
 

Diff for: ‎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 className="break-all">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
}

Diff for: ‎packages/docs/src/app/(pages)/_landing/demo.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
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
2023
fallback={
2124
<div className="mb-4 h-[136px] animate-pulse rounded bg-zinc-50 dark:bg-zinc-900 sm:h-10" />
2225
}
2326
>
24-
<div className="mb-4 flex flex-col gap-4 items-start sm:flex-row">
27+
<div className="mb-4 flex flex-col gap-4 sm:flex-row sm:items-center">
2528
<Demo />
2629
<LookAtTheURL />
2730
</div>
2831
</Suspense>
29-
<CodeBlock code={demoCode} />
32+
<CodeBlock code={formattedCode} />
3033
</>
3134
)
3235
}

0 commit comments

Comments
 (0)