Skip to content

Commit

Permalink
Add a value property to the ToggleFilter (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
civan authored Sep 26, 2023
1 parent b8a8652 commit cc8440a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/ToggleFilter/ToggleFilter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default {
export const Default = () => (
<ToggleFilter
options={[
{ label: 'Option 1', selected: true },
{ label: 'Option 2', selected: false },
{ label: 'Option 3', selected: false, color: "#F04438" }
{ label: 'Option 1', filterValue: 'One', selected: true },
{ label: 'Option 2', filterValue: 'Two', selected: false },
{ label: 'Option 3', filterValue: 'Three', selected: false, color: "#F04438" }
]}
onChange={(option) => console.log(option)}
/>
Expand All @@ -28,8 +28,8 @@ export const Default = () => (
export const WithCustomOptions = () => (
<ToggleFilter
options={[
{ label: 'Custom 1', selected: false },
{ label: 'Custom 2', selected: true }
{ label: 'Custom 1', filterValue: 'One', selected: false },
{ label: 'Custom 2', filterValue: 'Two', selected: true }
]}
onChange={(option) => console.log(option)}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/ToggleFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function ToggleFilter({ options, onChange, className }: ToggleFilterProps) {
const handleClick = (option: Option) => {
setSelectedOption(option.label);
if (onChange) {
onChange(option.label);
onChange(option.filterValue);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/ToggleFilter/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface Option {
label: string;
filterValue: string,
selected: boolean;
color?: string;
}
Expand Down

0 comments on commit cc8440a

Please sign in to comment.