feat(theme): add dark/light theme toggle, provider, API resilience an… #205
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.



feat(theme): add dark/light theme toggle, provider, API resilience and apply semantic theming
Related Tickets & Documents
Fixes: #3078
[dark-mode-toggle-issue]
Description
This PR adds a complete dark mode / light mode theme toggle to the Keploy blog website, improving accessibility, readability, and user personalization. The implementation uses Next.js 15 + Tailwind CSS with next-themes for seamless theme switching and persistence. Additionally, API resilience improvements ensure robust handling of WordPress GraphQL endpoint configuration, and new developer tooling helps contributors validate endpoints before running builds.
Changes
Core Theme Implementation
next-themesThemeProvider inpages/_app.tsxusing class-based strategy (attribute="class") for Tailwind dark mode supportcomponents/ui/theme-toggle.tsx— an accessible, animated sliding switch with Sun/Moon icons matching Keploy brand (orange#FF914Dthumb in dark mode)components/header.tsxfor visibility in both desktop header controls and mobile navigationStyling & CSS Variables
components/header.tsxto usebg-backgroundandbg-cardtokens instead of hard-codedbg-white.darkoverrides instyles/index.cssthat map common hard-coded Tailwind utilities (bg-white,text-black,border-gray-*) to CSS variables for backward compatibilitytailwind.config.jswhich already haddarkMode: ['class']enabled and:root/.darkCSS variables definedTheme Persistence
defaultTheme="system")Developer Experience & API Resilience
lib/api.tsto validate response content-type, auto-retry with/graphqlappended if URL returns HTML, and log helpful snippets on failuresscripts/verify-wp-endpoint.js— CLI tool to test WPGraphQL endpoints with auto-fallback to/graphqlnpm run verify-endpointto help contributors validateWORDPRESS_API_URLbefore dev/buildREADME.mdwith endpoint verification instructionsFiles Changed
pages/_app.tsx— ThemeProvider wrappercomponents/ui/theme-toggle.tsx(new) — Animated toggle componentcomponents/header.tsx— Toggle injection in desktop & mobile headerlib/api.ts— Response validation and/graphqlauto-retryscripts/verify-wp-endpoint.js(new) — Endpoint validator CLIpackage.json— Addednext-themes+verify-endpointscriptstyles/index.css—.darkCSS overridesREADME.md— Endpoint verification documentationPR_DESCRIPTION.md(new) — Comprehensive PR notesType of Change
Testing
Manual Testing