UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

59 lines (58 loc) 2.81 kB
"use strict"; 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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SkeletonText = void 0; const React = __importStar(require("react")); const styled_1 = __importDefault(require("@emotion/styled")); const common_1 = require("@workday/canvas-kit-react/common"); const tokens_1 = require("@workday/canvas-kit-react/tokens"); const canvas_kit_styling_1 = require("@workday/canvas-kit-styling"); const TextContainer = (0, styled_1.default)('div')({ marginBottom: tokens_1.space.m, }); const Line = (0, styled_1.default)('div', { shouldForwardProp: (0, common_1.filterOutProps)(['backgroundColor', 'width']), })(({ backgroundColor, width }) => { return { backgroundColor, width, borderRadius: tokens_1.borderRadius.s, outline: `${(0, canvas_kit_styling_1.px2rem)(1)} solid transparent`, outlineOffset: `-${(0, canvas_kit_styling_1.px2rem)(1)}`, height: '21px', marginBottom: tokens_1.space.xs, }; }); const createTextLines = (lineCount, backgroundColor) => { const lines = new Array(lineCount).fill(null); return lines.map((_value, index) => (React.createElement(Line, { key: index, backgroundColor: backgroundColor, width: index < lineCount - 1 || lineCount === 1 ? '100%' : '60%' }))); }; exports.SkeletonText = (0, common_1.createComponent)('div')({ displayName: 'Skeleton.Text', Component: ({ backgroundColor = tokens_1.colors.soap200, lineCount = 2, ...elemProps }, ref, Element) => lineCount <= 0 ? null : (React.createElement(TextContainer, { ref: ref, as: Element, ...elemProps }, createTextLines(lineCount, backgroundColor))), });