UNPKG

@navinc/base-react-components

Version:
54 lines (51 loc) 2.58 kB
"use strict"; 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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Link = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const styled_components_1 = __importDefault(require("styled-components")); const react_router_dom_1 = require("react-router-dom"); const utils_1 = require("@navinc/utils"); const text_js_1 = require("./text.js"); const StyledLink = (0, styled_components_1.default)(text_js_1.Text).withConfig({ displayName: "brc-sc-StyledLink", componentId: "brc-sc-1u9gte5" }) ` font-size: inherit; color: ${({ theme }) => theme.navPrimary400}; text-decoration: none; &:hover { color: ${({ theme }) => theme.navPrimary500}; } &:active { color: ${({ theme }) => theme.navPrimary500}; } &:focus { outline: ${({ theme }) => theme.focusOutline}; } `; StyledLink.displayName = 'StyledLink'; const BaseLink = (_a) => { var { to = '', href = to, target = '', onClick = () => { }, className = '', bold } = _a, props = __rest(_a, ["to", "href", "target", "onClick", "className", "bold"]); (0, react_1.useEffect)(() => (0, utils_1.deprecationWarning)(!!to, ` The \`to\` prop on BRC Link component is deprecated and support will be removed in a future version. Please use \`href\` instead. If you need to bypass React Router, add a \`target="_self"\` prop to your link.`), [to]); return ((0, jsx_runtime_1.jsx)(StyledLink, Object.assign({ target: target }, (target ? { href } : { to: href }), { as: target ? 'a' : href ? react_router_dom_1.Link : 'span', className: className, onClick: (e) => { e.persist(); onClick(e); }, rel: target === '_blank' ? 'noopener noreferrer' : undefined, "$bold": bold }, props))); }; BaseLink.displayName = 'Link'; exports.Link = (0, styled_components_1.default)(BaseLink).withConfig({ displayName: "brc-sc-Link", componentId: "brc-sc-1arvdw1" }) ``; //# sourceMappingURL=link.js.map