Add Snap docs site#11
Merged
Merged
Conversation
Integrates a full docs site into the emulator Next.js app. Docs and emulator share a single deployment with a unified left sidebar. Docs pages (10): - Introduction, Elements, Buttons, Colors (with swatches), Theme, Effects, Constraints, Authentication (full JFS spec), Examples, Building a Snap (with Claude Code skill install instructions) Features: - Farcaster logo in sidebar header - Collapsible sidebar (Lucide panel icons) - Light/dark mode toggle (Moon/Sun icons, persisted to localStorage) - Full dark mode across docs AND emulator (CSS variables) - Anchor links on all headings (# on hover) - Code copy button on code blocks (Copy/Check icons) - /llms.txt route for LLM consumption - /skill route serves create-farcaster-snap skill for download - Signature verification hint on 401 errors - Emulator moved to /emulator, root redirects to /docs Adapted for farcasterxyz/snap repo: - @farcaster/snap, @farcaster/snap-hono scoped package names - application/vnd.farcaster.snap+json accept header - SKIP_JFS_VERIFICATION env var - agent-skills/create-farcaster-snap/SKILL.md path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates a full MDX-based documentation site into the existing @farcaster/snap-emulator Next.js app, shipping docs and emulator together with a shared navigation sidebar, theme system, and a couple of utility routes (/llms.txt, /skill).
Changes:
- Add MDX docs section under
/docs/*(10 pages) plus/llms.txtaggregation and/skilldownload route. - Introduce shared app shell (sidebar + theme toggling) and redirect
/→/docs; move emulator UI to/emulator. - Refactor emulator renderer styling to use CSS variables for light/dark theming.
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds MDX + remark-gfm + lucide dependencies and transitive packages. |
| apps/emulator/tsconfig.json | Includes **/*.mdx for typechecking MDX pages. |
| apps/emulator/src/components/ThemeProvider.tsx | New client theme context + localStorage persistence (docs-theme). |
| apps/emulator/src/components/SnapRenderer.tsx | Swap hardcoded colors for CSS vars for theming consistency. |
| apps/emulator/src/components/snapCatalogRenderer.tsx | Replace hardcoded colors/borders with CSS vars. |
| apps/emulator/src/components/Sidebar.tsx | New shared left sidebar + collapse + theme toggle button. |
| apps/emulator/src/components/FarcasterLogo.tsx | Adds inline SVG Farcaster logo for sidebar branding. |
| apps/emulator/src/components/CodeBlock.tsx | Adds code-block copy-to-clipboard UI for docs pages. |
| apps/emulator/src/app/skill/route.ts | New route to serve SKILL.md as a downloadable file. |
| apps/emulator/src/app/page.tsx | Root now redirects to /docs. |
| apps/emulator/src/app/llms.txt/route.ts | New route aggregating docs MDX content into plain text. |
| apps/emulator/src/app/layout.tsx | Wraps app in ThemeProvider + shared sidebar shell; updates metadata. |
| apps/emulator/src/app/globals.css | Adds CSS-variable theme system + docs/sidebar styling. |
| apps/emulator/src/app/emulator/page.tsx | Moves emulator UI to /emulator and updates colors to CSS vars. |
| apps/emulator/src/app/emulator/layout.tsx | Emulator layout wrapper to constrain overflow appropriately. |
| apps/emulator/src/app/docs/layout.tsx | Docs layout wrapper + llms.txt link. |
| apps/emulator/src/app/docs/page.mdx | Adds docs landing page (Introduction). |
| apps/emulator/src/app/docs/examples/page.mdx | Adds Examples docs page. |
| apps/emulator/src/app/docs/elements/page.mdx | Adds Elements spec docs page. |
| apps/emulator/src/app/docs/buttons/page.mdx | Adds Buttons spec docs page. |
| apps/emulator/src/app/docs/colors/page.mdx | Adds Color Palette docs page with JSX swatches. |
| apps/emulator/src/app/docs/theme/page.mdx | Adds Theme & Styling docs page. |
| apps/emulator/src/app/docs/effects/page.mdx | Adds Effects docs page. |
| apps/emulator/src/app/docs/constraints/page.mdx | Adds Constraints docs page. |
| apps/emulator/src/app/docs/building/page.mdx | Adds Building a Snap guide. |
| apps/emulator/src/app/docs/auth/page.mdx | Adds Authentication (JFS) docs page. |
| apps/emulator/package.json | Adds MDX + remark + lucide deps; uses --webpack for builds. |
| apps/emulator/next.config.ts | Enables MDX via @next/mdx and remark-gfm; adds page extensions. |
| apps/emulator/next-env.d.ts | Adjusts Next route types import path. |
| apps/emulator/mdx-components.tsx | Custom MDX components: heading anchors + CodeBlock wrapper. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The emulator now lives at farcaster.xyz which signs messages automatically, eliminating signature bypass issues for developers. - Sidebar emulator link is now external (opens new tab, ExternalLink icon) - Updated Building a Snap guide to link to hosted emulator - Removed signature bypass instructions from testing section The local /emulator route is kept for development but no longer linked from the docs navigation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The port agent accidentally downgraded version ranges in template/package.json, causing lockfile mismatch in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add aria-label to sidebar collapse/expand button - CodeBlock: add clipboard fallback (execCommand), error handling, and timeout cleanup on unmount - Fix llms.txt palette-stripping regex to match actual markup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers content negotiation (Accept header routing), with examples for: - Dynamic sites (Hono, Express middleware) - Static sites (Cloudflare Worker, Vercel Edge Middleware, separate URL) - POST handling and testing Added to sidebar, and included in /llms.txt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Elements page: added inline visual previews for text, divider, progress, list, grid, text_input, slider, button_group, toggle, bar_chart, and group elements - Added callout linking to live Element Showcase in emulator - Building page: skill download URL now points to GitHub raw URL (farcasterxyz/snap repo) with link to view source on GitHub Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…errors Elements page improvements: - Image element: real sample image from picsum.photos - Video element: play button placeholder preview - Divider element: realistic usage context (poll results separator) - First Page: complete valid SnapResponse example - Common Validation Errors section with 5 examples: no title/body, no interactive/media, too many elements, two media elements, hex accent instead of palette name Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Grid: multi-row with tappable empty cells, shows tap coordinates - Video: thumbnail image with play button overlay - Text input: actually typeable (native HTML input) - Button group: tappable with selection highlighting (client component) - Valid first page: visual SnapCard preview with interactive buttons - All 5 validation errors: SnapCard previews showing what the broken snap would look like, with red VALIDATION ERROR badge New client components: - InteractiveGrid: stateful grid with tappable cells - InteractiveButtonGroup: stateful option selector - SnapCard: styled card wrapper with valid/invalid states Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Interactive ConfettiDemo component shows the confetti effect in a snap card preview with a "Replay confetti" button. Animates 60 particles with varied colors, shapes, and fall patterns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Effects fire when any page is rendered, not just on initial load. A POST button tap returning a page with effects will trigger them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a docs site to the emulator Next.js app at
/docs. The emulator itself now lives at farcaster.xyz/~/developers/snaps and is linked externally from the sidebar.Routes:
/docs/*— documentation pages/llms.txt— all docs as plain text for LLM consumption/skill— serves thecreate-farcaster-snapClaude Code skill for download/redirects to/docs10 docs pages:
Features:
llms.txtlink in top-right of every docs pageTech:
@next/mdx+remark-gfm(uses--webpacksince Turbopack doesn't support remark plugins)lucide-reactfor icons (MIT)Test plan
/docs/*with proper typography and tables/llms.txtreturns aggregated docs as plain text/skilldownloads the SKILL.md file/redirects to/docs🤖 Generated with Claude Code
-claude