UNPKG

norma-library

Version:

Olos/Norma-DS. Design System based on Material UI, developed with TypeScript and Styled Components to create reusable and consistent components in web applications.

48 lines 2.39 kB
import { __assign, __makeTemplateObject, __rest } from "tslib"; import React from 'react'; import { iconsSVG } from './Svgs'; import styled from '@emotion/styled'; import { palette } from '../helpers'; export var Svg = styled.svg({ shapeRendering: 'inherit', transform: 'translate3d(0,0,0)', }, function (_a) { var inline = _a.inline; return (inline ? { display: 'inline-block' } : { display: 'block' }); }); var scaleSize = { xsmall: 14, small: 20, medium: 24, large: 28, xlarge: 32, '2xlarge': 36, '3xlarge': 40, }; var colors = { inherit: palette.inherit, primary: palette.primary, secondary: palette.secondary, error: palette.error, info: palette.info, success: palette.success, warning: palette.warning, white: palette.white, black: palette.black, }; export var Icons = function (_a) { var icon = _a.icon, scale = _a.scale, useSymbol = _a.useSymbol, _b = _a.color, color = _b === void 0 ? 'inherit' : _b, props = __rest(_a, ["icon", "scale", "useSymbol", "color"]); var width = 24; var height = 24; if (scale) { width = scaleSize[scale] || 24; height = scaleSize[scale] || 24; } var fill = colors[color] || color; var stroke = colors[color] || color; var Svg = styled.svg(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: inline-block;\n shape-rendering: inherit;\n vertical-align: middle;\n fill: ", ";\n path {\n stroke: ", ";\n }\n circle {\n stroke: ", ";\n }\n rect {\n stroke: ", ";\n }\n "], ["\n display: inline-block;\n shape-rendering: inherit;\n vertical-align: middle;\n fill: ", ";\n path {\n stroke: ", ";\n }\n circle {\n stroke: ", ";\n }\n rect {\n stroke: ", ";\n }\n "])), fill, stroke, stroke, stroke); var isMuiIcon = typeof icon !== 'string'; return (React.createElement(Svg, __assign({ viewBox: "0 0 56 56", width: "".concat(width, "px"), height: "".concat(height, "px") }, props), useSymbol ? (React.createElement("use", { xlinkHref: "#icon--".concat(icon), fill: fill, stroke: stroke })) : isMuiIcon ? (React.createElement(icon, { style: { fill: fill, stroke: stroke } })) : (React.cloneElement(iconsSVG[icon], { fill: fill, stroke: stroke })))); }; var templateObject_1; //# sourceMappingURL=Icons.js.map