diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 55da23ce4c..07e41f69fb 100755 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -69,6 +69,7 @@ #### Loader - `Spinner` component replaced with new `Loader` component +- `xs` and `xl` sized have been removed, leaving only the default, `sm`, and `lg` sizes #### Menu diff --git a/packages/stacks-classic/lib/components/loader/loader.a11y.test.ts b/packages/stacks-classic/lib/components/loader/loader.a11y.test.ts index 456b79bd4b..498d9404a7 100644 --- a/packages/stacks-classic/lib/components/loader/loader.a11y.test.ts +++ b/packages/stacks-classic/lib/components/loader/loader.a11y.test.ts @@ -1,9 +1,9 @@ import { runA11yTests } from "../../test/a11y-test-utils"; import "../../index"; -describe("loading", () => { +describe("loader", () => { runA11yTests({ - baseClass: "s-loading", + baseClass: "s-loader", modifiers: { primary: ["sm", "lg"], }, diff --git a/packages/stacks-classic/lib/components/loader/loader.less b/packages/stacks-classic/lib/components/loader/loader.less index c39109cc46..6faf984997 100644 --- a/packages/stacks-classic/lib/components/loader/loader.less +++ b/packages/stacks-classic/lib/components/loader/loader.less @@ -1,61 +1,78 @@ -.s-loader--block { - // BASE COMPONENT-SPECIFIC CUSTOM PROPERTIES - --_ld-size: var(--su-static24); - --_ld-block-size: calc(var(--su-static8) - var(--su-static1)); - --_ld-gap: calc(var(--su-static2) + var(--su-static1)); - --_ld-start-offset: var(--su-static2); +.s-loader { + --_ld-color: var(--black-600); + --_ld-gap: calc(var(--_ld-size) / 2); + --_ld-size: calc(var(--su4) + var(--su1)); // 5px + --_ld-offset: calc(calc(var(--_ld-size) / 8) * -5); // -5/8ths of the size // MODIFIERS - &&__sm { - --_ld-size: var(--su-static16); - --_ld-gap: var(--su-static2); - --_ld-start-offset: calc(var(--su-static2) + var(--su-static1)); + &__sm { + --_ld-size: calc(calc(var(--su8) - var(--su1)) / 2); // 3.5px + margin-left: var(--su1); + margin-right: var(--su1); } - &&__lg { - --_ld-size: var(--su-static48); - --_ld-block-size: calc(var(--su-static4) + var(--su-static4)); - --_ld-start-offset: var(--su-static1); + + &__lg { + --_ld-size: var(--su8); + } + + // CHILD ELEMENTS + & &--block, + &:before, + &:after { + background-color: currentColor; + content: ""; + display: block; + height: var(--_ld-size); + width: var(--_ld-size); + + animation: loader-animation .8s cubic-bezier(1, 1, 0, 1) infinite; + } + + & &--block { + animation-delay: .25s; + } + + &:after { + animation-delay: .5s; } - align-items: center; display: flex; - height: var(--_ld-size); - justify-content: center; - position: relative; - width: var(--_ld-size); - - // Style the spot loading SVG to match container size - .svg-spot { - height: auto; - max-height: 100%; - max-width: 100%; - width: auto; - - rect { - height: var(--_ld-block-size); - width: var(--_ld-block-size); - } + gap: var(--_ld-gap); + margin-top: var(--_ld-gap); +} - rect:nth-child(2) { - x: var(--_ld-start-offset); - } - - rect:nth-child(3) { - x: calc(var(--_ld-start-offset) + var(--_ld-block-size) + var(--_ld-gap)); - } - - rect:nth-child(4) { - x: calc(var(--_ld-start-offset) + var(--_ld-block-size) * 2 + var(--_ld-gap) * 2); +@media (prefers-reduced-motion:reduce){ + .s-loader { + & &--block, + &:before, + &:after { + animation: loader-animation-reduced-motion 2s ease-in-out infinite; } } - - // Inherit text color when inside a button - .s-btn & { - color: var(--_bu-fc); - .svg-spot { - rect { - fill: var(--_bu-fc) !important; - } - } +} + +@keyframes loader-animation { + 0%,1%,99%,to{ + opacity: 0.2; + transform: translateY(0); + } + 49%,50%{ + opacity: 1; + transform: translateY(var(--_ld-offset)); + } + 51%{ + opacity: 0.2; + transform: translateY(var(--_ld-offset)); + } +} + +@keyframes loader-animation-reduced-motion { + 0%,to{ + opacity: 0.3; + transform: none; + } + 50%{ + opacity: 1; + transform: none; } -} \ No newline at end of file +} diff --git a/packages/stacks-classic/lib/components/loader/loader.visual.test.ts b/packages/stacks-classic/lib/components/loader/loader.visual.test.ts index 73827b5c3b..9eb4972e48 100644 --- a/packages/stacks-classic/lib/components/loader/loader.visual.test.ts +++ b/packages/stacks-classic/lib/components/loader/loader.visual.test.ts @@ -6,10 +6,10 @@ import "../../index"; const template = ({ component, testid }: any) => html`
Any button can have a loading state applied by adding the .s-loader--block .s-loader--block__sm state class.
Indicate a loading state by adding a .s-loader component to a button.