Design comparison
Solution retrospective
Any feedback is much welcome! Especially on the semantics and accessibility~
Community feedback
- @pikapikamartPosted over 3 years ago
Hey, awesome work on this one. The layout looks really good, it responds well and the mobile layout is really good. Cards are just bit bigger that's why 4 cards won't span in single row.
First, to be honest, I still find this challenge hard especially choosing semantic elements.
Some suggestions would be:
- For better accessibility, the color theme toggler should be using a
fieldset
as the parent container, and havinglegend
:
<fieldset> <legend> colormode selections </legend> <label /> <radio /> <label /> <radio /> </fieldset>
The structure would look like that. When screen reader navigates in that, it would read the
legend
element, informing a user what this set ofinput
does, hence it is for color mode selection.input type="radio"
will be the best element on this, since it is a choices right, radio buttons are intended for those. You can look at my rest-api-challenge, look up the structure of my color modes toggler. If you want a simpler one, like this challenge's color mode selection, you can reply to this feedback and i'll be gladly make a code snippet so that you can use it as your component.- Great adding
sr-only
text for themain
element.
Aside from those, great work. I still can't make decision what element I would use on this hahaha my first version of this is not really accessible at all. Great work!
Marked as helpful0@A-amonPosted over 3 years ago@pikamart Thank you so much! Oh, so <fieldset> can be used outside a form? 🤔 Interesting.. Having a <legend> to describe what the toggle is for is an amazing idea! If possible, can I have ur repo link for the REST API challenge? 😀 I wanna try to understand the code. And also the code snippet for this challenge so that I can try using it~😂
0@pikapikamartPosted over 3 years ago@A-amon Yes,
fieldset
can be used especially nesting radio buttons, and one great use case are the color mode selections. This is the link for the rest-api-challengeFor the code snippet, let me just create a snippet and I will reply it here after I coded it.
Marked as helpful0@A-amonPosted over 3 years ago@pikamart Thank you! I still have a lot to learn about HTML tags 😂
0@pikapikamartPosted over 3 years ago@A-amon Hey, sorry it took long hahaha, but here is the link of the sample snippet.
Marked as helpful0@A-amonPosted over 3 years ago@pikamart Wow, u coded an entire example! 😂 Really appreciate it~ Took me a while to understand it thoroughly. .lightmode label is for the moving circle. And the label that stays as Dark Mode is intentional to let user knows which radio button/direction is for dark mode. 🤔
I gotta go wow again. I didn't know I can use arrow keys to navigate between radio buttons! 😲
Thank you again! I learnt a lot from this short snippet (I am saving it in a notepad for reference! 😀)
0@pikapikamartPosted over 3 years ago@A-amon Not entirely like that.
If you try inspecting the sample, hover to both
label
. The two have the sameheight
andwidth
. As you may have noticed in the css, I am changing thez-index
property.If
darkmode
is selected, thez-index
goes toz-index: -1
, this way, the label forlightmode
will be on top of thedarkmode
. So for the next click you made, you are now clicking on thelightmode
label.Then if the
lightmode
is now selected, make the thedarkmode
label be on top of thelightmode
label by going back to its defaultz-index
. Then it just goes like that.Then I am just using the
darkmode
radio button, checking if I need to move thelightmode
circle or not.Also yep, if there are sets of radio buttons that have the same
name
property, you can seleck any one of those via arrow keys.Great that I could help with it hahaha awesome
1 - For better accessibility, the color theme toggler should be using a
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord