@navinc/base-react-components
Version:
Nav's Pattern Library
31 lines (29 loc) • 1.86 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import styled from 'styled-components';
import { visuallyHiddenStyles, Fieldset, HiddenLegend } from './form-elements/shared.js';
import isRebrand from './is-rebrand.js';
const OptionCard = styled.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.input.withConfig({ displayName: "brc-sc-VisuallyHiddenRadioInput", componentId: "brc-sc-t9y4at" }) `
${visuallyHiddenStyles}
&:focus {
+ ${OptionCard} {
box-shadow: ${({ theme }) => `0 0 0 4px
${isRebrand(theme) ? theme.navStatusPositive500 : theme.bubbleBlue300}`};
}
}
`;
export const OptionsGroup = ({ options, renderOption, value: selectedVal, onChange = () => { }, name, className, }) => {
return (_jsxs(Fieldset, Object.assign({ className: className, "data-testid": `options-group:${name}` }, { children: [_jsx(HiddenLegend, { children: name }), options.map((props) => (_jsxs("label", { children: [_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}` }), _jsx(OptionCard, Object.assign({ checked: selectedVal === props.value, "data-testid": `options-group:option-wrapper ${props.value}` }, { children: renderOption(props) }))] }, props.value)))] })));
};
export default styled(OptionsGroup).withConfig({ componentId: "brc-sc-1idswhx" }) ``;
//# sourceMappingURL=options-group.js.map