UNPKG

design-system-simplefi

Version:

Design System for SimpleFi Applications

67 lines 4.02 kB
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import { isNotNull, isNull } from 'ramda-adjunct'; import { requireRouterLink } from '../../../utils/require-router-link'; import { getLinkStyle } from '../../../utils'; import { LinkColors } from './Link.enums'; var StyledLink = styled.a(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin: 0;\n border: none;\n font-family: inherit;\n font-weight: normal;\n text-decoration: ", ";\n background-color: transparent;\n white-space: nowrap;\n cursor: pointer;\n\n &,\n &:not([href]):not([tabindex]) {\n color: ", ";\n }\n\n &:hover,\n &:not([href]):not([tabindex]):hover {\n color: ", ";\n text-decoration: none;\n }\n\n &:active,\n &:not([href]):not([tabindex]):active {\n color: ", ";\n text-decoration: none;\n }\n\n &:focus {\n outline: 0;\n }\n"], ["\n margin: 0;\n border: none;\n font-family: inherit;\n font-weight: normal;\n text-decoration: ", ";\n background-color: transparent;\n white-space: nowrap;\n cursor: pointer;\n\n &,\n &:not([href]):not([tabindex]) {\n color: ", ";\n }\n\n &:hover,\n &:not([href]):not([tabindex]):hover {\n color: ", ";\n text-decoration: none;\n }\n\n &:active,\n &:not([href]):not([tabindex]):active {\n color: ", ";\n text-decoration: none;\n }\n\n &:focus {\n outline: 0;\n }\n"])), getLinkStyle('decoration'), getLinkStyle('color'), getLinkStyle('hoverColor'), getLinkStyle('activeColor')); var Link = function (_a) { var children = _a.children, _b = _a.color, color = _b === void 0 ? LinkColors.primary : _b, _c = _a.as, as = _c === void 0 ? null : _c, _d = _a.href, href = _d === void 0 ? null : _d, _e = _a.to, to = _e === void 0 ? null : _e, onClick = _a.onClick, props = __rest(_a, ["children", "color", "as", "href", "to", "onClick"]); var RouterLink = null; if (isNull(as) && isNotNull(to)) { RouterLink = requireRouterLink(); } var domTag = as || (isNotNull(to) ? RouterLink // render 'Link' if 'to' is present : isNull(to) && isNull(href) ? 'button' // render 'button' if 'to' and 'href' is not present : undefined); // use default if (isNull(RouterLink) && isNull(domTag)) { return null; } return (React.createElement(StyledLink, __assign({ as: domTag, color: color, href: href, to: to, onClick: onClick }, props), children)); }; Link.propTypes = { href: PropTypes.string, to: PropTypes.oneOfType([ PropTypes.string, PropTypes.shape({ pathname: PropTypes.string, search: PropTypes.string, hash: PropTypes.string, }), ]), color: PropTypes.oneOf(Object.values(LinkColors)), onClick: PropTypes.func, }; export default Link; var templateObject_1; //# sourceMappingURL=Link.js.map