feat: implement AdminThemeToggle component with tests and integrate into admin pages#612
Merged
Conversation
|
@Dubemtopsite Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
This Pull Request addresses the lack of uniform Dark Mode support in the Admin Panel. It establishes standard client-side theme context across the entire repository (both standard Pages Router routes and modern App Router routes), solves Next.js hydration safety constraints, and provides a polished, high-fidelity dark visual aesthetic for all administrative control interfaces.
Key Features & Changes
1. Unified Theme Context
src/pages/_app.tsx: Wrapped the Pages Router root tree withThemeProviderso context hooks operate successfully across standard pages (useTheme,useThemeContext).2. Hydration-Safe Controls
src/components/admin/AdminThemeToggle.tsx: Added client-side mounting protection (useState+useEffect) to dynamically render the active theme button after page hydration. This ensures identical initial server rendering and avoids layout shifting or hydration mismatches.3. Styled Administrative Pages (Pages Router)
src/pages/admin/audit.tsx: Fully restyled for dark mode with curated slate tones, custom action badges, and integrated theAdminThemeTogglenext to responsive header controls.src/pages/admin/monitoring.tsx: Reconstructed with dark compatibility. Metric details are presented alongside beautiful dynamic status progress bars that shift color (emerald, amber, red) based on real-time server health.4. App Router Feature-Flags Integration
src/app/pages/admin/feature-flags/page.tsx: Added the theme toggle button group directly into the sticky header next to the audit log button.5. Automated Testing
src/components/admin/__tests__/AdminThemeToggle.test.tsx: Implemented a targeted unit test suite that asserts:document.documentElementupon user interactions.Verification Outcomes
Targeted Unit Tests
Ran the Vitest runner targeting theme context interfaces:
pnpm run test src/components/admin/__tests__/AdminThemeToggle.test.tsx src/components/ui/__tests__/theme-toggle.test.tsxResults:
Code Quality Gates
Issue References
Closes #510