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

Theme Detection (Dark Mode) #246

Merged
merged 6 commits into from
Oct 12, 2023
Merged

Theme Detection (Dark Mode) #246

merged 6 commits into from
Oct 12, 2023

Conversation

tlmii
Copy link
Member

@tlmii tlmii commented Oct 11, 2023

Resolves #216

The TL;DR here is "dashboard will use dark mode if the system is set to dark mode, and will use light mode otherwise".

The implementation is a little more complicated. To avoid a flash of bright white when setting dark mode at runtime, we track the last system setting in a cookie and use that cookie to render the initial state. You'll still get a flash of bright white the first time you load the site at a particular URL, but every time after that (including after stopping the debugger, exiting the app, etc) you won't. We also use a basic inline CSS style to set the initial background color to a dark color to avoid the same thing.

I tweaked some of the colors in the /Traces and /Trace pages to work better with dark mode. I didn't try to be exhaustive, just make sure there wasn't any dark-on-dark or light-on-light colors happening. I also made a small adjustment to the menu background.

Screenshots to follow.

@tlmii
Copy link
Member Author

tlmii commented Oct 11, 2023

Cropped too much, but you can see the menu background is a solid color. It also extends to the bottom of the page now:
DarkModeMenuChanges

Traces:
DarkModeTraces

Trace:
DarkModeTraceDetail

@JamesNK
Copy link
Member

JamesNK commented Oct 11, 2023

Traces looks 100% better than I thought it would. Not great, but not a train wreak 😄

@@ -11,6 +11,7 @@
<link rel="stylesheet" href="_content/Aspire.Dashboard/css/app.css" />
<link rel="stylesheet" href="_content/Aspire.Dashboard/Aspire.Dashboard.bundle.scp.css" />
<HeadOutlet @rendermode="@RenderMode.InteractiveServer" />
<style>@@media (prefers-color-scheme: dark) { body { background-color: #333333; } }</style>
Copy link
Member

Choose a reason for hiding this comment

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

Is this to avoid flash of white on page load? Add a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right. The custom properties (e.g. --neutral-fill-rest) aren't available at this point so I just took the raw color. Makes sure the page loads dark.

@tlmii
Copy link
Member Author

tlmii commented Oct 12, 2023

Traces looks 100% better than I thought it would. Not great, but not a train wreak 😄

Yeah most of the accent colors worked OK. There were just a few places where the background or foreground was hardcoded to white/gray/black that needed to be tweaked.

Some things definitely won't pass accessibility testing at the moment but I'll file bugs on those later this week.

@tlmii tlmii enabled auto-merge (squash) October 12, 2023 04:54
@tlmii tlmii disabled auto-merge October 12, 2023 05:01
tlmii and others added 4 commits October 11, 2023 22:44
Don't use FluentDesignSytemProvider and move injects to .cs file
Use standard luminosity values and use BaseLayerLuminance design token
Undo some unnecessary renaming
@tlmii tlmii enabled auto-merge (squash) October 12, 2023 08:20
@tlmii tlmii merged commit 3e24e55 into dotnet:main Oct 12, 2023
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dashboard needs to support Dark mode
5 participants