@navinc/base-react-components
Version:
Nav's Pattern Library
55 lines (52 loc) • 2.85 kB
JavaScript
;
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 });
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 = __importDefault(require("./text.js"));
const is_rebrand_js_1 = __importDefault(require("./is-rebrand.js"));
const StyledLink = (0, styled_components_1.default)(text_js_1.default).withConfig({ displayName: "brc-sc-StyledLink", componentId: "brc-sc-1u9gte5" }) `
font-size: inherit;
color: ${({ theme }) => ((0, is_rebrand_js_1.default)(theme) ? theme.navPrimary400 : theme.bubbleBlue500)};
text-decoration: none;
&:hover {
color: ${({ theme }) => ((0, is_rebrand_js_1.default)(theme) ? theme.navPrimary500 : theme.oceanBoat)};
}
&:active {
color: ${({ theme }) => ((0, is_rebrand_js_1.default)(theme) ? theme.navPrimary500 : theme.oceanBoat)};
}
&: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';
const Link = (0, styled_components_1.default)(BaseLink).withConfig({ displayName: "brc-sc-Link", componentId: "brc-sc-1arvdw1" }) ``;
exports.default = Link;
//# sourceMappingURL=link.js.map