This code makes any element with data-copy-url
copy the current page URL when clicked and adds a class to the button for 2.5s. Allowing for some fun confirmation animations with css.
1document.querySelectorAll('[data-copy-url]').forEach(function(copyTriggerElement) {
2 copyTriggerElement.addEventListener('click', function() {
3 navigator.clipboard.writeText(window.location.href).then(function() {
4 copyTriggerElement.classList.add('is-copied');
5 setTimeout(function() {
6 copyTriggerElement.classList.remove('is-copied');
7 }, 2500);
8 });
9 });
10});
<button data-copy-url>Copy URL</button>
1[data-copy-url] {
2 transition: all 0.3s ease;
3}
4
5[data-copy-url].is-copied {
6 background-color: #10b981;
7 color: white;
8}
9
10[data-copy-url].is-copied::after {
11 content: " ✓ Copied!";
12}
A small keyboard shortcut can make a marketing site feel faster, more intentional, and “app-like” with almost no extra design or development
Since Finsweet released its attributes as open source, I've been dipping in and out to understand how the API works and how it can be used effectively. Here's an explanation of the API methods and properties that I use pretty frequently to open more doors in my projects.
A practical, code-heavy dive into GSAP’s utility functions—keyframes, pipe, clamp, normalize, and interpolate—and why they’re so much more than just shortcuts for animation math.
GSAP lets you pass _functions_ as property values. I've known this for a while but never really explored it particularly deeply. Over the last couple of weeks I've been testing, experimenting and getting creative with it to deepen my understanding.
Exploring ways to keep JavaScript modular and maintainable in Webflow — from Slater to GitHub to a custom window.functions pattern. A look at what’s worked (and what hasn’t) while building more scalable websites.