5 ms·
I did this recently for my new personal website! It's quite easy and really satisfying. I love doing as much as possible in stateless CSS instead of JavaScript.
by brundolf 7y ago
I did this recently for my new personal website! It's quite easy and really satisfying. I love doing as much as possible in stateless CSS instead of JavaScript.
http://www.brandonsmith.ninja/ http://www.brandonsmith.ninja/
- uncheckederror 7y agoI've been using it for a few months on my personal site as well. It defaults to the light version and then switches to the dark them on request. This is so people who don't care or aren't good with computers get the light version and those that can set the system theme have the option of getting the dark version. https://thomasryan.xyz/ https://thomasryan.xyz/
- saagarjha 7y agoFWIW, your Posts/Demo/Resume links are laid out a bit oddly on my iPad.
- uncheckederror 7y agoThanks for pointing this out! I borrowed a coworker's iPad at lunch and fixed this bug. As best as I can tell Safari wasn't respecting the text-align: right; CSS rule. I've switched to a flexbox layout for those elements.
- _bxg1 7y ago> people who don't care or aren't good with computers get the light version Or more importantly, people whose browsers/OSes don't set that CSS flag
- 333c 7y agoI also did this on my personal website. I was surprised how easy it was, and happy that it was built into CSS, requiring no JS (as you said).
- wlesieutre 7y agoMine too! Finally put up a personal site last month after not touching any web projects for a long while. I've checked out of a lot of social media and wanted my own place to put stuff and to poke around with javascript and web graphics. One of the upcoming posts is going to cover handling dark mode for <canvas> content. So far I've just used transparent backgrounds with no black or white drawing so that it's visible either way. https://will.institute/ https://will.institute/ Not much on it yet, just been slowly working through the setup for doing a canvas with a responsive site. Neat tidbit - the logo image is a single SVG in shades of dark gray, which doesn't work well on a dark background. You can apply image transformations in CSS under the dark mode media query to adapt things like this: img#wi-logo { filter: invert(100%) brightness(110%); } This is the same tool that the linked post uses for desaturating images, but adding that invert is a useful tool for dark mode. Personally I wouldn't recommend general image desaturation, photos taking more focus against a dark background is a good look if you ask me. At least consider making it an opt-in setting instead of the default.
- _bxg1 7y agoWhat I did for my SVGs was use CSS to actually change the internal fill/stroke colors directly. Unfortunately you can only do this if the SVG is inlined as markup (as opposed to shown in an <img> tag), but it's computationally much cheaper than using filters, because the latter operate on the image as a set of pixels rather than a set of shapes. The logo design itself is really slick, though!
- wlesieutre 7y agoOoh, that's an interesting idea that I hadn't considered! My page is pretty computationally lightweight to start with (no 3rd party javascript) but if I'm ever in the mood for some unnecessary optimization that sounds like a fun one to experiment with. Trade-off is slightly more data to send with each page, since you have to inline the SVG rather than having it cached after the first load. But it's a whole 2kb and could probably be smaller if I wanted to look into SVG optimization.
- 7y ago
- fphilipe 7y agoSame here: https://phili.pe/ https://phili.pe/ I've used CSS variables though, which make it even simpler. E.g. I have `--page-background-color` and `--text-color-primary` that are set to a certain default value. In dark mode, these variables are set to other values, removing the need to redefine the actual selectors.
- _bxg1 7y agoMe too! CSS variables rock.
- Klonoar 7y agoDid this about six months ago over at my site. Was annoying to get it right but glad I did. Some people find these kinds of sites pointless these days, but I enjoy keeping one even if I rarely update it anymore. Spirit of the web and all that. https://rymc.io/ https://rymc.io/
- OJFord 7y agoNice site, it works well on mobile, which is a bit of a pleasant surprise when it happens from personal blogs etc.! FWIW the Twitter feed from, I assume, people you follow is a little odd though - it's not immediately clear that it's not you, nor about the article being viewed, which it doesn't necessarily have anything to do with, and it includes replies to threads. At the time of writing the top one is recommended reading that's 'racist from the start'.
- Klonoar 7y agoYeah, it bleeds a bit too much on mobile - younger brother passed away recently and I shoved the site out the door before heading back home to be with him. Desktop view has it more marked as separate content - e.g, that tweet is actually a Retweet with a comment, which is kind of a pain in the ass to handle from Twitter's API. Should find time to clear it up a bit I guess. Site works well on mobile because I cannot stand sites that don't load quick + layout well on mobile, and considering the general content I post, I'd expect the audience to have the (relatively) same pet peeve. I open sourced the activity scraper as well, if anyone's interested: https://github.com/ryanmcgrath/activity-scraper https://github.com/ryanmcgrath/activity-scraper
- agret 7y agoLooking at the feed you should see if it's possible to exclude any tweets that begin with "RT" (retweets) or the "@" (replies). This way only posts you write should show in the feed, would make it much cleaner as without the full conversation contexts those other messages make no sense. The GitHub activity feed is pulling in every comment you make, see if you can filter that to only show pull requests you've created to showcase your work. Maybe also include commits to your own projects if the commit length is more than a certain number of characters to filter out the small updates.
- woutr_be 7y agoI like that you're using CSS variables to achieve this. I had to look up support for this , and it seems fairly decent. https://caniuse.com/#feat=css-variables https://caniuse.com/#feat=css-variables