@navinc/base-react-components
Version:
Nav's Pattern Library
77 lines • 2.88 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 });
exports.Text = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const styled_components_1 = __importDefault(require("styled-components"));
const utils_1 = require("@navinc/utils");
const sizeVariants = {
small: {
fontSize: '12px',
lineHeight: '18px',
},
medium: {
fontSize: '14px',
lineHeight: '20px',
},
regular: {
fontSize: '16px',
lineHeight: '24px',
},
large: {
fontSize: '18px',
lineHeight: '28px',
},
};
const boldVariants = {
regular: {
fontWeight: 400,
},
semiBold: {
fontWeight: 600,
},
bold: {
fontWeight: 800,
},
};
const getBoldVariant = (props) => {
const { bold, $bold, boldType } = props;
const isBold = bold || $bold;
if (isBold) {
return boldVariants.bold;
}
return boldVariants[boldType];
};
const getSize = ({ size = 'regular' }) => {
var _a;
return (_a = sizeVariants[size]) !== null && _a !== void 0 ? _a : sizeVariants.regular;
};
/**
* @deprecated Use `CopyVariant as Copy` instead. Use `component='span'` to turn any nested Copy component into a span tag. This component will be removed in a future release. CopyVariant replaces Header, Copy, and Text.
*/
exports.Text = (0, styled_components_1.default)((_a) => {
var { bold, light: _light, size: _size, boldType: _boldType } = _a, props = __rest(_a, ["bold", "light", "size", "boldType"]);
(0, react_1.useEffect)(() => (0, utils_1.deprecationWarning)(bold, `The \`bold\` prop on Base React Component Text component is deprecated and support will be removed in a future version. Please use \`$bold\` instead.`), [bold]);
return (0, jsx_runtime_1.jsx)("span", Object.assign({}, props));
}).withConfig({ displayName: "brc-sc-Text", componentId: "brc-sc-emkmup" }) `
color: ${({ theme }) => theme.navNeutralDark};
font-family: ${({ theme }) => theme.fontPrimary};
${({ size }) => getSize({ size })};
${({ bold, $bold, boldType }) => getBoldVariant({ bold, $bold, boldType })};
`;
exports.Text.displayName = 'Text';
//# sourceMappingURL=text.js.map