From a3c01c0b2abb34c112e697c14787d86e2be761cb Mon Sep 17 00:00:00 2001 From: Julian Skinner Date: Fri, 6 Sep 2024 10:53:02 -0500 Subject: [PATCH] feature(loader): change loader to new behavior and colors (#1975) * feat(loader-rails): change the loader animation and fill color * feat(loader-react): change the loader animation and fill color * style(loader): change timing to 1.5s per convo with design team --------- Co-authored-by: Julian Skinner --- .../sage_components/_sage_loader.html.erb | 21 ++++++- .../lib/stylesheets/components/_loader.scss | 40 ++++++------- packages/sage-react/lib/Loader/Loader.jsx | 58 ++++++++++++------- 3 files changed, 74 insertions(+), 45 deletions(-) diff --git a/docs/lib/sage_rails/app/views/sage_components/_sage_loader.html.erb b/docs/lib/sage_rails/app/views/sage_components/_sage_loader.html.erb index 91cd1973cc..111436cb76 100644 --- a/docs/lib/sage_rails/app/views/sage_components/_sage_loader.html.erb +++ b/docs/lib/sage_rails/app/views/sage_components/_sage_loader.html.erb @@ -1,5 +1,6 @@ <% component_description = component.type === "success" ? "Success" : "Loading..." + stroke_color = SageTokens::COLOR_PALETTE[:MERCURY_40] %>
-> +> <%# Spinner SVG %> <% if component.type === "spinner" %> - - + + + + + + + + + + + + + + + + <% end %> diff --git a/packages/sage-assets/lib/stylesheets/components/_loader.scss b/packages/sage-assets/lib/stylesheets/components/_loader.scss index 014e30b0ca..1ae92a2902 100644 --- a/packages/sage-assets/lib/stylesheets/components/_loader.scss +++ b/packages/sage-assets/lib/stylesheets/components/_loader.scss @@ -10,8 +10,7 @@ $-loader-bar-speed: 1.2s; $-loader-bar-speed-delay: 0.5s; $-loader-bar-width: rem(300px); $-loader-spinner-size: rem(48px); -$-loader-spinner-speed: 2s; -$-loader-spinner-path-speed: 1.5s; +$-loader-spinner-speed: 1.5s; $-loader-typing-size: rem(6px); $-loader-lower-opacity: 0.4; @@ -84,7 +83,7 @@ $-loader-lower-opacity: 0.4; .sage-loader__spinner { width: sage-spacing(xl); height: sage-spacing(xl); - animation: rotate $-loader-spinner-speed linear infinite; + animation: loader-rotate $-loader-spinner-speed linear infinite; } .sage-loader__spinner--loading-button { @@ -94,11 +93,20 @@ $-loader-lower-opacity: 0.4; } .sage-loader__spinner-path { - stroke-dasharray: 150, 200; - stroke-dashoffset: -10; + stroke-width: 8px; +} + +.sage-loader__spinner-secondHalf { + stroke: url("#sage-loader__spinner-secondHalf"); +} + +.sage-loader__spinner-firstHalf { + stroke: url("#sage-loader__spinner-firstHalf"); +} + +.sage-loader__spinner-highlight { + stroke: currentColor; stroke-linecap: round; - stroke: sage-color(primary, 300); - animation: dash $-loader-spinner-path-speed ease-in-out infinite; } .sage-loader__spinner-path--loading-button { @@ -146,24 +154,12 @@ $-loader-lower-opacity: 0.4; } } -@keyframes rotate { - 100% { - transform: rotate(360deg); - } -} - -@keyframes dash { +@keyframes loader-rotate { 0% { - stroke-dasharray: 1, 200; - stroke-dashoffset: 0; - } - 50% { - stroke-dasharray: 89, 200; - stroke-dashoffset: -35; + transform: rotate(0deg); } 100% { - stroke-dasharray: 89, 200; - stroke-dashoffset: -124; + transform: rotate(360deg); } } diff --git a/packages/sage-react/lib/Loader/Loader.jsx b/packages/sage-react/lib/Loader/Loader.jsx index 115193c292..27f6a89d50 100644 --- a/packages/sage-react/lib/Loader/Loader.jsx +++ b/packages/sage-react/lib/Loader/Loader.jsx @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { LOADER_TYPES } from './configs'; +import { SageTokens } from '../configs'; export const Loader = ({ fillSpace, @@ -33,34 +34,51 @@ export const Loader = ({ {(type === LOADER_TYPES.SPINNER_IN_BUTTON) && ( )} {(type === LOADER_TYPES.SPINNER) && ( )} {(type === LOADER_TYPES.SUCCESS) && (