-
Notifications
You must be signed in to change notification settings - Fork 601
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
Dark/Light mode does not update neutral and foreground colors for Blazor projects using JavaScript #4231
Comments
Thanks @ameyasubhedar. I'm not 100% sure what the cause of this is but it appears there is an issue with the base layer luminance system. If you're blocked in the short term you can set the background color directly (instead of layer luminance) as show here: https://stackblitz.com/edit/js-zmgrjb |
@nicholasrice, thanks. I referenced the FAST website code to build the code for Blazor and JavaScript. The fast website has a custom component fast-frame that uses baseLayerLuminance to update the background. How does it work there ? Can you also check this source and let me know if I am missing something. |
Okay I tracked this down. For historical reasons, the color recipes themselves implement design-system memoization where return values are memoized by object reference. We're tracking an issue to change that here: #3833. What is happening in your example is the product of
The
Internally, the DesignSystemProvider circumvents this memoization and will force re-evaluation of the color recipe. I have a working example pulled from your code here: https://stackblitz.com/edit/js-zmgrjb - give that a shot and let me know if that solves the issue for you. |
@nicholasrice Thanks for the fix. Yes it does work now. One quick question is there any order dependency for the designSystemProvider force evaluate. For example I am first setting the layer luminance, then the accent color template followed with neutral color pallet and finally update the background color as show below. Hope this order is Ok ? But overall its working now, thanks for a quick fix.
|
Great! Sorry for the confusion, that is an area we're hoping to address soon. The order doesn't matter, it will all get reconciled by the provider :) |
Describe the bug; what happened?
See sample code in Github: https://github.com/ameyasubhedar/FastBlazorTheme
I have a Razor component library that bundles the styling and JavaScript for multiple Blazor WebAssembly and Blazor Server projects. I am trying to achieve same look and feel for all of the Blazor projects, so the razor component libraries contains the css and JS to initialize the fast design system provider and update baseLayerLuminance to achieve dark (0.23), light (1) and black (0) modes .
Razor component expose these as JSInterop scoped service, pretty standard for asp.net core balzor project.
In my App.razor pages I initialize the design system
Everything works nicely
I change the code manually with dark layer JsInterop.SetColorLayerLuminanceAsync(Web.Shared.Styling.LayerLuminance.Dark); below and restart the blazor project and that also works nicely.
But now if I change the dark theme at runtime and use toggleColorLayerLuminance JavaScript function defined above in the razor event handler the code updates the luminance layer and background color correctly but neutral and accent colors are not updated.
See the text foreground color, this is the issue. Same issues happens with fluent-card component, its background color is not updated.
What am I doing wrong in the JavaScript code ? Any help is appreciated.
The text was updated successfully, but these errors were encountered: