thaw icon indicating copy to clipboard operation
thaw copied to clipboard

Theme flashing issue.

Open glennpierce opened this issue 9 months ago • 2 comments

Hi

I am having a little issue with an ssr app and the dark / light mode.

Probably me doing something stupid.

I am not sure how to prevent the theme from defaulting to light when the ssr app sends the first hydrated page.

From what I read the Leptos author suggests setting

https://www.youtube.com/watch?v=AD3FHodVgE8&t=2040s https://github.com/leptos-rs/example-darkmode/blob/main/src/dark_mode.rs

I have setup my project to send / get a cookie and on new refresh and I can instantly get the theme set correctly but even though I set theme.set() with the cookie value at that time I have to wait until the page is dehydrated until I see the them change.

Thaw is enabled with ssr

Thanks

glennpierce avatar May 01 '24 11:05 glennpierce

You can introduce the following CSS files to temporarily solve this problem.

body {
    background-color: rgb(26, 29, 30);
    color: rgb(236, 237, 238);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
        "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 14px;
    color-scheme: dark;
    margin: 0px;
}

I will fix this completely in version 0.4.

luoxiaozero avatar May 02 '24 16:05 luoxiaozero

Thanks. Its probably the same reason icons and the grid are different between ssr/csr If it helps when you implement it I can try to do a demo or grab the css before and after if I can.

glennpierce avatar May 03 '24 15:05 glennpierce

I have implemented this feature in the v0.4-beta version.

luoxiaozero avatar Aug 25 '24 05:08 luoxiaozero