@workday/canvas-kit-preview-react
Version:
Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.
73 lines (72 loc) • 3.65 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoadingSparkles = void 0;
const React = __importStar(require("react"));
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
const common_1 = require("@workday/canvas-kit-react/common");
const icon_1 = require("@workday/canvas-kit-react/icon");
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
const sparkleIcon_1 = require("./sparkleIcon");
/**
* Duration of the sparkle animation (in ms).
*/
const ANIMATION_DURATION_MS = 1230;
// TODO: Replace with the actual color tokens when they are available.
/**
* Dragon Fruit colors.
*/
const AI_COLORS = {
dragonFruit100: '#FBF1FF',
dragonFruit200: '#EFD3FF',
dragonFruit300: '#BE61F6',
dragonFruit400: '#8C17D2',
dragonFruit500: '#6B11A3',
dragonFruit600: '#4A0D71',
};
/**
* The animation for the sparkle.
*/
const LOADING_ANIMATION = (0, canvas_kit_styling_1.keyframes)({ name: "nzjw3", styles: "0%, 79%, 100%{opacity:0.2;transform:scale(0.55);}27%{opacity:1;transform:scale(1);}53%{opacity:0.6;transform:scale(0.7);}" });
const loadingSparklesIconStyles = (0, canvas_kit_styling_1.createStyles)({ name: "nzjw4", styles: "animation-duration:1230ms;animation-fill-mode:both;animation-iteration-count:infinite;animation-name:animation-nzjw3;animation-timing-function:ease-in-out;.wd-sparkle-fill{fill:#8C17D2;}&:nth-child(1){animation-delay:0ms;}&:nth-child(2){animation-delay:calc(1230ms * (1/3));}&:nth-child(3){animation-delay:calc(1230ms * (2/3));}@media (prefers-contrast: more){.wd-sparkle-fill{color:currentColor;fill:currentColor;}}" });
/**
* An individual loading sparkle. ✨
*/
const Sparkle = () => {
return (React.createElement(icon_1.SystemIcon, { icon: sparkleIcon_1.sparkleIcon, cs: [loadingSparklesIconStyles], size: (0, canvas_kit_styling_1.cssVar)(canvas_tokens_web_1.system.space.x3) }));
};
const loadingSparklesStyles = (0, canvas_kit_styling_1.createStyles)({ name: "nzjw5", styles: "display:inline-flex;gap:0.0625rem;" });
/**
* A simple component that displays three horizontal sparkles, to be used when an AI operation is in progress.
*/
exports.LoadingSparkles = (0, common_1.createComponent)('div')({
displayName: 'LoadingSparkles',
Component: (elemProps, ref, Element) => {
return (React.createElement(Element, { ref: ref, role: "status", ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, loadingSparklesStyles) },
React.createElement(Sparkle, null),
React.createElement(Sparkle, null),
React.createElement(Sparkle, null)));
},
});
;