Featherweb Blog

Blog index


Saving document color in LocalStorage

Final part, promised!

In my last post I made a spring-cleaning list of things to do. I used it to describe my successes and failures and described how I was fed up with the growing complexities of web-writing and how much I longed to go back to freedom and simplicity. In fact, to put it bluntly, I allowed myself to be me again and no longer try to cater for everyone's expectations.

The beautiful thing that always happens at such moments, is that as soon as I shrink my world to what I really want, a new clarity is suddenly there and boring stuff that I wrestled with for days on end, suddenly is transformed into a fun series of aha-moments, leading to break-through solutions in just a few hours. Effortlessly.

And that's what happened with this color theme/localstorage stuff too. I could have gone back to my personal favorite "B.U.T.S" solution and keep purring happily ever after, but now I could see the beauty and promise of the almost complete color theme/localstorage, just begging to finish it correctly.

So that's what I did. As far as I can tell, it has become a decent and reliable theme switcher, that remembers your choice. I would have preferred a solution with much less lines of code, but okay...

This theme switcher is based on the work of Johan Kohlin. He added an interesting extra: in whatever color theme you are, just double-clicking anywhere on your screen, brings back the light theme.

Finally, I made the following available for playing, testing or for creating your own version:

Happy writing!

Feedback ⇆