feat: add complete dark mode (ThemeContext, CSS variables, FOWT prevention, Header toggle)#5
Open
m-mohamed wants to merge 3 commits intoxizon:mainfrom
Open
Conversation
…ggle - Define CSS custom properties (--color-*) on :root and [data-theme='dark'] in globals.scss for all themed colors - Create ThemeContext.tsx following JWTAuthContext pattern: useReducer state, useLocalStorage persistence, prefers-color-scheme fallback, and document.documentElement.setAttribute effect - Register ThemeProvider in ProviderLayout.tsx wrapping AuthProvider - Add suppressHydrationWarning to <html> in layout.tsx; add beforeInteractive Script that reads localStorage and sets data-theme before React hydrates (FOWT prevention) - Replace hardcoded colors in Buttons, Modal, MultilevelDropdownMenu, and Pagination SCSS modules with var(--color-*) references - Add sun/moon toggle button in Header using useTheme hook
|
Someone is attempting to deploy a commit to the xizon's projects Team on Vercel. A member of the Team first needs to authorize it. |
- Replace hardcoded http://localhost:3000 URLs in localConfig with relative paths to fix CORS when accessed via 127.0.0.1 - Replace removed `next lint` command with direct eslint invocation - Add missing typecheck (tsc --noEmit) and test scripts to package.json Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… calls demoMenuActions.js is called server-side from app/page.tsx during SSR. The previous CORS fix changed localConfig.MENU to a relative URL (/api/navigation), but axios in Node.js cannot resolve relative URLs, causing Invalid URL errors and a 500 on the home page. Detect server-side context (typeof window === 'undefined') and prefix relative URLs with the absolute localhost base URL so axios can resolve them. Client-side browser calls continue using relative URLs (no CORS issue). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
|
There is a small issue that after refreshing the page, localStorage reverts to empty, causing the theme to become invalid. :) |
Owner
|
you could fix this, it may be caused by the initialized script I guess. thanks :) |
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
globals.scssinto--color-*CSS variables on:root; added[data-theme='dark']override block with dark-mode equivalentssrc/contexts/ThemeContext.tsxfollowing theJWTAuthContextpattern —useReducerstate,useLocalStoragepersistence,prefers-color-schemefallback,document.documentElement.setAttribute('data-theme', ...)inuseEffectThemeProvideradded toProviderLayout.tsxwrappingAuthProvidersuppressHydrationWarning={true}on<html>element;beforeInteractiveScript inlayout.tsxreadslocalStorageand setsdata-themebefore React hydratesButtons,Modal,MultilevelDropdownMenu, andPaginationwithvar(--color-*)referencessrc/components/Header/index.tsxusinguseThemehookTest plan
localStorage./node_modules/.bin/eslint src/contexts/ThemeContext.tsx src/components/Header/index.tsx app/layout.tsx app/ProviderLayout.tsx— passes with no errorsnpx tsc --noEmit— no new type errors (two pre-existing errors in@pages/index.tsxandapp/ClientPage.tsxare unrelated)npm run dev— server starts cleanly on port 3000🤖 Generated with Claude Code