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

add dark mode with toggle and system preference #201

Closed
wants to merge 98 commits into from

Conversation

bzlibby
Copy link
Contributor

@bzlibby bzlibby commented Feb 23, 2023

I wanted to be able to apply dark mode. this automatically applies dark mode based on the user's system preference, and adds a toggle to switch between light and dark on the settings tab.

this is still in progress, but I'd appreciate any early feedback. what I plan to do still:

  • fix CssBaseline import in OnnxWeb.tsx to match other imports
  • move logic for checking the user's system preference and the current theme out of OnnxWeb.tsx and into utils.ts
  • add a label to light/dark mode toggle
  • improve logic for light/dark mode toggle based on system preference

what I'd like to do at some point, but may do as a separate PR:

  • add custom theming/colors

@ssube
Copy link
Owner

ssube commented Feb 25, 2023

Nice, this looks pretty good.

I see two minor issues, one of which you've already noted:

  • mode: state.theme as PaletteMode doesn't check to make sure that state.theme is really valid, and mui will throw an error and not load the app if that is not a valid theme name
  • if the user has not picked a theme yet, the toggle will not reflect their system settings and will always start with the light theme: if (state.theme === 'light') ...

For the import, I think you can import directly from the mui package, import { CssBaseline } from '@mui/material';.

@ssube
Copy link
Owner

ssube commented Mar 3, 2023

Hi, you will probably need to rebase this in the aftermath of #208 (i18n)

bzlibby and others added 26 commits March 9, 2023 09:20
@sonarcloud
Copy link

sonarcloud bot commented Apr 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.5% 0.5% Duplication

@bzlibby bzlibby closed this Apr 15, 2023
@bzlibby bzlibby deleted the dark-mode branch April 15, 2023 18:29
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.

None yet

2 participants