Skip to content

Commit

Permalink
add types to checkbox stories, add playground and merge disabled stories
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarcMilletScality committed Apr 3, 2024
1 parent 02ca676 commit e968159
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions stories/Checkbox/checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from 'react';
import React, { ComponentProps, useEffect, useRef } from 'react';
import { action } from '@storybook/addon-actions';
import { Checkbox } from '../../src/lib/components/checkbox/Checkbox.component';
import { Wrapper } from '../common';
Expand Down Expand Up @@ -26,7 +26,9 @@ export default meta;

export const DefaultCheckbox: CheckboxStory = {};

export const IndeterminateCheckbox: CheckboxStory = {
export const IndeterminateCheckbox: StoryObj<
ComponentProps<typeof Checkbox> & { 'data-cy': string }
> = {
render: (args) => {
const checkboxRef = useRef<HTMLInputElement>(null);
useEffect(() => {
Expand All @@ -36,15 +38,17 @@ export const IndeterminateCheckbox: CheckboxStory = {
}, [checkboxRef]);
return <Checkbox ref={checkboxRef} {...args} />;
},
// args: {
// 'data-cy': 'checked_checkbox',
// },
args: {
'data-cy': 'checked_checkbox',
},
};

export const CheckedCheckbox: CheckboxStory = {
export const CheckedCheckbox: StoryObj<
ComponentProps<typeof Checkbox> & { 'data-cy': string }
> = {
args: {
checked: true,
// 'data-cy': 'checked_checkbox',
'data-cy': 'checked_checkbox',
},
};

Expand All @@ -54,16 +58,28 @@ export const UncheckedCheckbox: CheckboxStory = {
},
};

export const DisabledCheckboxes: CheckboxStory = {
render: () => {
return (
<>
<Checkbox disabled checked label="Disabled & checked " />
<Checkbox disabled label="Disabled & unchecked" />
</>
);
},
};

export const DisabledCheckedCheckbox: CheckboxStory = {
args: {
checked: true,
disabled: true,
},
};

export const DisabledUncheckedCheckbox: CheckboxStory = {
args: {
checked: false,
disabled: true,
},
};

export const Playground: CheckboxStory = {};

0 comments on commit e968159

Please sign in to comment.