Polish The Copy Confetti On The Icons Page (#5191)

- Say "Copied SVG!" and "Copied name!" when an icon is copied with
  Shift + click or Ctrl/Cmd + click.
- Center the text over the icon instead of starting at its left edge.
- Give the icon the brand border while the confetti plays.
- Keep the confetti visible when reduced motion is on; the site-wide
  reduced-motion rule shrank it to 0.01ms so it never showed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PrimeTestLab
2026-11-10 12:55:00 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 68081128b3
commit 0991512434
2 changed files with 18 additions and 2 deletions
@@ -49,7 +49,7 @@ async function copyToClipboard(text: string, confettiMessage: string, toastMessa
}
function copyName() {
return copyToClipboard(props.name, `Copied name`, `Copied the name of ${props.name}`);
return copyToClipboard(props.name, `Copied name!`, `Copied the name of ${props.name}`);
}
function copySVG(iconButton: HTMLElement) {
@@ -57,7 +57,7 @@ function copySVG(iconButton: HTMLElement) {
class: `lucide lucide-${props.name}`,
});
return copyToClipboard(svgString, `Copied svg`, `Copied the SVG of ${props.name}`);
return copyToClipboard(svgString, `Copied SVG!`, `Copied the SVG of ${props.name}`);
}
async function navigateToIcon(event) {
@@ -202,6 +202,12 @@ const DiamondIcon = createLucideIcon('Diamond', diamond);
.confetti-button:before {
line-height: 80px;
/* Center the "Copied ..." text over the icon (it started at the icon's left edge and ran off to the right). */
width: 160px;
max-width: none;
left: calc(50% - 80px);
text-align: center;
white-space: nowrap;
}
.icon-button:active {
@@ -238,6 +244,7 @@ const DiamondIcon = createLucideIcon('Diamond', diamond);
}
.icon-button.active,
.icon-button.animate,
.icon-button:focus-visible {
border-color: var(--vp-c-brand);
}
@@ -173,3 +173,12 @@
0% 0%;
}
}
/* Keep the copy confetti even with reduced motion turned on (owner request): the site-wide
reduced-motion rule in style.css shrinks every animation to 0.01ms, which hid it at once. */
@media (prefers-reduced-motion: reduce) {
.confetti-button.animate:before,
.confetti-button.animate:after {
animation-duration: 1s !important;
}
}