docs: simplify CSS modification state management#3014
Conversation
- Make color picker standalone instead of a tab - Set activeTab to 0 (Custom) when using picker - Simplify useEffect sync logic Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 nodePath:
📦 Download Diff Report: node Bundle Diff 📁 node_mdPath:
📦 Download Diff Report: node_md Bundle Diff 📁 webPath:
📦 Download Diff Report: web Bundle Diff Generated by Rsdoctor GitHub Action |
There was a problem hiding this comment.
Pull request overview
This PR refactors the CSS modification state management in the documentation site to use useSyncExternalStore for precise subscriptions, ensuring components only re-render when their specific CSS entry changes. The refactor introduces a new useCssEntry hook with a useState-like API and consolidates CSS state management into a centralized context provider.
Changes:
- Introduced
CssModificationContextwith store-based state management usinguseSyncExternalStorefor granular subscriptions - Renamed
CssLiveCodeEditorWithTabstoCssLiveCodeEditorWithSelect(dropdown-only UI) - Refactored
CssPickerEditorto make color picker standalone with debouncing to prevent lag - Added
CssStyleSynccomponent to sync CSS to DOM style elements - Removed Banner component from Layout
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/theme/index.tsx | Integrated CSS modification context provider and removed deprecated Banner component |
| website/docs/zh/ui/vars.mdx | Added required styleId prop to CSS live editors |
| website/docs/en/ui/vars.mdx | Added required styleId prop to CSS live editors |
| website/docs/zh/guide/use-mdx/container.mdx | Quoted frontmatter description field |
| website/docs/en/guide/use-mdx/container.mdx | Quoted frontmatter description field |
| website/docs/components/ShikiThemeSwitcher.tsx | Updated to use renamed component with new API |
| website/docs/components/CssStyleSync.tsx | New component that syncs CSS context state to DOM |
| website/docs/components/CssPickerEditor.tsx | Complete refactor with standalone color picker and debouncing |
| website/docs/components/CssModificationIndicator.tsx | New component displaying modification status with reset button |
| website/docs/components/CssModificationContext.tsx | New centralized state management using useSyncExternalStore |
| website/docs/components/CssLiveCodeEditorWithTabs.tsx | Removed (replaced by CssLiveCodeEditorWithSelect) |
| website/docs/components/CssLiveCodeEditorWithSelect.tsx | New dropdown-only CSS editor component |
| website/docs/components/CssLiveCodeEditor.tsx | Simplified to use useCssEntry hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix timerRef type to use `number | null` instead of `ReturnType<typeof setTimeout>` - Use functional update in useEffect to avoid stale closure issues Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
CssModificationContextto useuseSyncExternalStorefor precise subscriptionsstyleIdchangesuseCssEntryhook for simplified state management (similar touseStateAPI)CssLiveCodeEditorWithTabstoCssLiveCodeEditorWithSelect(dropdown only)CssLiveCodeEditorby using the newuseCssEntryhookCssPickerEditor:Test plan
🤖 Generated with Claude Code