Re:Building a front end with no JavaScript
by giancarlostoro on Thursday April 11, 2019 @09:43AM
(#19634385)
If you disable JS on HN that button goes away, but you can still up / down vote. I like that, I wonder if the [-] could be implemented in CSS though, I feel like it can.
[ Parent
| on HN ]
Re:Building a front end with no JavaScript
by jgtrosh on Thursday April 11, 2019 @09:51AM
(#19634489)
I believe using a checkbox element and the :checked selector alongside siblings matching would do the trick.
That would do nothing for screen readers thus compromising accessibility.
Re:Building a front end with no JavaScript
by extra88 on Thursday April 11, 2019 @01:28PM
(#19636967)
If you use the checked state to of a checkbox to change the display property (i.e. toggle between none and initial), that will change the content's visibility and its availability to screen readers.
Re:Building a front end with no JavaScript
by giancarlostoro on Thursday April 11, 2019 @11:48AM
(#19635819)
I've done / seen so many hacky things in web dev I would be surprised how many websites even work properly with screen readers.
Such is the sad state of web development.
Re:Building a front end with no JavaScript
by giancarlostoro on Thursday April 11, 2019 @01:23PM
(#19636917)
As I do hacky work on the web I sometimes wonder why specific UI elements don't exist yet instead of people being forced to hack other elements to do things the web doesn't support. I can't remember a good example off the top of my head currently sadly.
Re:Building a front end with no JavaScript
by brlewis on Thursday April 11, 2019 @11:09AM
(#19635255)
Could you just nest <details> elements?
Re:Building a front end with no JavaScript
by humblebee on Thursday April 11, 2019 @09:51AM
(#19634484)
Seems like it could be done with a checkbox and some cash. I'm sure someone could figure it out.
The article has exactly this scenario as an example of where pure CSS can replace JS.
Re:Building a front end with no JavaScript
by pawelk on Thursday April 11, 2019 @11:05AM
(#19635198)
It could be done using `input:checked + sibling` selector e.g. like this: https://jsfiddle.net/6bgemn0s/
For something fancier it would be possible to style a label with appropriate for="" attribute and hide the checkbox completely, then even apply some transitions: https://jsfiddle.net/6bgemn0s/1/