Technology News

Add-to-Calendar Button UI Widget

A useful little UI widget thingy here from Jens Kuerschner. Click the add-to-calendar button, get a list of calendar apps, the user selects which one they actually use, and they get what they need for that calendar. Could be a specialized URL they get sent to, or even an .ics file that gets downloaded.

Add-to-Calendar Button banner from the GitHub repo.

It’s pretty easy to use. Here’s me using the library off of CDNs for both the JavaScript and CSS:

Let’s do a thought dump!

The configuration as “a big chunk of JSON sitting in the HTML as a string” is a little weird to me.

I see the hack where it uses display: none; on the parent to hide that text from rendering, but I think I like the setup where that’s put into a <script type="application/ld+json"> tag much better.

The fallback for these, assuming JavaScript doesn’t load or execute correctly, is nothing.

I’m torn there. Maybe it’s fine? This seems like bonus functionality anyway. And it’s presumably sitting next to actual content about the event that a user could add to their calendar however they want. I certainly wouldn’t want to see non-interactive text saying “Add to Calendar” because that’s worse than nothing. But maybe there could be some kind of generically useful hyperlink that can act as the fallback?

An add-to-calendar button seems like a good use case for a web component.

Why not an <add-to-calendar> element? That way, the script and styles could be isolated and probably a bit safer for general usage. But how do you do JSON config for a web component? Maybe every single property becomes an attribute? Maybe something like: <add-to-calendar options="Apple, Google", startTime="10:15" />

The biggest problem to address up front, though, is that it looks like the interactive element is a <div> with all JavaScript handlers.

You can’t Tab to it at all, so there is no way to activate it. There are no CSS states — it’s all classes updated by JavaScript. I’d definitely get this thing updated to be a <button>. And maybe it’s good timing to make use of a <dialog> element for the options and use dialog::backdrop for that fancy backdrop-filter background.

Just some constructive criticism, Jens — keep on keepin’ on.

Direct Link →

SpaceX and our space junk problem
5 Ways To Improve Your Webinar Content To Increase Sales

Related Articles

Maybe Nothing

maybe-nothing
What’s one thing we can do to make our site better? Maybe nothing at all! Our websites keep getting bigger and bigger! When we have a team with so many…

The `ping` attribute on anchor links

the-ping-attribute-on-anchor-links
This post is part of my Today I learned series in which I share all my learnings regarding web development. A PR on the MDN compatibility data repository caught my…

Passkeys: What the Heck and Why?

Passkeys: What the Heck and Why?
These things called passkeys sure are making the rounds these days. They were a main attraction at W3C TPAC 2022, gained support in Safari 16, are finding their way into macOS and iOS, and are…

Flight delayed? Blame a spaceship.

flight-delayed-blame-a-spaceship
You can typically blame an airline flight delay on a handful of usual suspects, like bad weather, mechanical issues, and traffic on the tarmac. But thanks to the rise of…

Best Ways to Negotiate Terms with Zomato

best-ways-to-negotiate-terms-with-zomato
Best-Ways-to-Negotiate-Terms-with-Zomato In this digital world, food aggregators like Zomato provide answers to all food-related queries in the shortest span of time. The success of restaurants depends upon the reviews that…

How to Build Your First Custom Svelte Transition

how-to-build-your-first-custom-svelte-transition
The Svelte transition API provides a first-class way to animate your components when they enter or leave the document, including custom Svelte transitions. By default, the transition directive uses CSS…

4 Ways Marketing and Customer Service Can Work Together

4-ways-marketing-and-customer-service-can-work-together
In 2020, cross-departmental collaboration is not optional anymore. It is a necessity for any small business wanting to provide consistent and user-oriented customer experiences.  One such example is the collaboration…