Skip to content

Commit

Permalink
feat: List Component Storybook (#3509)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Aug 14, 2024
1 parent 17213d1 commit 6cac0af
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion editor.planx.uk/src/@planx/components/List/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const SCHEMAS = [
{ name: "Protected spaces (GLA)", schema: ProtectedSpaceGLA },
{ name: "Open spaces (GLA)", schema: OpenSpaceGLA },
{ name: "Proposed advertisements", schema: ProposedAdvertisements },
];
] as const;

function ListComponent(props: Props) {
const formik = useFormik({
Expand Down
50 changes: 50 additions & 0 deletions editor.planx.uk/src/@planx/components/List/Public/List.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Meta, StoryObj } from "@storybook/react";
import React from "react";

import Wrapper from "../../fixtures/Wrapper";
import { SCHEMAS } from "../Editor";
import Editor from "../Editor";
import ListComponent from "../Public";
import Public from "./";

const meta = {
title: "PlanX Components/List",
component: ListComponent,
} satisfies Meta<typeof ListComponent>;

type SchemaItem = (typeof SCHEMAS)[number];
type SchemaNames = SchemaItem["name"];

export default meta;

type Story = StoryObj<typeof meta>;

const schemaFinder = (name: SchemaNames) => {
const schemaObj = SCHEMAS.find((schema) => schema.name === name)?.schema;
return schemaObj || SCHEMAS[0].schema;
};

export const Basic: Story = {
args: {
title:
"Describe any residential units that are being removed or lost as part of the development",
description: "Add one or many units below",
schemaName: "Residential units (GLA) - Removed",
fn: "MockFn",
schema: schemaFinder("Residential units (GLA) - Removed"),
},
};

export const SingularItem: Story = {
args: {
title: "Describe the advertisements you want to add",
description: "Complete the questions below",
schemaName: "Proposed advertisements",
fn: "MockFn",
schema: schemaFinder("Proposed advertisements"),
},
};

export const WithEditor = () => {
return <Wrapper Editor={Editor} Public={Public} />;
};

0 comments on commit 6cac0af

Please sign in to comment.