Select Page

Author: admin

Keyboard-Only Focus Styles

Like Eric Bailey says, if it’s interactive, it needs a focus style. Perhaps your best bet? Don’t remove the dang outlines that focusable elements have by default. If you’re going to rock a button { outline: 0; }, for example, then you’d better do a button:focus { /* something else very obvious visually */ }. I handled a ticket just today where a missing focus style was harming a user who relies on visual focus styles to navigate the web. But those focus styles are most useful when tabbing or otherwise navigating with a keyboard, and less so when they are triggered by a mouse click. Now we’ve got :focus-visible! Nelo writes: TLDR; :focus-visible is the keyboard-only version of :focus. Also, the W3C proposal mentions that :focus-visible should be preferred over :focus except on elements that expect a keyboard input (e.g. text field, contenteditable). (Also see his article for a good demo on why mouse clicking and focus styles can be at odds, beyond a general dislike of fuzzy blue outlines.) Browser support for :focus-visible is pretty rough: This browser support data is from Caniuse, which has more detail. A number indicates that browser supports the feature at that version and up. Desktop Chrome Opera Firefox IE Edge Safari No No 4* No No No Mobile / Tablet iOS Safari Opera Mobile Opera Mini Android Android Chrome Android Firefox...

Read More

What’s New in Swift 4.2?

The second update release to Swift of 2018, Swift 4.2 introduces some great improvements to the language. Read this post to learn how they can help you write even better code. Included in this version’s list of improvements: SE-0194: Adds the CaseIterable protocol to automatically generate an array of all the possible enum cases. SE-0195: Dynamic member lookup syntactical sugar. SE-0196: New compiler directives #warning and #error. SE-0197: New removeAll(where:) method to perform an optimized in-place filter for collections. SE-0199: New toggle() method to easily toggle/flip boolean values. SE-0202: New native random number generator. SE-0206: New Hasher type to improve and simplify conformance to the Hashable protocol. SE-0207: New allSatisfy() method to verify all...

Read More

11 Best Courses to Learn to Create a WordPress Theme or Plugin

Do you want to take your WordPress skills to the next level and learn to create your own themes and plugins? Well, you’ve come to the right place. I’ve compiled 11 of the best WordPress coding courses on Envato Tuts+ to help you do just that. Take a look and be inspired.  1. Designing for WordPress Any great product starts with great design. This is as true for building a house as it is for building a WordPress theme. That’s why the first course on our list is Designing for WordPress. Designing for WordPress introduces learners to the fundamentals...

Read More

The “C” in CSS: The Cascade

Following up from Geoff’s intro article on The Second “S” in CSS, let’s now move the spotlight to the “C” in CSS — what we call the Cascade. It’s where things start to get messy, and even confusing at times. Have you ever written a CSS property and the value doesn’t seem to work? Maybe you had to turn to using !important to get it going. Or perhaps you resorted to writing the CSS inline on the element in the HTML file. Ack, inline! Speaking of inline styles, have you wondered why SVG editors use them instead of a...

Read More

A Bunch of Options for Looping Over querySelectorAll NodeLists

A common need when writing vanilla JavaScript is to find a selection of elements in the DOM and loop over them. For example, finding instances of a button and attaching a click handler to them. const buttons = document.querySelectorAll(".js-do-thing"); // There could be any number of these! // I need to loop over them and attach a click handler. There are SO MANY ways to go about it. Let’s go through them. forEach forEach is normally for arrays, and interestingly, what comes back from querySelectorAll is not an array but a NodeList. Fortunately, most modern browsers support using forEach on NodeLists anyway. buttons.forEach((button) => { button.addEventListener('click', () => { console.log("forEach worked"); }); }); If you’re worried that forEach might not work on your NodeList, you could spread it into an array first: [...buttons].forEach((button) => { button.addEventListener('click', () => { console.log("spread forEach worked"); }); }); But I’m not actually sure if that helps anything since it seems a bit unlikely there are browsers that support spreads but not forEach on NodeLists. Maybe it gets weird when transpiling gets involved, though I dunno. Either way, spreading is nice in case you want to use anything else array-specific, like .map(), .filter(), or .reduce(). A slightly older method is to jack into the array’s natural forEach with this little hack: [].forEach.call(buttons, (button) => { button.addEventListener('click', () => { console.log("array forEach worked"); }); });...

Read More
000webhost logo