Skip to content

Commit

Permalink
change toast story render
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarcMilletScality committed Jun 4, 2024
1 parent 3ceadc9 commit f0b139f
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions stories/toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,39 @@ export default {
},
};

const Template = (args: Omit<ToastProps, 'open' | 'onClose'>) => {
const [open, setOpen] = useState(false);
const color = useGetBackgroundColor(args.status || 'info');
const iconName =
args.status === 'error'
? 'Times-circle'
: args.status === 'warning'
? 'Exclamation-circle'
: args.status === 'success'
? 'Check-circle'
: 'Info-circle';
return (
<div style={{ height: '30vh' }}>
{!open && (
<Button label={'Open my custom toast'} onClick={() => setOpen(true)} />
)}
<Toast
open={open}
onClose={() => setOpen(false)}
icon={<Icon name={iconName} color={color} />}
{...args}
/>
</div>
);
export const CustomToast = {
render: (args) => {
const [open, setOpen] = useState(false);
const color = useGetBackgroundColor(args.status || 'info');
const iconName =
args.status === 'error'
? 'Times-circle'
: args.status === 'warning'
? 'Exclamation-circle'
: args.status === 'success'
? 'Check-circle'
: 'Info-circle';
return (
<div style={{ height: '30vh' }}>
{!open && (
<Button
label={'Open my custom toast'}
onClick={() => setOpen(true)}
/>
)}
<Toast
open={open}
onClose={() => setOpen(false)}
icon={<Icon name={iconName} color={color} />}
{...args}
/>
</div>
);
},
args: {
message: <BasicText>{"I'm a custom toast"}</BasicText>,
status: 'info',
},
};

export const SimpleToast = {
Expand Down Expand Up @@ -134,11 +143,3 @@ export const ToastWithProgressBar = {
withProgressBar: true,
},
};

export const CustomToast: {
args?: Omit<ToastProps, 'open' | 'onClose'>;
} = Template.bind({});
CustomToast.args = {
message: <BasicText>{"I'm a custom toast"}</BasicText>,
status: 'info',
};

0 comments on commit f0b139f

Please sign in to comment.