akzhy / gatsby-starter-elemental

Gatsby starter for portfolio sites
https://elemental.netlify.app
MIT License
137 stars 57 forks source link

Dark mode flicker in Production #19

Closed marcphilippebeaujean-abertay closed 4 years ago

marcphilippebeaujean-abertay commented 4 years ago

First off, thanks for this great theme! I think I will contribute in due time. My only problem is that the light mode flickers when I first load the page in production, but dark mode is enabled by default. Any ways around this or am I just doing something wrong?

ahmad-reza619 commented 4 years ago

Hello @marcphilippebeaujean-abertay thanks for reporting issue.

I think because the default background in most browser is white, and that is why it flickers. it takes time for react to apply the styles. what do you think @akzhy

Edit: Sorry after further research yes, it's normally wouldn't flicker on first load. we use less and webpack loaders for less, so it could be the styles were loaded asynchronously by webpack on prod.

This is some lead that i've found regarding this issue.

marcphilippebeaujean-abertay commented 4 years ago

Thanks for getting back to me. Does this mean I'm the only one experiencing this issue? Or is this also in the repository?

ahmad-reza619 commented 4 years ago

I will try to reproduce the issue, but sadly I'm busy at the moment. I'll get back to you when I'm done.

akzhy commented 4 years ago

Hey @marcphilippebeaujean-abertay , sorry for the delay in response. This is because of an issue in adding class to the body. I will try to create a workaround to fix it.

marcphilippebeaujean-abertay commented 4 years ago

No worries. I also made some other fixes and added a cookie banner, can I push these to the repository?

akzhy commented 4 years ago

Hey @marcphilippebeaujean-abertay sorry for the really long delay in responding. Pull requests are welcomed and appreciated, checkout #22 , the latest version. contributions to it are welcomed.

baart1989 commented 4 years ago

There is a way to fix it with custom html.js.

As explained in following blog post

akzhy commented 4 years ago

Fixed in the latest version