/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ // import React, { useState } from "react"; // import { storiesOf } from "@storybook/react"; // import Toast from "./Toast"; // import ToastButtons from "./ToastButtons"; // import ToastButton from "./ToastButton"; // import { types } from "./themes"; // import ToastArea from "./ToastArea"; // import ToastNotification from "./ToastNotification"; // // const toastStories = storiesOf("Toast", module); // // const AnimatedToast = () => ( // // Awesome animated Toast // // ); // // const Animator = () => { // const [display, setDisplay] = useState(false); // // return ( //
// {display && } // //
// ); // }; // // const Closeable = () => { // const [show, setShow] = useState(true); // // const hide = () => { // setShow(false); // }; // // if (!show) { // return null; // } // // return ( // //

Close the message with a click

// // // Click to close // // //
// ); // }; // // toastStories.add("Open/Close", () => ); // toastStories.add("Click to close", () => ); // // types.forEach((type) => { // toastStories.add(type.charAt(0).toUpperCase() + type.slice(1), () => ( // //

The underlying Pull-Request has changed. Press reload to see the changes.

//

Warning: Non saved modification will be lost.

// // Reload // Ignore // //
// )); // }); // // toastStories.add("Multiple", () => ( // // {types.map((type) => ( // //

The notification received.

//
// ))} //
// )); import React, { useState } from "react"; import type { Meta, StoryObj } from "@storybook/react"; import Toast from "./Toast"; import ToastButtons from "./ToastButtons"; import ToastButton from "./ToastButton"; import { types } from "./themes"; import ToastArea from "./ToastArea"; import ToastNotification from "./ToastNotification"; // --- Helfer-Komponenten (aus der Original-Story übernommen) --- const OpenCloseExample = () => { const [display, setDisplay] = useState(false); return (
{display && ( Awesome animated Toast )}
); }; const ClickToCloseExample = () => { const [show, setShow] = useState(true); if (!show) { return

Toast wurde geschlossen.

; } return (

Close the message with a click

setShow(false)}> Click to close
); }; // --- Storybook Metadaten --- const meta: Meta = { title: "Components/Toast", component: Toast, decorators: [(Story) =>
{Story()}
], tags: ["autodocs"], }; export default meta; // --- Story-Definitionen --- type Story = StoryObj; // Basis-Props für die verschiedenen Toast-Typen const baseArgs = { title: "New Changes", children: ( <>

The underlying Pull-Request has changed. Press reload to see the changes.

Warning: Non saved modification will be lost.

Reload Ignore ), }; // Anstatt einer Schleife erstellen wir explizite Stories für jeden Typ export const Primary: Story = { args: { ...baseArgs, type: "primary" } }; export const Success: Story = { args: { ...baseArgs, type: "success" } }; export const Info: Story = { args: { ...baseArgs, type: "info" } }; export const Warning: Story = { args: { ...baseArgs, type: "warning" } }; export const Danger: Story = { args: { ...baseArgs, type: "danger" } }; // Stories mit eigener Logik verwenden eine `render`-Funktion export const OpenClose: Story = { name: "Open and Close Animation", render: () => , }; export const ClickToClose: Story = { name: "Click to Close", render: () => , }; export const Multiple: Story = { name: "Multiple Toasts in an Area", render: () => ( {types.map((type) => (

The notification received.

))}
), };