Live data from Hacker News

Edison Bulb Night Mode

petemillspaugh.com

31–34 of 34 posts

Re: Edison Bulb Night Mode

#31

Two improvements that could be made: 1. My dark mode preferences change throughout the day. Caching the value in localStorage means that it will require manual updates twice a day. Add a behavior that automatically unsets the localStorage key whenever it would set it to the currently system-preferred value. 2. Apply the override using a CSS class on the body element calculated from a synchronous JavaScript block to a…

Thanks, and yeah I was on the fence about #1 (I also like to auto-toggle at night sometimes). My hesitation is that some people might just like one theme better on my website and don't want it to keep resetting based on OS preference. Not sure which case is more common... #2 is a great idea. I made a todo for myself to do that at some point.

The nice thing about only storing the value when it's different from the current default and unsetting it otherwise is that anyone who prefers one theme never has to change it (because their system is already in that theme) or only has to change it one time and it will stay that way forever. But users who prefer the site to just Do The Right Thing can also have that behavior.

Re: Edison Bulb Night Mode

#32

Regarding the local storage Vs server side defaults I don't understand why you wouldn't use a web cookie to store the on/off state? Am I missing something

Setting a cookie is a good idea—I honestly just didn't think of it. I created a todo for myself to explore that whenever I can get around to it.

Re: Edison Bulb Night Mode

#33
post #2

This looks nice and all, but this doesn’t work on mobile devices due to pull to refresh.

Thanks for pointing this out. I updated it to allow drag/pull on mobile (prevent the pull-to-refresh with CSS `overscroll-behavior: none` on touch events).

Re: Edison Bulb Night Mode

#34

I love the landscape at the bottom of the page! It really gives a sense of the page being a place . I might have to steal that page bottom concept! I've never actually seen it before. The bulb is a really nice detail, and the color schemes are both really nice.

Thanks, and go for it! I'd be interested to see your remix if you end up getting to a landscape/place footer
Post reply on HN