UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

28 lines (27 loc) 2.28 kB
import * as React from 'react'; import { system } from '@workday/canvas-tokens-web'; import { createComponent } from '@workday/canvas-kit-react/common'; import { handleCsProp, keyframes, createStencil, calc, px2rem, } from '@workday/canvas-kit-styling'; /** * Keyframe for the dots loading animation. */ const keyframesLoading = keyframes({ name: "d5h454", styles: "0%, 80%, 100%{transform:scale(0);}40%{transform:scale(1);}" }); export const loadingDotsStencil = createStencil({ vars: { animationDurationMs: '40ms', loadingDotColor: system.color.bg.alt.strong, }, base: { name: "d5h455", styles: "--animationDurationMs-loading-dots-417e1d:40ms;--loadingDotColor-loading-dots-417e1d:var(--cnvs-sys-color-bg-alt-strong);box-sizing:border-box;display:inline-flex;gap:var(--cnvs-sys-space-x2);& [data-part=\"loading-animation-dot\"]{background-color:var(--loadingDotColor-loading-dots-417e1d);width:var(--cnvs-sys-space-x4);height:var(--cnvs-sys-space-x4);font-size:var(--cnvs-sys-space-zero);border-radius:var(--cnvs-sys-shape-round);outline:0.125rem solid transparent;transform:scale(0);display:inline-block;animation-name:animation-d5h454;animation-duration:calc(var(--animationDurationMs-loading-dots-417e1d) * 35);animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-fill-mode:both;&:nth-child(1){animation-delay:0ms;}&:nth-child(2){animation-delay:calc(var(--animationDurationMs-loading-dots-417e1d) * 4);}&:nth-child(3){animation-delay:calc(var(--animationDurationMs-loading-dots-417e1d) * 8);}}" } }, "loading-dots-417e1d"); /** * A simple component that displays three horizontal dots, to be used when some data is loading. */ export const LoadingDots = createComponent('div')({ displayName: 'LoadingDots', Component: ({ loadingDotColor, animationDurationMs, ...elemProps }, ref, Element) => { return (React.createElement(Element, { ref: ref, ...handleCsProp(elemProps, loadingDotsStencil({ loadingDotColor, animationDurationMs })) }, React.createElement("div", { "data-part": "loading-animation-dot" }), React.createElement("div", { "data-part": "loading-animation-dot" }), React.createElement("div", { "data-part": "loading-animation-dot" }))); }, });