Why you shouldn't use a div for everything - creating accessible buttons and navigations

  Рет қаралды 133,037

Kevin Powell

Kevin Powell

Күн бұрын

I think it's important to highlight when we've made past mistakes and show the right way to do it when we find those mistakes.
🔗 Links
✅ The finished code: codepen.io/kevinpowell/pen/Ba...
✅ More on Visually Hidden: www.scottohara.me/blog/2017/0...
📚 Resources I used to help make this video:
✅ AcceDe Web Accessibility Guidelines: www.accede-web.com/en/guideli...
✅ Paul J Adam's Accessible Hamburger Menu: pauljadam.com/demos/hamburger...
✅ Ally Style Guide's Mobile Navigation: a11y-style-guide.com/style-gu...
✅ Building Accessible Menu Systems on Smashing Magazine: www.smashingmagazine.com/2017...
⌚ Timestamps
00:00 - Introduction
00:29 - The mistake I made
01:18 - Why divs don’t make good buttons
03:10 - Fixing the styling of the button
03:48 - The second big mistake
05:20 - Adding extra context to our button
09:27 - Fixing up the CSS
10:47 - Updating the original jQuery to JavaScript
12:03 - Adding the aria-expanded to the JS
13:20 - Making improvements to the JS
18:38 - The next problem - removing the menu when it’s closed
19:31 - Why it’s important to do all this
20:49 - Toggling the display of the ul
23:29 - Fixing the animation
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZfaq channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 472
@KayinAngel
@KayinAngel Жыл бұрын
I'd love to see more vids on accessibility - it's definitely the only area where I'm not very well versed in.
@Bazkur98
@Bazkur98 Жыл бұрын
I concur! Color impairment solutions would be nice as well
@DarrenbyDesign
@DarrenbyDesign Жыл бұрын
Check out work from Sara Soueidan -she is a great a11y teacher
@KayinAngel
@KayinAngel Жыл бұрын
@@a1white Did your company wait until before or after a predatory lawsuit was filed? LOL.
@Ikejosh9
@Ikejosh9 Жыл бұрын
I agree
@voikalternos
@voikalternos Жыл бұрын
same :D
@RhayvenBlood
@RhayvenBlood Жыл бұрын
As a blind developer, I just want to say I love your content and love your focus on accessibility ;__;
@xijnin
@xijnin 6 ай бұрын
How do you know what ur writing?
@wobsoriano
@wobsoriano 5 ай бұрын
@@xijnin 🎙
@cintron3d
@cintron3d Жыл бұрын
Thank you so much for making this. I'm going to share this video with my team because you concisely captured years worth of "learning the hard way" in a short focused video.
@olisano1
@olisano1 Жыл бұрын
Thanks for supporting kevin he's so great
@stevenson1142
@stevenson1142 Жыл бұрын
paypig
@wickedwifestre
@wickedwifestre Жыл бұрын
As a developer at the beginning of my journey, I really appreciate you reminding us that everyone makes mistakes. I always learn so much from your videos but I especially appreciate how open you are about your process.
@dankierson
@dankierson Жыл бұрын
Stop brown-mouthing Kevin 😶
@tharsis
@tharsis Жыл бұрын
I know, I know, pedantic JS time. That collapsed if statement for controlling the menu feels really wrong to me. I understand why you've done it like that that to a degree, but you could definitely get rid of the if(...); surrounds so that you just have 'isOpened ? closeMenu() : openMenu()'. To me, empty if blocks just make me feel...off, even if it does work perfectly fine. Despite that minor bit, though, fantastic video! Excellent coverage on button and nav menu accessibility. The final bit of pedantry for me would be that maybe you could swap out for ? Apparently might signify to accessibility tools that the s within contain interactable content, unlike the information content of a , but I don't think any tools really care at the moment and according to the MDN it looks like they're both considered virtually identical by the browser. Still, could be something that might become more relevant in the future. Or not.
@motodew54
@motodew54 Жыл бұрын
first, love the videos! been watching for a year or two now! second, while this didn't happen in the video, if someone did that and forgot the semi-colon at the end of the line, the first line after that will technically be guarded by that if statement which could induce unanticipated behaviors since there were no scoping braces after that
@JenniferSaenz
@JenniferSaenz Жыл бұрын
If you change to , you open yourself up to ensuring more functionalities are enabled vs a traditional nav because that pattern is not meant for nav menus, but rather for application menus.
@jbird4478
@jbird4478 Жыл бұрын
@@lucidattf Writing with readability in mind is great, but writing so people who don't know the language can read it, seems a bit too much.
@kuckuk
@kuckuk Жыл бұрын
I agree with @JBird that knowledge of the language is just a pre-requisite to reading code. That being said, I also agree that (IMO) the ternary operator isn't the most readable choice here. Personally, I use the ternary operator exclusively for expressions (think things that take on a value) while I use if exclusively for statements (think things that do something). Somehow, it feels more natural to have something like "x is either 1 or 2" or "I want to set the label to 'button' and then add either nothing or an s" than to do it with an if (plus it allows me to use something like const when I want to conditionally initialize a variable) and then for behavior I can say "if it's open, I want to close it, else I want to open it". Also, just as a quick side note on the expression vs. statement thing: in JS / TS, `if` is always a statement - it CANNOT take a value and is never an expression. The ternary operator is an expression and always takes a value; however, it can also act like a statement! Some languages handle this differently. In rust, for example, `if` also forms an expression and for that reason, rust simply doesn't have a ternary operator! Instead, you can write something like `let x = if condition { 1 } else { 2 };` instead of `const x = condition ? 1 : 2;`. Personally, I would argue that this supports my view of when to use the ternary operator and when to just stick with `if`; even if it's slightly more verbose.
@lucidattf
@lucidattf Жыл бұрын
@@jbird4478 Ternary operations are not as well known, adding the word "if" doesn't cause any more issues and makes it more clear
@robrasti
@robrasti Жыл бұрын
"It's our job to do it properly" is pretty much how I define my career of coming in to projects that are behind and broken and having to fix them. Thanks for all you do, it helps to know resources like you are out there to direct my developers to for some concise and well built coding examples.
@m_nasyr
@m_nasyr Жыл бұрын
Mini-course about accessibility would be amazing!
@yttos7358
@yttos7358 Жыл бұрын
With all due respect, screw those people giving you push back on such amazing coverage. We're lucky to have you uploading such wonderfully full and robust content. I think we'd all appreciate you pointing out how to make sites more accessible. I think we all appreciate how you teach the right way, not the fast way.
@ahuggingsam
@ahuggingsam Жыл бұрын
Really good to see people A) be willing to admit and address mistakes they make and B) take assistive technology seriously. I'm not good at assistive stuff, but I do care about it and a lot of it is pretty subtle imo, so it's really nice to see it being addressed like this.
@naveenramkumar6123
@naveenramkumar6123 Жыл бұрын
I am pretty sure you don't need the if condition for the ternary operator. so, instead of if(isOpened ? closeMenu() : openMenu()) It should just be isOpened ? closeMenu() : openMenu(). Also I think the closeMenu and openMenu should be the same function with an argument of the true/false Let me know what you think
@hansheinrich700
@hansheinrich700 Жыл бұрын
Yup, you're right. You don't need the if(…) around the ternary operator. The closeMenu() function is redundant, instead you can use a ternary operator as second argument for the setAttribute(): siteNavigation.setAttribute('data-state', isOpened ? false : true). Last thing to mention: instead of adding a third state (closing) I would use the event listener 'transitioned'; after the closing animation/transition you set display to none. That saves you nearly 40-50% of code lines.
@ishayisrael8101
@ishayisrael8101 Жыл бұрын
I don't think it should be the same function, firstOff - it's less readable and on top of that it will lead to over engineering like this: function toggleMenu(state) { menuToggle.setAttribute('aria-expanded', state); siteNavigation.setAttribute('data-state', state ? "closing" : "opened"); if (!state) { // we're closing siteNavigation.addEventListener('animationend', () => { siteNavigation.setAttribute('data-state', 'closed'); }, { once: true }); } } or you could use the *animationName* property see ( developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event ) function toggleMenu(state) { menuToggle.setAttribute('aria-expanded', state); siteNavigation.setAttribute('data-state', state ? "closing" : "opened"); siteNavigation.addEventListener('animationend', () => { *if (e.animationName === "clipPathCircleClose")* siteNavigation.setAttribute('data-state', 'closed'); }, { once: true }); } Either way, it gets very complex, very quickly. It's just better to leave it as is.
@fortuneswake
@fortuneswake Жыл бұрын
Honestly this shouldn't even be a function it should just toString the opposite state of isOpened. ```js menuTogglesetAttribute('aria-expanded', !isOpened.toString()); ```
@VeaceslavBARBARII
@VeaceslavBARBARII Жыл бұрын
@@fortuneswake (!isOpened).toString()
@fortuneswake
@fortuneswake Жыл бұрын
@@VeaceslavBARBARII true, the order of operations would require it to be in parenthesis
@TheCRibe
@TheCRibe Жыл бұрын
Owning up to your "mistakes" and showing why and how to fix them is the definition of a true top level humble dev. You should never be afraid to own up, great work on this video !
@PicSta
@PicSta Жыл бұрын
Thanks, Kevin! Even this turned out to become a more complex video, it's show your progress and how you achieved certain things you would never do the same way. Accessibility today is very important, so thanks a ton for this update and the good work as always.
@kylevandeusen
@kylevandeusen Жыл бұрын
Also, really appreciate you taking the time to talk about why this is important and that we should continue to try to do better 💪
@1stMusic
@1stMusic Жыл бұрын
I loved looking at the word 'butt' for 5 seconds there (2:46). Everyone makes mistakes sometimes, you just have to learn from them :)
@RideTheTeacups
@RideTheTeacups Жыл бұрын
When you added your poll, I knew it was this one!!! Who hasn’t done that at some point? My Senior Dev at my first job didn’t care about clickable divs, so I was off to a poor start. I eventually realized it was an issue, but I had a hard time properly evangelizing to the rest of the team. After switching jobs, we’re now extremely a11y aware, and it’s incredible. Really thrilled to see you bringing awareness here! Thank you.
@erichobbs4042
@erichobbs4042 Жыл бұрын
I've seen you use these data and aria attribute selectors in your CSS before, and I feel like it's finally clicked for me as to why this is such a good idea. If I am reading the CSS, seeing that a style is applied when aria-expanded = opened, makes the intent and meaning of that style a lot clearer. Another side benefit of doing things properly.
@Weeniehutnurse
@Weeniehutnurse Жыл бұрын
I just graduated college and your videos actually helped me get a job. I’ve been taking everything you say and right notes, and apply it to websites I make for my portfolio. I talk about it in my interviews and got a job as a remote full stack developer who focuses on front end! Thank you so much Kevin! I’ll continue watching your content, to continue learning!
@katrinaaponte4787
@katrinaaponte4787 Жыл бұрын
I love that you didn't just delete the video and pretend like it didn't exist. Instead, you took the time to make a whole new video explaining why it was a mistake, and how to correct it. Love your channel!
@rychei5393
@rychei5393 Жыл бұрын
I learned a LOT... Learning from mistakes and fixing them is probably more helpful than perfectly clean tutorials.
@tutestheking7838
@tutestheking7838 Жыл бұрын
Great stuff, I love when you talk about accessibility, cause it's one area that I really struggle at! Keep them coming!
@MyLittlePwny7
@MyLittlePwny7 Жыл бұрын
Thank you so much for this. Any job I work, no one cares about semantic HTML or accessibility or basic keyboard user experience. Awesome stuff, please keep doing this!
@onrgms
@onrgms Жыл бұрын
Thank you for your great tips Kevin! BTW you don't need the "if()" block, 'cause you already used the "?" operator.
@PYXLDesign
@PYXLDesign Жыл бұрын
Yea you can use isOpened ? closeMenu() : openMenu; - I use these a lot when setting up variables conditionally and need a specific true or false value assigned.
@ThomPorter74
@ThomPorter74 Жыл бұрын
Kudos to you Kevin! The best mistakes are the ones we learn from! And as always, your in-depth explanation of why is very much appreciated! :)
@lifeisniche
@lifeisniche Жыл бұрын
anyone can easy make any design using CSS but these small things is what makes us different from others. Thank you kevin for this awesome channel
@KelseyThornton
@KelseyThornton Жыл бұрын
This is a great video! Thanks, Kevin! Not only does it say "Hey, we all make mistakes", but it shows us a great way of achieving a really solid, neat way of approaching accessibility in our designs. And as you say, this may be a lot of work now, but once it has been set up it's there for later. If web technologies improve again, then this can be expanded upon to include those new techniques.
@SoreBrain
@SoreBrain Жыл бұрын
I haven't watched the video yet. I just wanted to say Kevin, you're an amazing resource creating great content. OK now I watch it.
@lisarogers5873
@lisarogers5873 Жыл бұрын
Thanks for showing different options and the accessibility coding. I really like that you have the split screen showing the code then what it does in real time. Very helpful.
@KevinPowell
@KevinPowell Жыл бұрын
Glad it was helpful!
@joshuauzzell541
@joshuauzzell541 Жыл бұрын
Bravo! This is my favorite KZfaq video this year. Perhaps of all time. Thank you.
@andsheterliak
@andsheterliak Жыл бұрын
You can also simplify toggling the menu to: function toggleMenu (isOpened) { menuToggle.setAttribute('aria-expanded', `${!isOpened}`); }
@andsheterliak
@andsheterliak Жыл бұрын
You may not even need a function for this case. If you use typescript, wrapping the boolean in a template literal is mandatory.
@andsheterliak
@andsheterliak Жыл бұрын
Instead of data-state data-is-opened can be used. siteNavigation.dataset.isOpened= `${!isOpened}`;
@andsheterliak
@andsheterliak Жыл бұрын
If it haven't been said in the video the visibility: hidden can be used instead of display: block.
@lucbian
@lucbian Жыл бұрын
I also really appreciate to see you admitting to making "mistakes". Although I wouldn't refer to this as a mistake but simply "not the best choice made".
@JoelBorofsky-yc5ve
@JoelBorofsky-yc5ve Жыл бұрын
I'm happy when you show that there's more work to this. Take away the marketing reasons and other reasons behind accessibility and the number one reason we should be making our sites accessible is that it includes people. No one likes being left out. So if I have to put a little extra work into a build, or go back and change some things in a build I made, just so a few more people can feel included if they stumble across my site, then that alone should make it worth it. Half the reason I watch your videos is for stuff like this.
@me_manish_prajapati
@me_manish_prajapati Жыл бұрын
Amount of knowledge I get from one video is unimaginable 🔥
@psycho-tv
@psycho-tv Жыл бұрын
I have learn something that I really have ignored all the time. Thanks Kevin ❤️
@kalahari8295
@kalahari8295 Жыл бұрын
I love that you answer the question "why" ❤️
@sovereignlivingsoul
@sovereignlivingsoul Жыл бұрын
excellent video, i am the worst for taking the easy road when it comes to coding, but since watching your videos and taking a couple courses from you i spend more time analysing what i want to do and building my functionality one step at a time, and i do a lot more testing than i used to, your commitment to perfection is admirable, i am definitely going to incorporate your hamburger methodology in my future products, using the aria with the js code to eliminate css code is very smart, thanks Kevin
@taofeeqomotolani2311
@taofeeqomotolani2311 Жыл бұрын
This is already an Amazing series
@simplesoul6143
@simplesoul6143 Жыл бұрын
😅😅 You have no idea how many sites I have made using divs and spans as button, then add a javascript and cursor pointer. I have learned something new and important. Thanks Kevin!!
@thecoderabbi
@thecoderabbi Жыл бұрын
Kevin this is great! Going back to something you didn't do right and correcting it openly👍
@dalanazelas
@dalanazelas Жыл бұрын
I think this is by far my favorite video of yours in recent memory. I would like to see this navigation taken a step further to address the issue of responsive design. My biggest question I was left with was "What happens to the button element when you're on a desktop and how to you address the two different states of the menu in one solution?"
@rmdev
@rmdev Жыл бұрын
Kudos to you for taking the time to actually make a video correcting mistakes and explaining it rather than just pinning a comment with the correction!
@emilioclemente1987
@emilioclemente1987 Жыл бұрын
Amazing video! It helps knowing that even the best make mistakes and are constantly learning. I am not alone in this never ending but passionate walk
@travholt
@travholt Жыл бұрын
Solid video! I just set up a navigation menu today, going to go through it tomorrow with all your points in mind. Thanks!
@RodrigoMendoza7
@RodrigoMendoza7 Жыл бұрын
Another top notch video from the King. Thank you! Here's my contribution to it: instead of using to list menu items, use , which is the new semantic list wrapper for this purpose.
@explodatedfaces
@explodatedfaces Жыл бұрын
As someone who primarily works on internal tools that don't face the public I really don't often think of developing for people who need to use assistance tools to get around the web, like someone who is blind. I fully came into this video thinking "who cares about using a div, its not that big of a deal.. you can make it all work the same" and within about 5 minutes realized I was forgetting that there are millions of people who need us to do more for them so they can use our products. Thanks for the great reminder that I need to consider that some people need us to put in a good effort instead of doing things the lazy way.
@paolodinooddone
@paolodinooddone Жыл бұрын
oh thank you man. I was doing the wrong way by simply adding too many setTimeout and intermediate classes (like closing or opening). My handheld menu bar is a real mess. You are great. Thank you again.
@AndrewDodson1
@AndrewDodson1 Жыл бұрын
Kevin, this video's title might be very incorrect! When I saw a 30 minute video and the title, I thought I'd watch / skim about 5 minutes of it to find the mistake, but ended up watching the entire thing. It has a ton of value! Thanks!
@voikalternos
@voikalternos Жыл бұрын
I'm glad I followed a good developer who is inclusive :)
@wpeasy
@wpeasy Жыл бұрын
Love your work.. I consider myself to be pretty OK with JS and CSS. However, I try to watch at least one of your videos each day. You have great clarity and I always find something interesting.
@composernotes
@composernotes Жыл бұрын
This is a fantastic video. Making sure our websites are accessible is such an important issue.
@obed.raimundo
@obed.raimundo Жыл бұрын
This. All of this! Thank you Kevin. THANK YOU!
@kayaqueen6982
@kayaqueen6982 11 ай бұрын
you Sir teach me that speaking a language doen't mean you actualy know it . watching videos here and there and watching your videos always makes me realise this truth
@josipbjezancevic5697
@josipbjezancevic5697 9 ай бұрын
Why should you be ashamed? You are learning too. The shame would be if you never really cared. Good work Kevin!
@Linuxdirk
@Linuxdirk Жыл бұрын
Wow! Accessible web design! Something that is overlooked by pretty much all “KZfaq web designers”. Thanks for this video! 👍
@sovereignlivingsoul
@sovereignlivingsoul Жыл бұрын
Happy Holidays Kevin, great video, about my fifth time watching it, always learn something new.
@damianrivas
@damianrivas Жыл бұрын
Wow, this is one of the most informative videos I have ever watched
@jacmkno5019
@jacmkno5019 Жыл бұрын
Good things should soon come to you for doing this. Keep it up Kevin! You should do a summary of interesting not obvious behaviors associated with pure HTML tags and attributes. I bet there is a lot there that developers should be aware of...
@Erwin_t
@Erwin_t Жыл бұрын
Kevin! I truly admire how you are passionate about CSS. Everytime I see your videos I learn something new. I wanted to ask, what are some projects that you have worked like websites that are out live today in the real world. You are ledengary.
@natalieeuley1734
@natalieeuley1734 Жыл бұрын
The only accessibility thing missing from this is what happens if the user doesn't have JS enabled :P. Always have a no-JS fallback as part of accessibility, too. Also, animations are super cool but they need to be able to be disabled from knowing the user's animation preference (prefers no animation). Obviously that is outside the scope of this video's concept, but they are things to keep in mind.
@CottidaeSEA
@CottidaeSEA Жыл бұрын
A no-JS fallback seems like an impossibility to me. There are far too many things that simply do not work without JS and there is no good way to add alternatives seamlessly. You'd just end up with a broken website.
@quindarious1487
@quindarious1487 Жыл бұрын
Let’s make sure we include support for apple watches too!
@abc33155
@abc33155 Жыл бұрын
CSS-only drop down menus have been around for many years, no JS required. Most examples on the web open on :hover, but we can use :focus instead so that it opens on click instead, and also when navigating with the keyboard.
@chadiem
@chadiem Жыл бұрын
I learned so much from this video. Thanks Kevin!
@j0ntsang
@j0ntsang Жыл бұрын
This is the best tutorial video on the internet
@hcjorgensen
@hcjorgensen Жыл бұрын
Excellent video, Kevin. Thanks!
@sumitkumarsoni1
@sumitkumarsoni1 Жыл бұрын
Vim user here and a frontend dev. Thanks for making this video. I was confused when vimium didn't recognised a toggle button which was actually a div.
@afroloco1553
@afroloco1553 Жыл бұрын
Awesome video! I'd love to see more videos on stuff like this!
@darealmexury
@darealmexury Жыл бұрын
I always type something along the lines of elem.setAttribute("aria-expanded", isOpen) And when toggling attributes I do elem.toggleAttribute("aria-expanded", isOpen). This will remove aria-expanded if it's not open, but add it if it is.
@ofmouseandman1316
@ofmouseandman1316 Жыл бұрын
Styling on aria attributes is something I do more and more: it forces you to add accessibility in the code which is a good thing
@GeoffTripoli
@GeoffTripoli Жыл бұрын
Great video! I completely agree with your rant about doing it right being important. Also, one little nit... You don't need a surrounding if statement for your ternary (17:49). You can just use the ternary by itself. But, sometimes lint rules will complain even though it's completely valid. Adding the additional if statement makes it less readable to me since that if statement isn't actually used for anything.
@PeppertopComics
@PeppertopComics Жыл бұрын
Passing a non-string second parameter to setAttribute() will convert it to a string anyway. So the code around 13:05 can be simplified to menuToggle.setAttribute('aria-expanded', !isOpened); No need for a ternary operator or extra functions for that. It's also worth knowing that there's an optional second parameter to classList.toggle() which can be used to force the addition or removal of the class - making it behave like classList.add() or classList.remove() depending on the value of that second parameter. That would allow you to do something like this: menuToggle.classList.toggle('open', !isOpen); ...without having to worry about things getting out of sync if the menu is already opened when the user clicks. Finally, you should always check the 'animationName' property of the animationEnd event (at 29:34) to make sure your code is only responding to the menu animation, and not any others that might be added to the page. In this case I suspect you could have got away with just using a CSS transition with a transition-delay value on the 'display' property though, without needing to use animations at all.
@rngesus8057
@rngesus8057 Жыл бұрын
16:20 i really like that idea of using those aria tags, which already carry a semantic meaning.
@JohnSmith-vs9oe
@JohnSmith-vs9oe Жыл бұрын
Thanks for the video! Great work as always! :)
@macx
@macx Жыл бұрын
Well explained. Thanks for the all the details that are important!
@ck0024
@ck0024 Жыл бұрын
That's what I was looking for. Bootstrap use this technique in their accordion. Expand -> Expanding -> Expanded.
@yolocat-dev
@yolocat-dev Жыл бұрын
JavaScript Improvements 2: A one-liner to toggle the aria-expanded property (two lines including the isOpen variable declaration) menuToggle.setAttribute(isOpen ? "false" : "true"); No need for extra functions, just one line :D
@theweirddev
@theweirddev Жыл бұрын
or simply: menuToggle.setAttribute((!isOpen).toString());
@metalstarver642
@metalstarver642 Жыл бұрын
Or just menuToggle.setAttribute("" + !isOpen);
@yolocat-dev
@yolocat-dev Жыл бұрын
@@theweirddev could mess up older browsers tho
@theweirddev
@theweirddev Жыл бұрын
@@yolocat-dev Why?
@CirTap
@CirTap Жыл бұрын
Unlike display the visibility property is animatable from hidden to visible so the clip-path transition should've worked with that. Although hidden from screen readers it remains in the DOM and has layout.
@The14Some1
@The14Some1 Жыл бұрын
I wonder if he could have added "visibility" straight into the ClipPathCirlcleClose, showed at 25:50 instead of all those sketchy shenanigans.
@PaweBystrzan
@PaweBystrzan Жыл бұрын
aria-controls was only one I didn't know, but... It's cool I learned it after 16y in front end!
@MrAsgardian1987
@MrAsgardian1987 Жыл бұрын
thanks for your awesome demo, i actually had that this problem :-D, now i can fix my menu the proper way :-D
@salmanfarshisajib6512
@salmanfarshisajib6512 Жыл бұрын
Stunning, wanna see more javaScript videos from you.
@elysium2013
@elysium2013 Жыл бұрын
Great video. Another option to exclude navigation from a11y when it is hidden is to add a new inert attribute.
@39_navin_sem-ii22
@39_navin_sem-ii22 Жыл бұрын
You're just an amazing and awesome person and tutor ❤️❤️
@dabbopabblo
@dabbopabblo Жыл бұрын
My preference when it comes to programming is to go against the convention as a means of security through obscurity, on top of actual security standards. So using the information in the beginning of this video I’ve implemented a custom event that can be added to div buttons and instead of adding it with addEventListener you add it with prepareEventListener and based on which event you pass it, in this case it’s “sitename.interaction” it will set a tab index that’s based on its depth in the dom from body and use it’s innertext node to give it a aria-name property if it doesn’t already have one. And if you pass in a controlled child as an optional parameter it will ensure through setting a custom property if the child hasn’t been prepared or remanipulating it’s tabindex and it’s childrens to ensure they are above the tab index of the parent button, so you can layout your html however you need for zindex purposes and still get desired accessibility features without using the standard button which can be scraped for by general purpose bad actor scripts. Oh and I named the event interaction because it listens for both mouse down and pointer down and whichever event fires first serves the callback assigned and the second event to fire recognizes it’s already being handled which allows for dev tools to switch between emulating a pointer device and normal site without refreshing the page to reinitialize the event listeners based on the user agent or screen size as a fallback
@stillready6405
@stillready6405 Жыл бұрын
Thank you for the update :)
@bpavanellic
@bpavanellic Жыл бұрын
Realy Awsome Kevin. Thak u! Love from Brasil.
@BroodPitt
@BroodPitt Жыл бұрын
Please make more mistakes, this taught me a lot! 🙃
@kacpermarciniak1110
@kacpermarciniak1110 Жыл бұрын
Amazing video, thank you for your hard work 😁
@Daniel_H01
@Daniel_H01 Жыл бұрын
amazing video i didn't know about any of this. time to go back to my site and redesign and redevelop a little bit.
@MarcelRobitaille
@MarcelRobitaille Жыл бұрын
As others have said, you don't need the if with the ternary inside. You also don't need to create functions to use the ternary, you could have kept the same two lines as the if / else.
@onecornflower
@onecornflower Жыл бұрын
Damn. it feels illegal to be this early. Great content!
@jacknguyen4014
@jacknguyen4014 Жыл бұрын
Instead of display none you can use opacity and pointer event none and keep using the transition for better performance; Also you can use aria-hidden in the navigation when hidden. BTW great video!
@eruryuzaki6505
@eruryuzaki6505 Жыл бұрын
Nit: Let's profile that before jumping into optimization. Sadly the proposed solution for faking the `display: none` does not account for the keyboard navigation.
@stevenmuncy491
@stevenmuncy491 Жыл бұрын
Good catch on the accessibility. Thanks.
@D7460N
@D7460N Жыл бұрын
So very very important!
@chukwuemekacelestine2286
@chukwuemekacelestine2286 Жыл бұрын
This is very informative, thank you very much.
@EpicMakesEverythingBetter
@EpicMakesEverythingBetter Жыл бұрын
I have 's for breaking, lunch and dinner, man. Don't take away my bread!
@PYXLDesign
@PYXLDesign Жыл бұрын
This is an awesome video! Very informative, and the display:block solutions is a good one. I normally would use aria-hidden or remove all the tab-index on the links ;) This solution is much cleaner IMO thanks for sharing!
@PawelGrzelak
@PawelGrzelak Жыл бұрын
Seriously great tut
@wormius51
@wormius51 Жыл бұрын
This is just insane. I can see how solving invisible problems is important. But this is nuts. How many websites actually follow this kind of design?
@SAIEN333
@SAIEN333 Жыл бұрын
Ustaad 🙏🏽
@tomasnovellino5980
@tomasnovellino5980 Жыл бұрын
The issue with the event listener for "animation closed" is that you are creating them everytime you click the button. Even with the once is still there. Other option is to create the listener outside the function so it will only create once. Also if you pass the event as a parameter you might get context on the trigger so the same listener can be used for multiple closing signals
@bellabear653
@bellabear653 Жыл бұрын
Thank you this was great!
@RaphaelSanchez
@RaphaelSanchez Жыл бұрын
very elegant solution
@mahadevovnl
@mahadevovnl Жыл бұрын
I've reviewed hundreds of job applications over the years, and the times I see front-end developers not having the faintest idea what W3C standards are is astounding. Sometimes I see them nesting and together, and similar nastiness. So many people simply don't understand that conflicting interactive elements shouldn't be nested. Many of them don't know there are rules to HTML, and many of them underestimate HTML. I mean, kudos to them for not ONLY using , but when you use semantics... use them correctly.
@narnigrin
@narnigrin Жыл бұрын
This is probably something that needs to be taught more, tbh. It's now 20+ years since I began to learn HTML and I was lucky enough to learn it from notes and literature that happened to talk at least a bit about a11y, but I get the sense most people that learn HTML in, say, university courses or whatever (1) just don't care that much about HTML in the first place and (2) don't really seem to ever get told that a11y is something you can improve in concrete ways if you write your code right. The 'move fast and break things' culture that I see in a lot of startuppy Facebook-wannabe circles doesn't help either, of course.
@KoOcie92
@KoOcie92 Жыл бұрын
@@narnigrin (1) - It is too easy to blame university courses or whatever as those have very limited time to actually teach those things. (2) - Telling someone that writing code right will improve a11y won't magically make theme writing the code right ;) I personally think that at the end of the day nothing really replace work experience and as long as people are willing to learn and peers are willing to share their experience, HTML semantics shouldn't be a deal breaker
@naveenramkumar6123
@naveenramkumar6123 Жыл бұрын
OMG I've made this mistake soo much, I am changing everything RIGHT NOW!
@thecoderabbi
@thecoderabbi Жыл бұрын
Haha!
Avoid These 5 Awful CSS Mistakes
20:42
Kevin Powell
Рет қаралды 190 М.
The Most Important Skill You Never Learned
34:56
Web Dev Simplified
Рет қаралды 172 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 104 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 25 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 54 МЛН
Avoid these 5 beginner CSS mistakes
21:38
Kevin Powell
Рет қаралды 75 М.
Getting started with web accessibility with Ashlee Boyer
30:29
Kevin Powell
Рет қаралды 53 М.
Learn CSS Flexbox in easy way
5:05
cssiseasy
Рет қаралды 10 М.
Async Rust Is A Bad Language | Prime Reacts
28:46
ThePrimeTime
Рет қаралды 89 М.
Learn flexbox the easy way
34:04
Kevin Powell
Рет қаралды 687 М.
Container Queries are going to change how we make layouts
24:24
Kevin Powell
Рет қаралды 171 М.
The Only Unbreakable Law
53:25
Molly Rocket
Рет қаралды 318 М.
The 6 most important CSS concepts for beginners
28:58
Kevin Powell
Рет қаралды 151 М.
I learned to code from scratch in 1 year. Here's how.
41:55
Thomas Frank
Рет қаралды 369 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 104 МЛН