Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back dark mode support with simpler logic #107

Merged
merged 13 commits into from
Mar 3, 2025
Merged

Bring back dark mode support with simpler logic #107

merged 13 commits into from
Mar 3, 2025

Conversation

dkhalife
Copy link
Owner

@dkhalife dkhalife commented Mar 3, 2025

  • merge storage context into themecontext
  • TokenManager -> api util
  • reduce themecontext
  • lowercase util files
  • dead code
  • remove Contexts
  • remove theme from app
  • JoyUI to save in custom storage key
  • remove custom ThemeContext
  • remove custom ThemeMode
  • simplify theme toggles
  • apply theme

@Copilot Copilot bot review requested due to automatic review settings March 3, 2025 06:48
@dkhalife dkhalife changed the title darkmode Bring back dark mode support with simpler logic Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors and simplifies theming by merging storage context into theme context, streamlining theme toggles, and removing unused context code.

  • Consolidates theme management and storage logic in src/constants/theme.ts
  • Simplifies toggle button components by removing the ThemeContext dependency and relying on direct state and util function updates
  • Removes obsolete context and custom theme types and utilizes JoyUI’s CssVarsProvider for theming

Reviewed Changes

File Description
src/constants/theme.ts Centralizes theme logic and introduces helper functions for mode handling
src/views/Settings/ThemeToggleButton.tsx Updates toggle behavior to work purely on component state
src/App.tsx Removes unused theme code and integrates CssVarsProvider
src/views/Settings/ThemeToggle.tsx Refactors theme toggle control to remove context dependency
src/utils/dom.ts Adds applyTheme utility to update the document’s theme data attribute
src/views/Settings/Settings.tsx Removes ThemeContext usage and simplifies settings view
src/views/Navigation/NavBar.tsx Strips out ThemeContext consumer and adjusts theme toggle placement
src/contexts/ThemeContext.tsx Eliminates obsolete theming context

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/constants/theme.ts:15

  • The function getNextThemeMode does not handle the 'system' theme mode, which could lead to undefined behavior when the current mode is 'system'. Consider adding an explicit case or a default branch to handle this scenario.
export const getNextThemeMode = (currentThemeMode: Mode): Mode => {
@dkhalife dkhalife enabled auto-merge (squash) March 3, 2025 06:49
@dkhalife dkhalife merged commit 7269b3c into main Mar 3, 2025
5 checks passed
@dkhalife dkhalife deleted the darkmode branch March 3, 2025 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant