Archive

Archive for February, 2021

Front of the Front / Back of the Front

February 16th, 2021 No comments

People really latched onto Brad’s framing. And for good reason. Front-end development has gotten so wide scoping that there are specialists inside of it. Two years ago, I cut it down the middle and now Brad is putting a point on that here, saying he has actual clients who have shifted their hiring strategy away from full-stack and toward these exact distinctions. Nice.

Brad shoots for a simple distinction:

A succinct way I’ve framed the split is that a front-of-the-front-end developer determines the look and feel of a button, while a back-of-the-front-end developer determines what happens when that button is clicked.

Part of me loves the clarity there. And part of me like But! But! Wait! I’m a front-of-the-front kinda guy, but I totally deal with what happens on click. I’m a state updating machine over here. I’ll fire off that GraphQL mutation myself, thankyouverymuch. I friggin own that onClick.

And yet, I still don’t feel back-of-the-front at all. I can’t set up that GraphQL API or troubleshoot it. I don’t know what the security implications of the network request is. I don’t know if the query I wrote will be performant or not, nor where to look at a graph to find out. I think I’d draw the line in a slightly different place than Brad, but he knows that. He’s flexible here:

The line between front-of-the-front-end and back-of-the-front-end can be fuzzy and varies greatly from developer to developer. It’s totally possible that one developer might be able to perform many tasks across the front-end spectrum. But it’s also worth pointing out that’s not super common.

That’s why the term full-stack isn’t my favorite. I bet an awful lot of developers have skill sets on both sides of the “great divide”, which I think makes it feel like you’re full-stack when it’s more likely you’re cross-stack. Full-stack makes me feel like you’re deeply knowledgeable about literally everything across not only the front-end spectrum but back-end too. Brad says that’s not common and I’ll up that and say it’s downright rare.

My main regret about trying to cut front-end development in half is that it’s too clean of a metaphor for a messy thing.

I live in Bend, Oregon where outdoor hobbies are like the main thing. You don’t really go up and ask people if they are a summer sports person or a winter sports person because they are almost always both. But one person might be into snowshoeing, downhill skiing, and day hiking, where the next person might be into paddle boarding, nordic skiing, and mountain biking. So I had this idea of Bend Name Tags where it lists all the outdoor hobbies and you write your name and then circle all the ones that you’re into.

It should almost be like that with front-end development. You write your name and then list out all the things you’re into. Me? I like HTML, CSS, JavaScript, Build Processes, Design, React, WordPress, with a dash of Accessibility, Performance, and Copywriting. What does that make me? Me.

Direct Link to ArticlePermalink


The post Front of the Front / Back of the Front appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

How to Create a Shrinking Header on Scroll Without JavaScript

February 16th, 2021 No comments

Imagine a header of a website that is nice and thick, with plenty of padding on top and bottom of the content. As you scroll down, it shrinks up on itself, reducing some of that padding, making more screen real estate for other content.

Normally you would have to use some JavaScript to add a shrinking effect like that, but there’s a way to do this using only CSS since the introduction of position: sticky.

Let me just get this out there: I’m generally not a fan of sticky headers. I think they take up too much of the screen’s real estate. Whether or not you should use sticky headers on your own site, however, is a different question. It really depends on your content and whether an ever-present navigation adds value to it. If you do use it, take extra care to avoid inadvertently covering or obscuring content or functionality with the sticky areas — that amounts to data loss.

Either way, here’s how to do it without JavaScript, starting with the markup. Nothing complicated here — a

with one descendant

which, intern, contains the logo and navigation.

<header class="header-outer">
  <div class="header-inner">
    <div class="header-logo">...</div>
    <nav class="header-navigation">...</nav>
  </div>
</header>

As far as styling, we’ll declare a height for the parent

(120px) and set it up as a flexible container that aligns its descendant in the center. Then, we’ll make it sticky.

.header-outer {
  display: flex;
  align-items: center;
  position: sticky;
  height: 120px;
}

The inner container contains all the header elements, such as the logo and the navigation. The inner container is in a way the actual header, while the only function of the parent

element is to make the header taller?so there’s something to shrink from.

We’ll give that inner container, .header-inner, a height of 70px and make it sticky as well.

.header-inner {
  height: 70px;
  position: sticky;
  top: 0; 
}

That top: 0? It’s there to make sure that the container mounts itself at the very top when it becomes sticky.

Now for the trick! For the inner container to actually stick to the “ceiling” of the page we need to give the parent

a negative top value equal to the height difference between the two containers, making it stick “above” the viewport. That’s 70px minus 120px, leaving with with — drumroll, please — -50px. Let’s add that.

.header-outer {
  display: flex;
  align-items: center;
  position: sticky;
  top: -50px; /* Equal to the height difference between header-outer and header-inner */
  height: 120px;
}

Let’s bring it all together now. The

slides out of frame, while the inner container places itself neatly at the top of the viewport.

CodePen Embed Fallback

We can extend this to other elements! How about a persistent alert?

CodePen Embed Fallback

While it’s pretty awesome we can do this in CSS, it does have limitations. For example, the inner and outer containers use fixed heights. This makes them vulnerable to change, like if the navigation elements wrap because the number of menu items exceeds the amount of space.

Another limitation? The logo can’t shrink. This is perhaps the biggest drawback, since logos are often the biggest culprit of eating up space. Perhaps one day we’ll be able to apply styles based on the stickiness of an element…


The post How to Create a Shrinking Header on Scroll Without JavaScript appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Maximally optimizing image loading for the web in 2021

February 16th, 2021 No comments

Malte Ubl’s list for:

8 image loading optimization techniques to minimize both the bandwidth used for loading images on the web and the CPU usage for image display.

  1. Fluid width images in CSS, not forgetting the height and width attributes in HTML so you get proper aspect-ratio on first render.
  2. Use content-visibility: auto;
  3. Send AVIF when you can.
  4. Use responsive images syntax.
  5. Set far-out expires headers on images and have a cache-busting strategy (like changing the file name).
  6. Use loading="lazy"
  7. Use decoding="async"
  8. Use inline CSS/SVG for a blurry placeholder.

Apparently, there is but one tool that does it all: eleventy-high-performance-blog.

My thoughts:

  • If you are lazy loading, do you really need to do the content-visibilty thing also? They seem very related.
  • Serving AVIF is usually good, but it seems less cut-and-dry than WebP was. You need to make sure your AVIF version is both better and smaller, which feels like a manual process right now.
  • The decoding thing seems weird. I’ll totally use it if it’s a free perf win, but if it’s always a good idea, shouldn’t the browser just always do it?
  • I’m not super convinced blurry placeholders are in the same category of necessary as the rest of this stuff. Feels like a trend.

Direct Link to ArticlePermalink


The post Maximally optimizing image loading for the web in 2021 appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

The web didn’t change; you did

February 16th, 2021 No comments

I love this piece from Remy Sharp where he argues that the web didn’t get more complicated over the last 20 years, despite what we might think:

Web development did not change. Web development grew. There are more options now, not different options.

Browsers have become more capable and still work with web pages built over 20 years ago.

[…] The web really didn’t change. It really didn’t become complex. The web development process is not one single path. There is simply more choice and more options.

Remy argues that the web is only really as complex as we make it and, when we choose an enormous framework for a small problem, it’s us that’s choosing the complexity. We really don’t have to build a website with the latest and greatest tools if we’re familiar with the old stuff and there’s no shame in using float over flexbox, if that works for you.


There’s a lot of ego in web design, and there’s a lot of folks out there bashing others for using the “incorrect” tools. But here’s the secret when it comes to making website: there are no perfect tools, and there’s no perfect way to build a website. That sucks, but it’s also exciting because we get to figure it all out; nothing is set in stone.

For example: I use Sass all the time for side projects and I know for a fact that a lotta folks would scoff at that. There’s emotion and Tachyons! There’s plain CSS! There’s PostCSS! But hey: I like Sass for a few things. I like the power it gives me and I like that I’m familiar with it. That doesn’t stop me from reaching for emotion in my day job or experimenting with something new when it comes along.

But old tech isn’t bad just because it’s old. And new tech isn’t good just because it’s new. You can see that sentiment playing out in the comment thread of Chris’ “Front-End Dissatisfaction (and Backing Off)” post.

Direct Link to ArticlePermalink


The post The web didn’t change; you did appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Netlify

February 16th, 2021 No comments

High five to Netlify for the ? sponsorship. Netlify is a great place to host your static (or not-so-static!) website because of the great speed, DX, pricing, and feature set. I’ve thought of Netlify a bunch of times just in the past week or so, because either they release something cool, or someone else is writing about it.


The post Netlify appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

LinkedIn Hashtags For Business: Check Everything Right Here!

February 16th, 2021 No comments

Social media is used for professional purposes these days; they use social platforms such as Facebook, Twitter, Linkedin, or Instagram.

But not a single platform works like Linkedin. LinkedIn is the most popular and professional platform that enables business vendors to connect and socialize with similar-minded people.

Many people have career aspects. As social media for professionals, Linkedin is a reliable platform among online marketers, HR departments, business owners, content creators, and many professional people, helping them develop their network. Using LinkedIn for business promotion and marketing has become quite common. Vendors use hashtags to reach the targeted business goal in a short duration of time.

Learn Top Tips to Use Linkedin Hashtags for Your Business!

As of 2020, Linkedin has around 170 million users in the U.S. alone. The country by the leading market of professional job networking service with a runner-up. About 68 million users use Linkedin in India.

LinkedIn is a professional networking service that helps job seekers to post their CVs while enabling recruiters to post job ads to search for prospective candidates. Besides this, businesses also use social platforms as promotional platforms to achieve their targeted goals in no time.

Linkedin hashtags are a powerful tool to use when you are trying to build your brand. Similarly, on other social media hashtags, Linkedin using is the best way to reach a larger audience with targeted interest. Hence it becomes essential for them to know which Linkedin hashtags you can use with your content to build your brand and network.

Businesses can use trendy Linkedin hashtags in their posts. Such hashtags are widely used by businesses to support their post and reach maximum post expectations. Ultimately, it also helps you to present your message in front of the right audience. But one common question which strikes in their mind is how

So in this post, we share some of the best trending LinkedIn hashtags you better use in your next posts. Such hashtags are used by professionals and support your post to reach its maximum post expectations. It helps you to present your message in front of the right audience. But, the first question is:

  • Do Hashtags Work on Linkedin?
  • What’s value of using LinkedIn hashtags?
  • When should I use hashtags on LinkedIn?
  • How do I select the hashtags for my posts?
  • Should I participate in trending hashtag topics?

Many other questions arise in the individual mind. Businesses can use various hashtags to post on Linkedin and drive more traffic on the platform.

General Linkedin Hashtags

#Mindfulness
#Productivity
#Tips
#Innovation
#Management
#Motivation
#Leaderships
#Creativity
#GettingThingsDone

Social Media & Marketing

#Branding
#KnowYourSocial
#SocialNetworking
#SocialMedia
#SocialMediaMarketing
#SocialMediaAdvertising
#DigitalMarketing
#ContentMarketing
#OnlineAdvertising
#Marketing
#Sales

Small Business

#Business
#BusinessInteligence
#SmallBusiness
#Entrepreneur
#Entrepreneurship
#SocialEntrpreneurship

Other Networking Tags

#Networking
#LetsWork
#WhatInspiresMe
#ONO
#PersonalDevelopment
#PersonalBranding

Linkedin is at the top of an online community for professional and business vendors. And yes, Linkedin hashtags are a powerful way to promote your post and improve your business to the maximum exposure. You can use Linkedin hashtags to push the content to a broader audience using the Linkedin hashtag. When used wisely, relevant hashtags helps to boost post impressions and engagements in return.

Linkedin Hashtags: Why to Use it?

Suppose you’re regularly sharing Linkedin content and not using the hashtag. Explore the reasons why you need to use LinkedIn hashtags for your business.

  • Hashtags are like grouping that supports your Linkedin post to describe the relevant topic and subject.
  • Hashtags are tools, just like keywords that help you improve your post to attain organic impressions and clicks on Linkedin.
  • Use popular hashtags to acquire post engagements on trending subjects.
  • Your profile or page gets interaction from the audience due to adding the right hashtags.
  • Trending Linkedin hashtags are a fantastic marketing tool; you should not ignore them if you want to promote or market your business.
  • Post with relevant hashtags promotes a message in front of the right audience.
  • Post relevant hashtags in front of the right audience.

Do not limit the Linkedin hashtags to get more post engagements. With the trendy hashtags, you can even expand your network quickly without any hassle. Businesses who focus on growing their connections at Linkedin helps them to get more connections at Linkedin. By interacting actively with those who comment, like, and share your posts. Strengthening your professional network enables you to grow your brand to a great extent.

Quick Tips to Use LinkedIn Hashtags

Hashtag Relevancy

Make sure Linkedin hashtags that you use are relevant to your post content. Suppose your post is on the Netflix business model then use hashtags accordingly. Take hashtags as a folder of related content grouping together. Use hashtags that fit your specific business categories and describe your post topics as well.

Research Linkedin Hashtags

Before using Linkedin hashtags without understanding the perfect use and finding the best one for your post, you should search for it. Search for the best hashtags on Linkedin finds their popularity as well as relevance to your post.

Develop Effective Hashtag Strategy

Like promoting and publishing the regular post on Linkedin, you need to have some hashtags related to post-delivery. Plan everything and use the Linkedin hashtags that are appropriate for your business. Also, diversify into low, high, or competitive hashtags.

Use Limited Hashtags

There is no limitation on how many hashtags to use in posts. But Linkedin hashtags use is optimal; experts advise using up to 3 to 5 hashtags to your Linkedin business post. Use topical and relevant hashtags suggested by the platform for your topic.

Follow & Discover More Hashtags

LinkedIn offers you popular hashtags to use for your business post. You can search for industry-specific hashtags such as sales, marketing, or any other hashtags of your choice. Discover more ideas and view more topical hashtags that can be used for your brands’ post.

Learning from Leaders

If you’re looking to start with Linkedin promotion and the best hashtags to use with it, then you should find your leaders and competitions. Check the content they’re posting with attractive and engaging hashtags. Try to learn from them; these can provide you with a clear idea about which content type to create and which hashtags to apply.

Where Are You Allowed to Add Hashtags to Your Linkedin In Account?

  • Graphical & textual content forms
  • Summary of your profile
  • LinkedIn articles
  • Company page
  • Status updates
  • The comment section of others others’ posts and status

Final Notes

Using Hashtags on your Linkedin account is one of the best ways to grow your business reach and visibility if you are a new audience. If your post relates to a particular business, they prefer to use such relevant hashtags and business-specific hashtags.

Apart from using Linkedin hashtags, it would help if you used industry-specific hashtags related to your content. Make sure to hashtags relevant, but understand that the overuse of the hashtags will look spammy. Make sure to use natural hashtags with your pose; you can use 3 to 5 hashtags in a single post to drive more traffic for your business.

You can use more hashtags, but avoid using lots of hashtags in the post. Not using hashtags can shorten your post to its full potentials. Hence plan and perform research to find trendy and useful hashtags for marketing purposes.

Categories: Others Tags:

Variable Font Reveals The Full Horror of The Climate Crisis

February 16th, 2021 No comments

Finnish newspaper Helsingin Sanomat has developed a variable font, that is designed to make the effects of human-driven climate change tangible in a simple graphical form.

Whereas most type designers use variable font techniques to embed a range of weights in a single font file, the team — lead by Helsingin Sanomat’s art director Tuomas Jääskeläinen, and typographer Eino Korkala — used the technique to “melt” the typeface.

In the design process, we tried out countless letter shapes and styles, only to find that most of them visualized the disaster right in the earliest stages of the transformation. That’s something we wanted to avoid because unlike a global pandemic, climate change is a crisis that sneaks up on us.

— Tuomas Jääskeläinen

The default typeface represents the volume of Arctic sea ice in 1979 (when records began). It’s a rather beautiful, chiseled, chunky sans-serif, with cut-aways that open up counters to give it a modern appeal. As you move through the years towards 2050 the shapes appear to melt away, to the point that they’re barely legible.

Set the scale to 2021 and you’ll see an already dramatic loss of Arctic sea ice, and the resulting desalination of the ocean.

As depressing as these outlines are, they aren’t an estimate. The typeface’s outlines precisely match real data — there was an unexpected uptick in Arctic sea ice in 2000, and that’s reflected in the font.

The historical data is taken from the NSIDC (The US National Snow and Ice Data Center) and the predictive data comes from the IPCC (The Intergovernmental Panel on Climate Change).

We hope that using the font helps people see the urgency of climate change in a more tangible form – it is a call for action.

— Tuomas Jääskeläinen

You can download the font for free, for personal or commercial work.

Source

The post Variable Font Reveals The Full Horror of The Climate Crisis first appeared on Webdesigner Depot.

Categories: Designing, Others Tags:

Top eCommerce Platforms to Launch An Online Furniture Rental Marketplace in 2021

February 16th, 2021 No comments

Online software solutions automate intricate furniture rental operations and assist in resolving numerous problems like complex inventory management, asset tracking, product maintenance, and unconventional pricing models.

These solutions are required by various types of entrepreneurs and business owners looking forward to releasing a furniture rental eCommerce store or marketplace.

Correspondingly, the number of rental businesses in the furniture industry is also rising because of decreasing consumer preference for ownership, low maintenance cost in the rental economy, and the frequently changing designs and trends. The working population frequently changing cities also demands flexible furnishing options that the product ownership model can’t always fulfill at a reasonable cost. Thus, in the end, convenient furniture renting remains the most favorable option.

Top Players in Online Furniture Rental Industry

The furniture rental industry is saturated with several incumbents. However, only a few of them have earned a name for conducting business operations via online channels. The incumbents leading the online furniture rental industry are listed in the graphic below:

Software Solutions to Launch a Functional Furniture Rental Marketplace

Entrepreneurs interested in entering the online furniture rental industry require a website, so do the existing furniture rental businesses for undergoing digital transformation. We have curated a list of the top 5 rental solutions with which one can develop a captivating furniture rental website. (View the attached table for basic comparison.)

1. Yo!Rent

Yo!Rent is a fully-customizable white-label rental eCommerce software. It’s available in two variants – multi-vendor and single vendor to meet the unique requirements of rental businesses. The software is perfectly suited to build online furniture rental, dress rental, equipment rental, vehicle rental, party supply rental websites. Yo!Rent also offers multilingual and multi-currency functionality. The team behind Yo!Rent also offers 1-year of free technical support in case of any issues and problems with the software.

Features:

  • Enable Rent/Sell options
  • Real-time stock availability
  • Smart review management system
  • Affiliate management
  • Multiple revenue streams
  • Free Integration of 15 Payment Gateways
  • Ratings and reviews management
  • Multipurpose file attachments
  • Minimum rental duration settings
  • Compare products feature
  • Income calculator for vendors

Pros: Free instant demo, 1-year free technical support, unlimited listings
Cons: Readymade templates are not available
Suitable for: Startups, SMEs, Agencies, Enterprises
Website: https://www.yo-rent.com/furniture-rental-marketplace-platform.html

2. Sharetribe

Sharetribe is an online marketplace solution that’s available in two packages viz. ShareTribe Go and ShareTribe Flex. The packages are perfectly tailored to meet the varied demands of a wide range of businesses. ShareTribe is also fully customizable and has a recurrent pricing model, which makes it suitable for business enthusiasts experimenting with digital touchpoints and sales channels.

Features:

  • Renting & selling
  • Pre-built templates
  • Catalog management
  • Order management
  • Multistore management
  • Category management
  • Global payment option
  • Supports multiple languages
  • Customizable transaction process

Pros: Affordable, free version available
Cons: Limited number of users and categories
Suitable for: Startups, Entrepreneurs, SMEs
Website: https://www.sharetribe.com/

3. Arcadier

Arcadier is an online marketplace solution to launch an eCommerce website. It is simple to use and comes with optimized themes and interface. Arcadier also has a plugins marketplace to tailor the design and functionality of your website. At the time of publishing this blog, all plugins in the marketplace are free of cost, which makes Arcadier quite affordable in terms of adding minor functionality and features.

Features:

  • Multilingual
  • Themes and templates available
  • Social login
  • SEO friendly
  • Review management
  • Catalog management
  • Category management
  • Add-on services
  • Calendar scheduling option

Pros: Easy to start, no coding required, user friendly
Cons: Limited customizations, costly to scale your website
Suitable for: Startups, Entrepreneurs, SMEs, Large Businesses
Website: https://www.arcadier.com/

4. ExlCart

ExlCart is a customizable online marketplace software that caters to the varied needs of B2B and B2C businesses. The software is tailored to build eCommerce, groceries, restaurants, and rental marketplaces. Using ExlCart, business owners can launch a fast and responsive furniture rental marketplace. ExlCart supports unlimited product listings and comes with several add-on options.

Features:

  • Support multiple languages, currency, payment options
  • Advanced filters
  • Returns management
  • Inventory management
  • Subscription management
  • Delivery management
  • Multi-store management
  • Country and city management
  • Advanced search filters
  • Customer and vendor verification

Pros: Free installation, ease of use
Cons: Limited customization, difficult onboarding process, only 3 to 6 months of technical support
Suitable for: Startups, SMEs, Agencies, Enterprises
Website: https://www.exlcart.com/

5. EZRentOut

EZRentOut is an equipment rental software that focuses on ease of use and customizability to improve the end-user experience. The platform specifically caters to industries such as construction and tools rental, party and event rental, IT rental, and sports rentals. EZRentOut offers advanced features for booking, invoicing, and inventory management. It is also one of the few marketplace software that comes with barcode and QR code scanner options.

Features:

  • Order management
  • Import/export information via excel files
  • Vendor management
  • Availability Based Ordering
  • Payment & order tracking
  • Consolidated invoicing
  • Built-in invoice designer
  • Late Fee Calculation

Pros: Ease to use, 15 days free trial, customizable, flexible pricing plans
Cons: Caters primarily to the equipment rental businesses
Suitable for: Startups, SMEs, Enterprises
Website: https://www.ezrentout.com/

Conclusion

The aforementioned online furniture rental solutions do share some common features and functionalities. To refine the list as per your preferences, you can take the customer support and pricing model into considerations. Reaching out to the respective sales teams of these solutions will provide you with complete information regarding these products. Demos and online reviews of the software are also reliable sources of information to help you finalize your decision.

Categories: Others Tags:

Using AbortController as an Alternative for Removing Event Listeners

February 15th, 2021 No comments

The idea of an “abortable” fetch came to life in 2017 when AbortController was released. That gives us a way to bail on an API request initiated by fetch() — even multiple calls — whenever we want.

Here’s a super simple example using AbortController to cancel a fetch() request:

const controller = new AbortController();
const res = fetch('/', { signal: controller.signal });
controller.abort();
console.log(res); // => Promise(rejected): "DOMException: The user aborted a request"

You can really see its value when used for a modern interface of setTimeout. This way, making a fetch timeout after, say 10 seconds, is pretty straightforward:

function timeout(duration, signal) {
  return new Promise((resolve, reject) => {
    const handle = setTimeout(resolve, duration);
    signal?.addEventListener('abort', e => {
      clearTimeout(handle);
      reject(new Error('aborted'));
    });
  });
}

// Usage
const controller = new AbortController();
const promise = timeout(10000, controller.signal);
controller.abort();
console.log(promise); // => Promise(rejected): "Error: aborted"

But the big news is that addEventListener now accepts an Abort Signal as of Chrome 88. What’s cool about that? It can be used as an alternate of removeEventListener:

const controller = new AbortController();
eventTarget.addEventListener('event-type', handler, { signal: controller.signal });
controller.abort();

What’s even cooler than that? Well, because AbortController is capable of aborting multiple cancelable requests at once, it streamlines the process of removing multiple listeners in one fell swoop. I’ve already found it particularly for drag and drop.

Here’s how I would have written a drag and drop script without AbortController, relying two removeEventListener instances to wipe out two different events:

// With removeEventListener
el.addEventListener('mousedown', e => {
  if (e.buttons !== 1) return;

  const onMousemove = e => {
    if (e.buttons !== 1) return;
    /* work */
  }

  const onMouseup = e => {
    if (e.buttons & 1) return;
    window.removeEventListener('mousemove', onMousemove);
    window.removeEventListener('mouseup', onMouseup);
  }

  window.addEventListener('mousemove', onMousemove);
  window.addEventListener('mouseup', onMouseup); // Can't use `once: true` here because we want to remove the event only when primary button is up
});

With the latest update, addEventListener accepts the signal property as its second argument, allowing us to call abort() once to stop all event listeners when they’re no longer needed:

// With AbortController
el.addEventListener('mousedown', e => {
  if (e.buttons !== 1) return;

  const controller = new AbortController();

  window.addEventListener('mousemove', e => {
    if (e.buttons !== 1) return;
    /* work */
  }, { signal: controller.signal });

  window.addEventListener('mouseup', e => {
    if (e.buttons & 1) return;
    controller.abort();
  }, { signal: abortController.signal });
});
CodePen Embed Fallback

Again, Chrome 88 is currently the only place where addEventListener officially accepts an AbortSignal. While other major browsers, including Firefox and Safari, support AbortController, integrating its signal with addEventListener is a no go at the moment… and there are no signals (pun sorta intended) that they plan to work on it. That said, a polyfill is available.


The post Using AbortController as an Alternative for Removing Event Listeners appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Beautiful accessibility with Floating Focus

February 15th, 2021 No comments

Imagine if your :focus styles animated from element to element as you tab through a site. Like the focus ring up and flew across the page to the next element. The spirit of it is similar to smooth scrolling: it’s easier to understand what is happening when movement accompanies the change¹. Rather than scrolling (or focus change) being an instant jump, movement guides you to the new location.

Guido Bouman thought this would be good for accessibility and looked at some options (e.g. Flying Focus) but ultimately created their own, Floating Focus:

After this exploration we had a good idea of what a good focus state needed. It needs to have a high contrast but not impair readability of the underlying components. It has to guide the user to the next focus target with a form of transition. And it only needs to show for users benefitting from the focus outline.

We’ve covered a similar thing before in 2019 when Maurice Mahan FocusOverlay.

Here’s what I wrote about it back then:

  • It’s a neat effect.
  • I can imagine it being an accessibility win since, while the page will scroll to make sure the next focused element is visible, it doesn’t otherwise help you see where that focus has gone. Movement that directs attention toward the next focused element may help make it more clear.
  • I can imagine it being harmful to accessibility in that it is motion that isn’t usually there and could be surprising and possibly offputting.
  • If it “just works” on all my focusable elements, that’s cool, but I see there are data attributes for controlling the behavior. If I find myself needing to sprinkle behavior control all over my templates to accommodate this specific library, I’d probably be less into it.

In that article, I covered a conditional loading idea for not loading this if prefers-reduced-motion was set to reduce. These days, you might do a conditional ES Modules import.

Don’t take any of this as advice that this movement-based focus stuff is 100% good for accessibility. I don’t feel qualified to make that determination. It is interesting though.

  1. This reminds me of “transitional interfaces” as well. Movement can really help make clear what is happening in a UI.

Direct Link to ArticlePermalink


The post Beautiful accessibility with Floating Focus appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags: