Skip to content

Commit

Permalink
feat(page): Add Storybook file
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 16, 2024
1 parent 76c4f9d commit cd1aef9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions editor.planx.uk/src/@planx/components/Page/Page.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Meta, StoryObj } from "@storybook/react";
import React from "react";

import Wrapper from "../fixtures/Wrapper";
import Editor, { PAGE_SCHEMAS } from "./Editor";
import Public from "./Public";

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

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

export default meta;

type Story = StoryObj<typeof meta>;

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

export const Basic: Story = {
args: {
title:
"Tell us about your proposed advertisements",
description: "Please add your details below",
schemaName: "Advert consent",
fn: "MockFn",
schema: schemaFinder("Advert consent"),
},
};

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

0 comments on commit cd1aef9

Please sign in to comment.