UNPKG

@atlaskit/icon

Version:

An icon is a symbol representing a command, device, directory, or common action.

100 lines (96 loc) 3.05 kB
/* icon-new.tsx generated by @compiled/babel-plugin v0.39.1 */ import "./icon-new.compiled.css"; import * as React from 'react'; import { ax, ix } from "@compiled/react/runtime"; import { memo } from 'react'; /** * We are hiding this props from consumers as it's reserved * for use by Icon Tile. */ const svgStyles = null; const iconStyles = null; const smallIconStyles = null; const scaleStyles = null; /** * For windows high contrast mode */ const baseHcmStyles = null; const scaleSize = null; const coreSizeMedium = { none: "_1bsbpxbi _4t3ipxbi", compact: "_1bsb1ejb _4t3i1ejb", spacious: "_1bsb1ejb _4t3i1ejb" }; const coreSizeSmall = { none: "_1bsbutpp _4t3iutpp", compact: "_1bsbpxbi _4t3ipxbi", spacious: "_1bsb1ejb _4t3i1ejb" }; const paddingMap = { medium: { none: 0, compact: 4, spacious: 4 }, small: { none: 0, compact: 2.66, spacious: 8 } }; /** * __Icon__ * * An icon is used as a visual representation of common actions and commands to provide context. * * - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon) */ export const Icon = /*#__PURE__*/memo(function Icon(props) { const { color = 'currentColor', testId, label, // Used to set icon dimensions/behaviour in codegen // Used to set icon glyphs in codegen dangerouslySetGlyph, // Used with iconTile to scale icon up and down shouldScale, spacing = 'none', name } = props; const dangerouslySetInnerHTML = dangerouslySetGlyph ? { __html: dangerouslySetGlyph } : undefined; let size = 'medium'; if ('size' in props && props.size !== undefined) { if (typeof props.size === 'string') { size = props.size === 'small' || props.size === 'medium' ? props.size : size; } else if (name) { const newSize = props.size(name); size = newSize === 'small' || newSize === 'medium' ? newSize : size; } } const baseSize = 16; const viewBoxPadding = paddingMap[size][spacing]; const viewBoxSize = baseSize + 2 * viewBoxPadding; return /*#__PURE__*/React.createElement("span", { "data-testid": testId, role: label ? 'img' : undefined, "aria-label": label ? label : undefined, "aria-hidden": label ? undefined : true, style: { color }, className: ax(["_1e0c1o8l _vchhusvi _1o9zidpf _vwz4kb7n _y4ti1igz _bozg1mb9", "_12va1onz _jcxd1r8n", shouldScale && "_1bsb1kw7 _4t3i1kw7", size === 'small' && "_vwz4utpp"]) }, /*#__PURE__*/React.createElement("svg", { fill: "none" // Adjusting the viewBox allows the icon padding to scale with the contents of the SVG, which // we want for Icon Tile , viewBox: `${0 - viewBoxPadding} ${0 - viewBoxPadding} ${viewBoxSize} ${viewBoxSize}`, role: "presentation", dangerouslySetInnerHTML: dangerouslySetInnerHTML, className: ax(["_1reo15vq _18m915vq _syaz1r31 _lcxvglyw _s7n4yfq0 _vc881r31", shouldScale ? "_1bsb1kw7 _4t3i1kw7" : size === 'small' ? coreSizeSmall[spacing] : coreSizeMedium[spacing]]) })); }); export default Icon;