Skip to content

Commit

Permalink
fix: allow className on CheckboxGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmars committed Mar 25, 2024
1 parent ca261fa commit cada747
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/components/Checkbox/CheckboxGroup.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ export const SomeDisabled = () => {
<CheckboxGroup options={optionsSomeDisabled} onChange={handleChange} selected={selected} />
);
};

export const Horizontal = () => {
const [selected, setSelected] = useState([]);

const handleChange = (values) => {
setSelected(values);
action('onChange')(values);
};

return (
<CheckboxGroup
className="d-flex gap-3"
options={options}
onChange={handleChange}
selected={selected}
/>
);
};
5 changes: 3 additions & 2 deletions src/components/Checkbox/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ interface Option {
}

export interface CheckboxGroupProps {
className?: string;
options: Option[];
selected: Value[];
onChange: (values: Value[]) => void;
}

const CheckboxGroup = ({ options, selected, onChange }: CheckboxGroupProps) => {
const CheckboxGroup = ({ className, options, selected, onChange }: CheckboxGroupProps) => {
const [groupId] = useState(uuidv4());

const handleCheckboxChange = (checked: boolean, value: Value) => {
Expand All @@ -33,7 +34,7 @@ const CheckboxGroup = ({ options, selected, onChange }: CheckboxGroupProps) => {
};

return (
<FormGroup>
<FormGroup className={className}>
{options.map((option, index) => {
const id = `option-${option.label}-${groupId}`;
const dataTestId = `react-gears-checkboxgroup-${groupId}-${index}`;
Expand Down

0 comments on commit cada747

Please sign in to comment.