@navinc/base-react-components
Version:
Nav's Pattern Library
67 lines (63 loc) • 2.32 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.Tab = exports.TabGroup = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const prop_types_1 = __importDefault(require("prop-types"));
const text_1 = __importDefault(require("./text"));
const styled_components_1 = __importDefault(require("styled-components"));
exports.TabGroup = styled_components_1.default.nav `
width: 100%;
display: flex;
flex-flow: row nowrap;
border-bottom: 1px solid ${({ theme }) => theme.neutral300};
padding-top: 16px;
& > * {
padding: 8px 0 16px;
margin-right: 48px;
}
& > *:last-child {
margin-right: 0;
}
`;
exports.Tab = (0, styled_components_1.default)(text_1.default).withConfig({
shouldForwardProp: (prop) => !['isActive'].includes(prop),
}) `
position: relative;
color: ${({ theme }) => theme.neutral500};
&:hover {
color: ${({ theme }) => theme.neutral500};
}
&::after {
content: '';
width: 100%;
height: 4px;
background-color: ${({ isActive, theme }) => (isActive ? theme.azure : 'transparent')};
border-radius: 2px;
position: absolute;
bottom: 0;
left: 0;
}
`;
exports.Tab.propTypes = {
isActive: prop_types_1.default.bool,
};
exports.default = (_a) => {
var { children } = _a, props = __rest(_a, ["children"]);
return ((0, jsx_runtime_1.jsx)(exports.TabGroup, Object.assign({ "data-testid": "tab-group" }, props, { children: react_1.Children.toArray(children).map(({ type, key, props }) => ((0, jsx_runtime_1.jsx)(exports.Tab, Object.assign({ as: type }, props), key))) }), void 0));
};
//# sourceMappingURL=tab-group.js.map