News for hackers. Stuff that matters.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by Etheryte on Friday May 29, 2020 @09:06AM (#23349469)
Another day, another site that's just text and images but for some reason won't work with cookies disabled. I know not allowing arbitrary cookies on my machine en masse is my own choice, but I cannot comprehend why a page like this wouldn't work without them.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Friday May 29, 2020 @09:21AM (#23349645)
Fix incoming . I'm using local storage to maintain the "dark mode" choice and it can't be accessed if cookies are blocked.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by Etheryte on Friday May 29, 2020 @09:30AM (#23349754)
Thanks a lot for the quick update, really appreciate it. Works well now.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by IshKebab on Friday May 29, 2020 @09:37AM (#23349822)
You can do dark mode purely in CSS. No need to code an explicit choice in your site.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by mikewhy on Friday May 29, 2020 @10:13AM (#23350169)
But the point of coding the choice is ... so the user has a choice? This is a bizarre response.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by mcintyre1994 on Friday May 29, 2020 @10:27AM (#23350302)
I think they mean using CSS `prefers-color-scheme` the user can set a light/dark preference at the browser level and your site doesn't have to have its own implementation. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by satvikpendem on Friday May 29, 2020 @10:41AM (#23350438)
Yes but sometimes I want a choice. For example, I use the Dark Reader extension with a pure #000 background. Many dark modes use some grey or other non-black hue, which can be quite annoying, so I usually turn them to light mode and then Dark Reader can properly convert the light theme into my preferred black theme.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by mikewhy on Friday May 29, 2020 @10:43AM (#23350470)
I'm aware of the prefers-color-scheme stuff added to browsers. AFAICT, only Firefox supports setting it at the browser level, while others will inherit from the system.

This would still remove the visitors ability to say "I want THIS SITE to be in light/dark mode", without affecting all other sites / apps on their system. This page could support reading from the browser/OS, while still giving the choice on top of that.

Again, this choice was probably implemented ... to give the user a choice.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by adrianmsmith on Friday May 29, 2020 @12:41PM (#23352218)
May I ask (genuine question), why would anyone need a choice per site? Surely some people are “light mode” people and want everything in that mode and others are “dark mode” people?
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by mikewhy on Friday May 29, 2020 @01:25PM (#23352814)
Some people are "light mode" people, and some are "dark mode".

Some people may not want everything to be light or dark mode. I am one of them.

Some articles may not work well with dark mode.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Friday May 29, 2020 @01:50PM (#23353166)
As the author of the site, I like switching between the two modes on all websites that support it.

Like someone above said, some sites implement it as an after-thought. In my case, I'm giving more love to dark-more because there are simply more nice color combinations in dark more than with white.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by mountainboot on Friday May 29, 2020 @01:06PM (#23352558)
Not me, I like both modes. Often I will have one text editor in dark mode and another in light mode.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by dnissley on Friday May 29, 2020 @01:15PM (#23352682)
Sometimes one implementation or the other just plain sucks -- typically it's bad dark mode implementations that obviously were just afterthoughts.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by satvikpendem on Friday May 29, 2020 @10:39AM (#23350417)
You can make a pure CSS theme toggle as well. You can even use SVG to do it with a custom animation.

https://codepen.io/demilad/pen/bZRjpb

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Friday May 29, 2020 @01:51PM (#23353186)
The author here: indeed! I've debated myself over and over whether I should make dark mode the default, but I'll implement the "preferred theme" someone mentioned in another comment :)
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Friday May 29, 2020 @09:09AM (#23349509)
author here. I wasn't aware this was an issue, sorry about that. I'll fix it
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by lsalvatore on Friday May 29, 2020 @10:49AM (#23350548)
It's cool that you fixed this, but you shouldn't apologize to this person. You published a free article on your own site. This commenter rudely criticized your site for their nontypical edge case without an ounce of respect. They are lucky to have gotten your attention at all.
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by vorpalhex on Friday May 29, 2020 @11:11AM (#23350852)
There's value in listening to your audience, and it sounds like the author didn't intend for cookies to be required to use the site.

I don't think the commenter was being rude either, though it's obvious they're frustrated (understandably).

You can choose to cooperate with others or fight them. Usually when we cooperate, things are improved.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Friday May 29, 2020 @01:54PM (#23353230)
This is my sentiment. I'd feel frustrated as well if I was on their shoes (visited an interesting article, but it didn't work because of something silly).

It was also unexpected. I didn't even know localStorage could be broken by disabling cookies haha.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by seattle_spring on Friday May 29, 2020 @03:31PM (#23354479)
> though it's obvious they're frustrated (understandably)

It reminds me of the meme where a guy is riding his bike, inserts a stick into his own wheel while riding, falls over (understandably), and then blames someone else for his fall.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by vorpalhex on Friday May 29, 2020 @03:58PM (#23354777)
When I visit a news site, to read an article, I get a video that scrolls along with me and autoplays. So I disable video autoplay.

This breaks some video conferencing apps. It's a choice I have to make - some broken apps or a bunch of annoying websites.

Some websites use my cookies and localstorage to track me across properties. They do this so they can harvest my profile data and habits and sell them for profit without my permission.

Again, it's a choice and I think it's a fair one to make.

As engineers, we don't exist to punish our users for making choices different from ours. That's a great way to end up without any users. We should make their experience as good as we can and give them value. Sometimes that isn't possible - I can't make a video conference app that's immune to blocking autoplay. That doesn't mean we shouldn't try.

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by obedm on Saturday May 30, 2020 @07:24AM (#23360358)
I whole-heartedly agree with this. Unless you implement a must-have feature based on localStorage or whatever, your site should still fully (or at least partially) function without it.

In my case, I was aghast my blog didn't work without cookies. I don't even have ads running on it, and it's static, it should work on my grandmother's toaster!

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by danlugo92 on Friday May 29, 2020 @09:11AM (#23349532)
What do you use for cookie blocking?
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by Etheryte on Friday May 29, 2020 @09:29AM (#23349739)
Nothing special, I've turned off both first party and third party cookies in the browser settings. I add sites I use regularly to a domain whitelist [1], other than that I don't use much anything for cookies anymore. Historically I also used to use Privacy Badger [2], but with my current setup it isn't really all that relevant.

In broader tracking and privacy context, I also use NextDNS [3] and uBlock Origin [4].

[1] chrome://settings/content/cookies?search=cookies

[2] https://privacybadger.org/

[3] https://nextdns.io/

[4] https://github.com/gorhill/uBlock

Re:A Visual Guide to React Mental Models: UseState, UseEffec... by sopromo on Friday May 29, 2020 @12:05PM (#23351671)
You could give uMatrix a try, I use it to block cookies, images, media and iframes. If you really want to allow a site to use all that it is a bit easier to do (I think)
Re:A Visual Guide to React Mental Models: UseState, UseEffec... by pier25 on Friday May 29, 2020 @11:36AM (#23351200)
So if a site requires cookies for authentication you manually add that site every time?