feat(docs): synchronize site and demo color modes - #1393
dajiaohuang wants to merge 2 commits into
Conversation
✅ Deploy Preview for react-data-table-component ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thanks @dajiaohuang It's been a busy week but I will have a look this weekend |
|
This is great @dajiaohuang! However, I think it still needs some polishing. http://localhost:4399/docs/conditional-styles http://localhost:4399/docs/selection Also there is a strange flashing of tables when a page is loaded in dark mode There are also several other demo controls that might not be inheriting the theme. |
|
Follow-up pushed in a010b82.
Validation: npm test (719 tests), npm run typecheck, npm run build, npm run docs:build, and targeted Prettier checks pass. The docs build reports the existing Pagefind note that /docs/ has no outer html element. Remote CI/deploy checks will run against a010b82. |
Summary
Fixes #1381. Adds a Light / Dark / System selector to the documentation header, initializes the page theme before first paint, and synchronizes the site, code blocks, and demos through the existing
localStorage.themecontract. System mode follows OS changes; explicit preferences persist across navigation and synchronize between tabs.The browser check also exposed a hydration bug in
useColorMode: a dark client could retain the server's light inline styles because its initial state was already dark. Initialize consistently with the server, then apply the detected preference in the effect. A regression test fails before this change and passes afterward. Demo wrappers default to system mode while preserving explicit demo overrides.Type of change
Checklist
npm test)npm run typecheck)How to test
npm run docs:build, then preview the built site./docs/themes/with a dark OS preference and no saved theme. The page and hydrated tables should both be dark.Validation: 719 tests passed; lint and typecheck passed; library build passed using Git Bash for the existing POSIX build command on Windows; documentation build produced 55 pages. Browser acceptance covered 14 checks including first hydration, persistence, OS changes, cross-tab synchronization, homepage/recipe/headless demos, and mobile controls, with no JavaScript runtime errors.
The mobile check covers the new control and theme behavior. Wide table/reference content is not claimed to be overflow-free.