UNPKG

react-loader-spinner

Version:

react-spinner-loader provides simple React.js spinner component which can be implemented for async wait operation before data load to the view.

1 lines 5.09 kB
{"version":3,"sources":["../src/type.ts","../src/shared/svg-wrapper.tsx","../src/shared/constants.ts","../src/loader/triangle.tsx"],"names":["DEFAULT_COLOR","DEFAULT_WAI_ARIA_ATTRIBUTE","SvgWrapper","styled","props","SVG_NAMESPACE","VIEW_BOX_VALUES","POLYGON_POINTS","dash","keyframes","Polygon","SVG","Triangle","height","width","color","ariaLabel","wrapperStyle","wrapperClass","visible","jsx"],"mappings":"gFAEO,IAAMA,CAAAA,CAAgB,UAEhBC,CAAAA,CAA6B,CACxC,YAAa,IAAA,CACb,IAAA,CAAM,aACR,CAAA,CCLO,IAAMC,EAAaC,CAAAA,CAAO,GAAA;AAAA,WAAA,EACpBC,CAAAA,EAAUA,CAAAA,CAAM,QAAA,CAAW,MAAA,CAAS,MAAO,CAAA;ECHjD,IAAMC,CAAAA,CAAgB,4BAAA,KCuCvBC,CAAAA,CAAkB,aAAA,CAClBC,CAAAA,CAAiB,iBAAA,CAGjBC,CAAAA,CAAOC,SAAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAKPC,EAAUP,CAAAA,CAAO,OAAA;AAAA;AAAA,aAAA,EAERK,CAAI,CAAA;AAAA,CAAA,CAEbG,EAAMR,CAAAA,CAAO,GAAA;AAAA;AAAA,CAAA,CAKNS,CAAAA,CAA6C,CAAC,CACzD,MAAA,CAAAC,EAAS,EAAA,CACT,KAAA,CAAAC,CAAAA,CAAQ,EAAA,CACR,KAAA,CAAAC,CAAAA,CAAQf,CAAAA,CACR,SAAA,CAAAgB,EAAY,kBAAA,CACZ,YAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,IACZ,IAEIC,GAAAA,CAAClB,CAAAA,CAAA,CACC,KAAA,CAAOe,CAAAA,CACP,QAAA,CAAUE,CAAAA,CACV,SAAA,CAAW,GAAGD,CAAY,CAAA,CAAA,CAC1B,aAAA,CAAY,kBAAA,CACZ,YAAA,CAAYF,CAAAA,CACX,GAAGf,CAAAA,CAEJ,SAAAmB,GAAAA,CAACT,CAAAA,CAAA,CACC,EAAA,CAAG,UAAA,CACH,KAAA,CAAOG,CAAAA,CACP,MAAA,CAAQD,EACR,KAAA,CAAOR,CAAAA,CACP,OAAA,CAASC,CAAAA,CACT,aAAA,CAAY,cAAA,CAEZ,QAAA,CAAAc,GAAAA,CAACV,EAAA,CACC,IAAA,CAAK,aAAA,CACL,MAAA,CAAQK,EACR,WAAA,CAAY,GAAA,CACZ,MAAA,CAAQR,CAAAA,CACV,EACF,CAAA,CACF","file":"triangle.mjs","sourcesContent":["import { CSSProperties } from 'react'\n\nexport const DEFAULT_COLOR = '#4fa94d'\n\nexport const DEFAULT_WAI_ARIA_ATTRIBUTE = {\n 'aria-busy': true,\n role: 'progressbar',\n}\n\n// Reuse React's CSSProperties for consistent style typing across components\nexport type Style = CSSProperties\n\n// PrimaryProps includes common props shared by experimental components\nexport interface PrimaryProps {\n height?: string | number\n width?: string | number\n color?: string\n ariaLabel?: string\n wrapperStyle?: CSSProperties\n wrapperClass?: string\n visible?: boolean\n}\n\n\n","import styled from 'styled-components'\n\nexport const SvgWrapper = styled.div<{ $visible: boolean }>`\n display: ${props => (props.$visible ? 'flex' : 'none')};\n`\n","export const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'\n","import { FunctionComponent, CSSProperties } from 'react'\nimport styled, { keyframes } from 'styled-components'\nimport { DEFAULT_COLOR, DEFAULT_WAI_ARIA_ATTRIBUTE } from '../type'\nimport { SvgWrapper } from '../shared/svg-wrapper'\nimport { SVG_NAMESPACE } from '../shared/constants'\n\n/**\n * Props for the Triangle loader component.\n * \n * The Triangle loader displays a triangular shape with animated elements.\n * \n * @interface TriangleProps\n */\ninterface TriangleProps {\n /** Height of the SVG (number interpreted as px). */\n height?: string | number\n /** Width of the SVG (number interpreted as px). */\n width?: string | number\n /** Primary color applied to the loader. */\n color?: string\n /** Accessible label announced to screen readers. */\n ariaLabel?: string\n /** Inline style object applied to the wrapper element. */\n wrapperStyle?: CSSProperties\n /** CSS class applied to the wrapper for custom styling. */\n wrapperClass?: string\n /** When false, the loader is not rendered. Defaults to true. */\n visible?: boolean\n /** \n * Provide multiple colors to render a gradient instead of a solid color.\n * When 2 or more colors are supplied a gradient will be applied to the loader.\n */\n colors?: string[]\n /** Type of gradient (linear or radial). Defaults to linear. */\n gradientType?: 'linear' | 'radial'\n /** Angle (in degrees) applied via rotate() transform for linear gradients. */\n gradientAngle?: number\n}\n\nconst VIEW_BOX_VALUES = '-3 -4 39 39'\nconst POLYGON_POINTS = '16,0 32,32 0,32'\n\n/** Styles */\nconst dash = keyframes`\nto {\n stroke-dashoffset: 136;\n }\n`\nconst Polygon = styled.polygon`\n stroke-dasharray: 17;\n animation: ${dash} 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;\n`\nconst SVG = styled.svg`\n transform-origin: 50% 65%;\n`\n/** Styles Ends */\n\nexport const Triangle: FunctionComponent<TriangleProps> = ({\n height = 80,\n width = 80,\n color = DEFAULT_COLOR,\n ariaLabel = 'triangle-loading',\n wrapperStyle,\n wrapperClass,\n visible = true,\n}: TriangleProps) => {\n return (\n <SvgWrapper\n style={wrapperStyle}\n $visible={visible}\n className={`${wrapperClass}`}\n data-testid=\"triangle-loading\"\n aria-label={ariaLabel}\n {...DEFAULT_WAI_ARIA_ATTRIBUTE}\n >\n <SVG\n id=\"triangle\"\n width={width}\n height={height}\n xmlns={SVG_NAMESPACE}\n viewBox={VIEW_BOX_VALUES}\n data-testid=\"triangle-svg\"\n >\n <Polygon\n fill=\"transparent\"\n stroke={color}\n strokeWidth=\"1\"\n points={POLYGON_POINTS}\n />\n </SVG>\n </SvgWrapper>\n )\n}\n"]}