@navinc/base-react-components
Version:
Nav's Pattern Library
33 lines (31 loc) • 1.98 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';
const StyledFieldset = styled(Fieldset).withConfig({ displayName: "brc-sc-StyledFieldset", componentId: "brc-sc-1of3gaw" }) `
display: flex;
flex-direction: column;
gap: 10px;
`;
const OptionCard = styled.div.withConfig({ displayName: "brc-sc-OptionCard", componentId: "brc-sc-lrq2iq" }) `
border-radius: 8px;
padding: 13px 16px;
background: ${({ theme }) => theme.navSecondary100};
border: ${({ theme, checked }) => `3px solid ${checked ? theme.navPrimary400 : theme.navNeutral200}`};
transition: border 250ms;
&:hover {
border-color: ${({ theme }) => theme.navPrimary400};
}
`;
const VisuallyHiddenRadioInput = styled.input.withConfig({ displayName: "brc-sc-VisuallyHiddenRadioInput", componentId: "brc-sc-1i5xidx" }) `
${visuallyHiddenStyles}
&:focus {
+ ${OptionCard} {
box-shadow: ${({ theme }) => `0 0 0 4px ${theme.navStatusPositive500}`};
}
}
`;
const _OptionsGroup = ({ options, renderOption, value: selectedVal, onChange = () => { }, name, className, }) => {
return (_jsxs(StyledFieldset, { 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, { checked: selectedVal === props.value, "data-testid": `options-group:option-wrapper ${props.value}`, children: renderOption(props) })] }, props.value)))] }));
};
export const OptionsGroup = styled(_OptionsGroup).withConfig({ displayName: "brc-sc-OptionsGroup", componentId: "brc-sc-b0xcba" }) ``;
//# sourceMappingURL=options-group.js.map