mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
added storybook stories for diff
This commit is contained in:
@@ -2,7 +2,6 @@ import React, { ReactNode } from "react";
|
||||
import Button from "./Button";
|
||||
import { storiesOf } from "@storybook/react";
|
||||
import styled from "styled-components";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import AddButton from "./AddButton";
|
||||
import CreateButton from "./CreateButton";
|
||||
import DeleteButton from "./DeleteButton";
|
||||
@@ -17,14 +16,9 @@ const Spacing = styled.div`
|
||||
padding: 1em;
|
||||
`;
|
||||
|
||||
type StoryFn = () => ReactNode;
|
||||
|
||||
const RoutingDecorator = (story: StoryFn) => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>;
|
||||
|
||||
const SpacingDecorator = (story: StoryFn) => <Spacing>{story()}</Spacing>;
|
||||
const SpacingDecorator = (story: () => ReactNode) => <Spacing>{story()}</Spacing>;
|
||||
|
||||
storiesOf("Buttons|Button", module)
|
||||
.addDecorator(RoutingDecorator)
|
||||
.add("Colors", () => (
|
||||
<div>
|
||||
{colors.map(color => (
|
||||
@@ -44,7 +38,6 @@ storiesOf("Buttons|Button", module)
|
||||
|
||||
const buttonStory = (name: string, storyFn: () => ReactElement) => {
|
||||
return storiesOf("Buttons|" + name, module)
|
||||
.addDecorator(RoutingDecorator)
|
||||
.addDecorator(SpacingDecorator)
|
||||
.add("Default", storyFn);
|
||||
};
|
||||
@@ -53,7 +46,7 @@ buttonStory("CreateButton", () => <CreateButton>Create</CreateButton>);
|
||||
buttonStory("DeleteButton", () => <DeleteButton>Delete</DeleteButton>);
|
||||
buttonStory("DownloadButton", () => <DownloadButton displayName="Download" disabled={false} url="" />).add(
|
||||
"Disabled",
|
||||
() => <DownloadButton displayName="Download" disabled={true} url=""></DownloadButton>
|
||||
() => <DownloadButton displayName="Download" disabled={true} url="" />
|
||||
);
|
||||
buttonStory("EditButton", () => <EditButton>Edit</EditButton>);
|
||||
buttonStory("SubmitButton", () => <SubmitButton>Submit</SubmitButton>);
|
||||
|
||||
Reference in New Issue
Block a user