UNPKG

@navinc/base-react-components

Version:
48 lines (45 loc) 2.2 kB
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 { jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import styled from 'styled-components'; import { Link as ReactRouterLink } from 'react-router-dom'; import { deprecationWarning } from '@navinc/utils'; import { Text } from './text.js'; const StyledLink = styled(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"]); useEffect(() => 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 (_jsx(StyledLink, Object.assign({ target: target }, (target ? { href } : { to: href }), { as: target ? 'a' : href ? ReactRouterLink : 'span', className: className, onClick: (e) => { e.persist(); onClick(e); }, rel: target === '_blank' ? 'noopener noreferrer' : undefined, "$bold": bold }, props))); }; BaseLink.displayName = 'Link'; export const Link = styled(BaseLink).withConfig({ displayName: "brc-sc-Link", componentId: "brc-sc-1arvdw1" }) ``; //# sourceMappingURL=link.js.map