generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
379 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
packages/docs/src/app/(pages)/playground/_components/playground-page-layout.tsx
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
packages/docs/src/app/(pages)/playground/basic-counter/page.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/docs/src/app/playground/(demos)/_components/query-spy.skeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
export function QuerySpySkeleton({ | ||
children, | ||
className, | ||
...props | ||
}: React.ComponentProps<'pre'>) { | ||
return ( | ||
<pre | ||
aria-label="Querystring spy" | ||
aria-description="For browsers where the query is hard to see (eg: on mobile)" | ||
className={twMerge( | ||
'mt-4 block w-full overflow-x-auto rounded-lg border bg-background px-3 py-2 text-xs dark:bg-zinc-900 dark:shadow-inner sm:text-sm', | ||
className | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</pre> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/docs/src/app/playground/(demos)/_components/source-on-github.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { CodeBlock } from '@/src/components/code-block' | ||
import { FileCode2 } from 'lucide-react' | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'url' | ||
|
||
type SourceOnGitHubProps = { | ||
path: string | ||
} | ||
|
||
export async function SourceOnGitHub({ path }: SourceOnGitHubProps) { | ||
const source = await readSourceCode(path) | ||
return ( | ||
<footer className="mt-2 space-y-2 border-t py-4"> | ||
<div className="flex items-baseline"> | ||
<span className="flex items-center gap-1 text-zinc-500"> | ||
<FileCode2 size={16} /> | ||
{path.split('/').slice(1).join('/')} | ||
</span> | ||
<a | ||
href={`https://github.com/47ng/nuqs/tree/next/packages/docs/src/app/playground/(demos)/${path}`} | ||
className="ml-auto text-sm" | ||
> | ||
Source on GitHub | ||
</a> | ||
</div> | ||
<div className="not-prose overflow-hidden"> | ||
<CodeBlock code={source} /> | ||
</div> | ||
</footer> | ||
) | ||
} | ||
|
||
function readSourceCode(demoPath: string) { | ||
const demosDir = path.resolve(fileURLToPath(import.meta.url), '../../') | ||
const demoFilePath = path.resolve(demosDir, demoPath) | ||
return fs.readFile(demoFilePath, 'utf8') | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/docs/src/app/playground/(demos)/basic-counter/client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client' | ||
|
||
import { Button } from '@/src/components/ui/button' | ||
import { Minus, Plus } from 'lucide-react' | ||
import { parseAsInteger, useQueryState } from 'nuqs' | ||
|
||
export default function BasicCounterDemoPage() { | ||
const [counter, setCounter] = useQueryState( | ||
'counter', | ||
parseAsInteger.withDefault(0) | ||
) | ||
return ( | ||
<> | ||
<nav className="my-8 flex flex-wrap gap-4"> | ||
<Button size="sm" onClick={() => setCounter(x => x - 1)}> | ||
<Minus /> | ||
</Button> | ||
<Button size="sm" onClick={() => setCounter(x => x + 1)}> | ||
<Plus /> | ||
</Button> | ||
<Button size="sm" onClick={() => setCounter(null)}> | ||
Reset | ||
</Button> | ||
<span className="text-2xl font-semibold tabular-nums"> | ||
Counter: {counter} | ||
</span> | ||
</nav> | ||
</> | ||
) | ||
} |
Oops, something went wrong.