@navinc/base-react-components
Version:
Nav's Pattern Library
51 lines • 2.26 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ButtonLinkIcon = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = __importDefault(require("styled-components"));
const icon_js_1 = __importDefault(require("./icon.js"));
const ButtonLinkIconWrapper = styled_components_1.default.div.withConfig({ displayName: "brc-sc-ButtonLinkIconWrapper", componentId: "brc-sc-1hn0nvm" }) `
display: flex;
align-items: center;
`;
const getSize = (size) => {
const iconSizes = {
small: {
width: '13.2px',
height: '13.2px',
},
medium: {
width: '16.5px',
height: '16.5px',
},
large: {
width: '19.8px',
height: '19.8px',
},
extraLarge: {
width: '20.5px',
height: '20.5px',
},
};
return size ? iconSizes[size] : iconSizes.medium;
};
const StyledIcon = (0, styled_components_1.default)(icon_js_1.default).withConfig({ displayName: "brc-sc-StyledIcon", componentId: "brc-sc-10o2ccp" }) `
& {
${({ size }) => getSize(size)}
}
`;
const StyledChildren = styled_components_1.default.span.withConfig({ displayName: "brc-sc-StyledChildren", componentId: "brc-sc-1u96y6y" }) `
& {
${({ iconPosition }) => (iconPosition === 'left' ? { paddingLeft: '3px' } : { paddingRight: '3px' })}
}
`;
const ButtonLinkIcon = ({ children, name, iconPosition, variation, size, }) => {
if (variation !== 'buttonLinkIcon')
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
return ((0, jsx_runtime_1.jsxs)(ButtonLinkIconWrapper, { children: [iconPosition === 'left' && (0, jsx_runtime_1.jsx)(StyledIcon, Object.assign({}, { size, name, iconPosition })), (0, jsx_runtime_1.jsx)(StyledChildren, Object.assign({}, { iconPosition }, { children: children })), iconPosition === 'right' && (0, jsx_runtime_1.jsx)(StyledIcon, Object.assign({}, { size, name, iconPosition }))] }));
};
exports.ButtonLinkIcon = ButtonLinkIcon;
//# sourceMappingURL=button-link-icon.js.map