Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add break word all for better ux #753

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function Demo() {
onChange={e => setHello(e.target.value || null)}
data-interacted={Boolean(hello)}
/>
<p>Hello, {hello || 'anonymous visitor'}!</p>
<p className="break-all">Hello, {hello || 'anonymous visitor'}!</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: this file isn't used in the codebase, it was just a demo of how GitHub uses search params to store state, we should probably remove it.

Suggested change
<p className="break-all">Hello, {hello || 'anonymous visitor'}!</p>
<p>Hello, {hello || 'anonymous visitor'}!</p>

</>
)
}
4 changes: 3 additions & 1 deletion packages/docs/src/app/(pages)/_landing/demo.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function Demo() {
onChange={e => setHello(e.target.value || null)}
data-interacted={Boolean(hello)}
/>
<p>Hello, {hello || 'anonymous visitor'}!</p>
<p className="sm:overflow-x-auto sm:text-ellipsis sm:text-nowrap">
Hello, {hello || 'anonymous visitor'}!
</p>
</>
)
}
13 changes: 8 additions & 5 deletions packages/docs/src/app/(pages)/_landing/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { CodeBlock } from '@/src/components/code-block'
import fs from 'node:fs/promises'
import { format } from 'prettier'
import { Suspense } from 'react'
import { Demo } from './demo.client'

export async function LandingDemo() {
const demoFilePath =
process.cwd() + '/src/app/(pages)/_landing/demo.client.tsx'
const demoFile = await fs.readFile(demoFilePath, 'utf8')
// Poor man's AST manipulation
const demoCode = demoFile
.replace(/className=".+"/g, '') // Strip styling
.split('\n')
.filter(
line =>
!line.includes('className="') && !line.includes('data-interacted=')
)
.filter(line => !line.includes('data-interacted='))
.join('\n')
const formattedCode = await format(demoCode, {
parser: 'typescript'
})
return (
<>
<Suspense
Expand All @@ -26,7 +29,7 @@ export async function LandingDemo() {
<LookAtTheURL />
</div>
</Suspense>
<CodeBlock code={demoCode} />
<CodeBlock code={formattedCode} />
</>
)
}
Expand Down
Loading