feat: add runtime theme tweaks
Draft
KI
2mo ago+3996+3996+0123456789012345678901234567890123456789-19-19-01234567890123456789
Status
Draft and stacked on #476. This restores the work from the original PR #241 so it can continue being developed independently before merging.
Scope
- Runtime theme tweak configuration and UI.
- Framework bundle and adapter integration.
- Related exports, styles, examples, and tests from the original change.
History
The original PR was reverted by #474 because it was not ready to ship. This branch reproduces the original PR tree exactly when combined with #476, without unrelated changes.
Merge order
Merge #476 first. Then retarget this PR to main, update it, and complete its review.
Summary by cubic
Adds an opt‑in runtime “Tweaks” dialog to docs so readers can adjust preset, accent, density, radius, and font, and authors can adjust all tokens and export a createTheme({...}) snippet. Selections persist in localStorage and reapply pre‑paint to avoid FOUC; nothing changes unless enabled.
- Opt in via
defineDocsastweaks: { reader: true, author: process.env.NODE_ENV !== 'production', position?: 'sidebar' | 'floating' | 'both' }. Defaults off. - Integrates in layout by mounting
TweaksControl/TweaksAutoPortalTriggerand injecting a pre‑paint script frombuildFoucScript(); addstweaks.cssto base styles. - Exposes types and components:
TweaksConfigin@farming-labs/docs;TweaksAutoPortalTrigger,TweaksControl, and triggers in@farming-labs/fumadocs; new subpath export@farming-labs/fumadocs/tweaks. - Main review focus:
packages/fumadocs/src/tweaks-runtime.ts(persistence, FOUC prevention) andpackages/fumadocs/src/tweaks-dialog.tsx(UI, token application). Examples enabletweaksfor local dev.