From 1791f27dda4824a5f95f60e9c58d72f91a6b4fc9 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 18 Nov 2025 15:18:26 -0500 Subject: [PATCH] simplify internals and fix track width bug; fixes #1317 --- .../docs/docs/resources/changelog.md | 1 + .../src/components/spinner/spinner.css | 45 +++++++------------ .../src/components/spinner/spinner.ts | 17 +++---- 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/packages/webawesome/docs/docs/resources/changelog.md b/packages/webawesome/docs/docs/resources/changelog.md index f67dea039..22ff64602 100644 --- a/packages/webawesome/docs/docs/resources/changelog.md +++ b/packages/webawesome/docs/docs/resources/changelog.md @@ -17,6 +17,7 @@ Components with the Experimental badge sh - Fixed a bug in `` that caused some touch devices to end up with the incorrect value [issue:1703] - Fixed a bug in `` that prevented some slots from being detected correctly [discuss:1450] - Fixed a bug in `` that caused the browser to hang when cancelling the `wa-hide` event [issue:1483] +- Fixed a bug in `` that caused `--track-width` to not work correctly [issue:1317] - Improved performance of `` so initial rendering occurs faster, especially with multiple icons on the page [issue:1729] ## 3.0.0 diff --git a/packages/webawesome/src/components/spinner/spinner.css b/packages/webawesome/src/components/spinner/spinner.css index cc28a04c8..b68de2efa 100644 --- a/packages/webawesome/src/components/spinner/spinner.css +++ b/packages/webawesome/src/components/spinner/spinner.css @@ -2,58 +2,43 @@ --track-width: 2px; --track-color: var(--wa-color-neutral-fill-normal); --indicator-color: var(--wa-color-brand-fill-loud); - --speed: 2s; + --speed: 1s; - /* Resizing a spinner element using anything but font-size will break the animation because the animation uses em units. - Therefore, if a spinner is used in a flex container without `flex: none` applied, the spinner can grow/shrink and - break the animation. The use of `flex: none` on the host element prevents this by always having the spinner sized - according to its actual dimensions. - */ flex: none; display: inline-flex; width: 1em; height: 1em; } -svg { +[part='base'] { + position: relative; width: 100%; height: 100%; - aspect-ratio: 1; - animation: spin var(--speed) linear infinite; } .track { - stroke: var(--track-color); + position: absolute; + inset: 0; + border: var(--track-width) solid var(--track-color); + border-radius: 50%; } .indicator { - stroke: var(--indicator-color); - stroke-dasharray: 75, 100; - stroke-dashoffset: -5; - animation: dash 1.5s ease-in-out infinite; - stroke-linecap: round; + position: absolute; + inset: 0; + border: var(--track-width) solid transparent; + border-top-color: var(--indicator-color); + border-right-color: var(--indicator-color); + border-radius: 50%; + animation: spin var(--speed) linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } } - -@keyframes dash { - 0% { - stroke-dasharray: 1, 150; - stroke-dashoffset: 0; - } - 50% { - stroke-dasharray: 90, 150; - stroke-dashoffset: -35; - } - 100% { - stroke-dasharray: 90, 150; - stroke-dashoffset: -124; - } -} diff --git a/packages/webawesome/src/components/spinner/spinner.ts b/packages/webawesome/src/components/spinner/spinner.ts index ca3d2b45d..78297157b 100644 --- a/packages/webawesome/src/components/spinner/spinner.ts +++ b/packages/webawesome/src/components/spinner/spinner.ts @@ -11,6 +11,8 @@ import styles from './spinner.css'; * @since 2.0 * * @csspart base - The component's base wrapper. + * @csspart track - The spinner's track. + * @csspart indicator - The spinner's indicator. * * @cssproperty --track-width - The width of the track. * @cssproperty --track-color - The color of the track. @@ -25,17 +27,10 @@ export default class WaSpinner extends WebAwesomeElement { render() { return html` - - - - +
+
+
+
`; } }