7 ms·
Dark mode shouldn't be harder with SSR apps, you would just send back the dark mode CSS in the initial GET response. Complexity around this might be related to
by darepublic 7y ago
Dark mode shouldn't be harder with SSR apps, you would just send back the dark mode CSS in the initial GET response. Complexity around this might be related to trying to work with out of the box framework settings, but comparing this problem to some advanced image recognition, while admittedly a joke.. is just over-representing the problem imo. I'm sorry gatsby didn't give you an easy way to do this, but if you understand the principles of web applications this should not be an epic quest.
- saagarjha 7y agoThe problem is that the question of whether dark mode CSS should be applied is only known once JavaScript can be executed on the page.
- deleted 7y ago[deleted]
- darepublic 7y agoThat's the thing with SSR... (i.e. with Next) or with pre-rendering apps before hand. In the initial GET request to the page, you also send a cookie with user preference. Depending on their dark mode preference you can style the page to be in dark mode as part of the server or pre-rendered markup -- no JS required :o. Now.. how difficult that is to do with Gatsby I don't know. But the fact that someone shot themselves in the foot with Gatsby, then learned to hobble along on one foot isn't a cause for celebration imo.
- saagarjha 7y agoI don't see how you could do that with a static site.
- robertoandred 7y agoThis has nothing to do with Gatsby or SSR. It has to do with storing the user's preference locally and applying it before the page renders. Don't think you understand the principles here.
- darepublic 7y agoSo with server side rendered code you can render in dark mode and send that back in the html markup of the request -- no latency on seeing the style applied. You don't need to just store the user preference locally and apply it with js. You can even store the user preference on the server as part of their profile (:o) and then NEW browsers will get the dark or light mode styling. If I am very wrong let me know but I still think it is new web devs getting lost in a wilderness of frameworks and not realizing that the escape from the haunted forest is just to walk north for ten paces, because they lack a basic compass.
- robertoandred 7y agoDoubt users are going to want to create a profile for a random website just to save their color mode preference.