@navinc/base-react-components
Version:
Nav's Pattern Library
38 lines (36 loc) • 2.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionsGroup = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = __importDefault(require("styled-components"));
const shared_js_1 = require("./form-elements/shared.js");
const is_rebrand_js_1 = __importDefault(require("./is-rebrand.js"));
const OptionCard = styled_components_1.default.div.withConfig({ displayName: "brc-sc-OptionCard", componentId: "brc-sc-3txhnn" }) `
border-radius: 8px;
padding: 13px 16px;
background: white;
margin-bottom: 10px;
border: ${({ theme, checked }) => `3px solid ${checked ? theme.navPrimary : theme.navNeutral200}`};
transition: border 250ms;
&:hover {
border-color: ${({ theme }) => theme.navPrimary};
}
`;
const VisuallyHiddenRadioInput = styled_components_1.default.input.withConfig({ displayName: "brc-sc-VisuallyHiddenRadioInput", componentId: "brc-sc-t9y4at" }) `
${shared_js_1.visuallyHiddenStyles}
&:focus {
+ ${OptionCard} {
box-shadow: ${({ theme }) => `0 0 0 4px
${(0, is_rebrand_js_1.default)(theme) ? theme.navStatusPositive500 : theme.bubbleBlue300}`};
}
}
`;
const OptionsGroup = ({ options, renderOption, value: selectedVal, onChange = () => { }, name, className, }) => {
return ((0, jsx_runtime_1.jsxs)(shared_js_1.Fieldset, Object.assign({ className: className, "data-testid": `options-group:${name}` }, { children: [(0, jsx_runtime_1.jsx)(shared_js_1.HiddenLegend, { children: name }), options.map((props) => ((0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)(VisuallyHiddenRadioInput, { type: "radio", id: props.value, name: name, value: props.value, checked: selectedVal === props.value, onChange: onChange, "data-testid": `options-group:hidden-radio ${props.value}` }), (0, jsx_runtime_1.jsx)(OptionCard, Object.assign({ checked: selectedVal === props.value, "data-testid": `options-group:option-wrapper ${props.value}` }, { children: renderOption(props) }))] }, props.value)))] })));
};
exports.OptionsGroup = OptionsGroup;
exports.default = (0, styled_components_1.default)(exports.OptionsGroup).withConfig({ componentId: "brc-sc-1idswhx" }) ``;
//# sourceMappingURL=options-group.js.map