2024-08-23 13:31:37 +00:00
|
|
|
import type { Meta } from "@storybook/react";
|
2024-08-21 15:14:40 +00:00
|
|
|
import { Toast } from "../src/components/Toast/Toast";
|
2024-08-23 13:31:37 +00:00
|
|
|
import { useState } from "react";
|
2024-08-20 13:57:58 +00:00
|
|
|
|
|
|
|
const meta = {
|
|
|
|
title: "Overlays/Toast",
|
|
|
|
component: Toast,
|
|
|
|
parameters: {
|
|
|
|
layout: "fullscreen",
|
|
|
|
inlineStories: false,
|
|
|
|
iframeHeight: "425px",
|
|
|
|
},
|
|
|
|
tags: ["autodocs"],
|
|
|
|
argTypes: {},
|
|
|
|
args: {},
|
|
|
|
} satisfies Meta<typeof Toast>;
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
|
|
|
const Template = () => {
|
|
|
|
const [time, setTime] = useState(0);
|
|
|
|
|
2024-08-23 13:31:37 +00:00
|
|
|
const onClick = () => setTime(Date.now());
|
2024-08-20 13:57:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ padding: "2rem" }}>
|
|
|
|
<button onClick={onClick}>Make Toast</button>
|
|
|
|
<Toast
|
2024-08-30 14:10:17 +00:00
|
|
|
variant="success"
|
2024-08-20 13:57:58 +00:00
|
|
|
message="Toast displayed with success"
|
|
|
|
time={time}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-08-30 14:10:17 +00:00
|
|
|
export const Success = Template.bind({});
|
|
|
|
|
|
|
|
const ErrorTemplate = () => {
|
|
|
|
const [time, setTime] = useState(0);
|
|
|
|
|
|
|
|
const onClick = () => setTime(Date.now());
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ padding: "2rem" }}>
|
|
|
|
<button onClick={onClick}>Make Toast</button>
|
|
|
|
<Toast variant="error" message="Toast displayed with error" time={time} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Error = ErrorTemplate.bind({});
|