Skip to content

Commit

Permalink
update storybook files
Browse files Browse the repository at this point in the history
  • Loading branch information
ghernandez345 committed Jan 15, 2025
1 parent fa5d394 commit 02bb670
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 265 deletions.
15 changes: 7 additions & 8 deletions frontend/components/FlashMessage/FlashMessage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { noop } from "lodash";
import { Meta, StoryObj } from "@storybook/react";

import FlashMessage from ".";

import { IFlashMessage } from "./FlashMessage";

import "../../index.scss";

export default {
const meta: Meta<typeof FlashMessage> = {
component: FlashMessage,
title: "Components/FlashMessage",
argTypes: {
Expand All @@ -28,8 +25,10 @@ export default {
isVisible: true,
},
},
} as Meta;
};

export default meta;

const Template: Story<IFlashMessage> = (props) => <FlashMessage {...props} />;
type Story = StoryObj<typeof FlashMessage>;

export const Default = Template.bind({});
export const Default: Story = {};
13 changes: 7 additions & 6 deletions frontend/components/FleetAce/FleetAce.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import { noop } from "lodash";

import FleetAce from ".";
import { IFleetAceProps } from "./FleetAce";

import "../../index.scss";

export default {
const meta: Meta<typeof FleetAce> = {
component: FleetAce,
title: "Components/FleetAce",
args: {
Expand All @@ -26,8 +25,10 @@ export default {
onChange: noop,
handleSubmit: noop,
},
} as Meta;
};

const Template: Story<IFleetAceProps> = (props) => <FleetAce {...props} />;
export default meta;

export const Default = Template.bind({});
type Story = StoryObj<typeof FleetAce>;

export const Default: Story = {};
21 changes: 11 additions & 10 deletions frontend/components/InfoBanner/InfoBanner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";

import InfoBanner from ".";
import { IInfoBannerProps } from "./InfoBanner";

import "../../index.scss";

export default {
const meta: Meta<typeof InfoBanner> = {
component: InfoBanner,
title: "Components/InfoBanner",
} as Meta;
};

const Template: Story<IInfoBannerProps> = (props) => (
<InfoBanner {...props}>
<div>This is an Info Banner.</div>
</InfoBanner>
);
export default meta;

export const Default = Template.bind({});
type Story = StoryObj<typeof InfoBanner>;

export const Default: Story = {
args: {
children: <div>This is an Info Banner.</div>,
},
};
28 changes: 18 additions & 10 deletions frontend/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import { noop } from "lodash";

import Modal from ".";
import { IModalProps } from "./Modal";

import "../../index.scss";

export default {
const meta: Meta<typeof Modal> = {
component: Modal,
title: "Components/Modal",
args: {
title: "Test modal",
className: "",
onExit: noop,
},
} as Meta;
};

const Template: Story<IModalProps> = (props) => (
<Modal {...props}>
<div>This is a test description with lots of information.</div>
</Modal>
);
export default meta;

export const Default = Template.bind({});
type Story = StoryObj<typeof Modal>;

export const Default: Story = {
decorators: [
(Story) => (
<div style={{ height: "300px" }}>
<Story />
</div>
),
],
args: {
children: <div>This is a test description with lots of information.</div>,
},
};
95 changes: 49 additions & 46 deletions frontend/components/ModalFooter/ModalFooter.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
/* eslint-disable no-alert */
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";

import Button from "components/buttons/Button";
import Icon from "components/Icon";
import ActionsDropdown from "components/ActionsDropdown";
import ModalFooter from "./ModalFooter";

export default {
const meta: Meta<typeof ModalFooter> = {
title: "Components/ModalFooter",
component: ModalFooter,
} as Meta;
};

export default meta;

const Template: Story = (args) => (
<ModalFooter primaryButtons={<></>} {...args} />
);
type Story = StoryObj<typeof ModalFooter>;

export const Default = Template.bind({});
Default.args = {
primaryButtons: (
<>
<ActionsDropdown
className="modal-footer__manage-automations-dropdown"
onChange={(value) => alert(`Selected action: ${value}`)}
placeholder="More actions"
isSearchable={false}
options={[
{ value: "action1", label: "Action 1" },
{ value: "action2", label: "Action 2" },
]}
menuPlacement="top"
/>
<Button onClick={() => alert("Done clicked")} variant="brand">
Done
</Button>
</>
),
secondaryButtons: (
<>
<Button variant="icon" onClick={() => alert("Download clicked")}>
<Icon name="download" />
</Button>
<Button variant="icon" onClick={() => alert("Delete clicked")}>
<Icon name="trash" color="ui-fleet-black-75" />
</Button>
</>
),
isTopScrolling: false,
export const Default: Story = {
args: {
primaryButtons: (
<>
<ActionsDropdown
className="modal-footer__manage-automations-dropdown"
onChange={(value) => alert(`Selected action: ${value}`)}
placeholder="More actions"
isSearchable={false}
options={[
{ value: "action1", label: "Action 1" },
{ value: "action2", label: "Action 2" },
]}
menuPlacement="top"
/>
<Button onClick={() => alert("Done clicked")} variant="brand">
Done
</Button>
</>
),
secondaryButtons: (
<>
<Button variant="icon" onClick={() => alert("Download clicked")}>
<Icon name="download" />
</Button>
<Button variant="icon" onClick={() => alert("Delete clicked")}>
<Icon name="trash" color="ui-fleet-black-75" />
</Button>
</>
),
isTopScrolling: false,
},
};

export const WithTopScrolling = Template.bind({});
WithTopScrolling.args = {
...Default.args,
isTopScrolling: true,
export const WithTopScrolling: Story = {
args: {
...Default.args,
isTopScrolling: true,
},
};

export const WithoutSecondaryButtons = Template.bind({});
WithoutSecondaryButtons.args = {
primaryButtons: Default.args.primaryButtons,
secondaryButtons: undefined,
isTopScrolling: false,
export const WithoutSecondaryButtons: Story = {
args: {
primaryButtons: Default.args?.primaryButtons,
secondaryButtons: undefined,
isTopScrolling: false,
},
};
12 changes: 8 additions & 4 deletions frontend/components/Pagination/Pagination.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryFn } from "@storybook/react";
import { noop } from "lodash";

// @ts-ignore
Expand All @@ -14,7 +14,7 @@ interface IPaginationProps {
onPaginationChange: () => void;
}

export default {
const meta: Meta<IPaginationProps> = {
component: Pagination,
title: "Components/Pagination",
args: {
Expand All @@ -23,8 +23,12 @@ export default {
resultsOnCurrentPage: 10,
onPaginationChange: noop,
},
} as Meta;
};

const Template: Story<IPaginationProps> = (props) => <Pagination {...props} />;
export default meta;

const Template: StoryFn<IPaginationProps> = (props) => (
<Pagination {...props} />
);

export const Default = Template.bind({});
45 changes: 19 additions & 26 deletions frontend/components/TooltipWrapper/TooltipWrapper.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";

import TooltipWrapper from ".";

import "../../index.scss";

interface ITooltipWrapperProps {
children: React.ReactNode;
tipContent: React.ReactNode;
}

export default {
const meta: Meta<typeof TooltipWrapper> = {
component: TooltipWrapper,
title: "Components/TooltipWrapper",
args: {
tipContent: "This is an example tooltip.",
},
argTypes: {
position: {
options: [
Expand All @@ -35,21 +27,22 @@ export default {
control: "radio",
},
},
} as Meta;
};

// using line breaks to create space for top position
const Template: Story<ITooltipWrapperProps> = (props) => (
<>
<br />
<br />
<br />
<br />
<TooltipWrapper {...props}>Example text</TooltipWrapper>
<br />
<br />
<br />
<br />
</>
);
export default meta;

export const Default = Template.bind({});
type Story = StoryObj<typeof TooltipWrapper>;

export const Default: Story = {
args: {
tipContent: "This is an example tooltip.",
children: "Example text",
},
decorators: [
(Story) => (
<div style={{ margin: "4rem 0" }}>
<Story />
</div>
),
],
};
35 changes: 22 additions & 13 deletions frontend/components/buttons/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import { Meta, StoryObj } from "@storybook/react";
import { noop } from "lodash";

import Button from ".";
import { IButtonProps } from "./Button";

import "../../../index.scss";

export default {
component: Button,
const meta: Meta<typeof Button> = {
// TODO: change this after button is updated to a functional component. For
// some reason the typing is incorrect becuase Button is a class component.
component: Button as any,
title: "Components/Button",
argTypes: {
variant: {
Expand Down Expand Up @@ -47,14 +47,23 @@ export default {
title: "",
onClick: noop,
},
} as Meta;
};

const Template: Story<IButtonProps> = (props) => (
<Button {...props}>Click Here</Button>
);
export default meta;

export const Default = Template.bind({});
Default.args = { variant: "brand", type: "button" };
type Story = StoryObj<typeof Button>;

export const Disabled = Template.bind({});
Disabled.args = { ...Default.args, disabled: true };
export const Default: Story = {
args: {
variant: "brand",
type: "button",
children: "Click Here",
},
};

export const Disabled: Story = {
args: {
...Default.args,
disabled: true,
},
};
Loading

0 comments on commit 02bb670

Please sign in to comment.