Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve storybook entry #161

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import { Meta, StoryObj } from "@storybook/react";

import { OakPupilJourneyList } from "./OakPupilJourneyList";

import { OakPupilJourneyListItem } from "@/components/organisms/pupil/OakPupilJourneyListItem";

const meta: Meta<typeof OakPupilJourneyList> = {
component: OakPupilJourneyList,
tags: ["autodocs"],
title: "components/organisms/pupil/OakPupilJourneyList",
argTypes: {
phase: { control: { options: ["primary", "secondary"] } },
},
parameters: {
controls: {
include: ["phase"],
},
},
};
export default meta;

type Story = StoryObj<typeof OakPupilJourneyList>;

export const Default: Story = {
render: (args) => (
<OakPupilJourneyList {...args}>
<OakPupilJourneyListItem title="Lesson 1" index={1} href="#" />
<OakPupilJourneyListItem title="Lesson 2" index={2} href="#" />
<OakPupilJourneyListItem title="Lesson 3" index={3} href="#" />
</OakPupilJourneyList>
),
args: {
phase: "primary",
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import "@testing-library/jest-dom";
import { create } from "react-test-renderer";

import { OakPupilJourneyList } from "./OakPupilJourneyList";

import renderWithTheme from "@/test-helpers/renderWithTheme";
import { OakThemeProvider } from "@/components/atoms";
import { oakDefaultTheme } from "@/styles";

describe("OakPupilJourneyList", () => {
it("should render successfully", () => {
const { getByText } = renderWithTheme(
<OakPupilJourneyList phase="primary">
<p>Hello World</p>
</OakPupilJourneyList>,
);
expect(getByText("Hello World")).toBeInTheDocument();
});

it("matches snapshot", () => {
const tree = create(
<OakThemeProvider theme={oakDefaultTheme}>
<OakPupilJourneyList phase="primary">
<p>Hello World</p>
</OakPupilJourneyList>
</OakThemeProvider>,
).toJSON();
expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";

import { OakFlex } from "@/components/atoms/OakFlex";

export type OakPupilJourneyListProps = {
children: React.ReactNode;
phase: "primary" | "secondary";
};

/**
*
* A styled list container for use with OakPupilJourneyListItems
*
*/

export const OakPupilJourneyList = ({
children,
phase,
}: OakPupilJourneyListProps) => {
const backgroundColor =
phase === "primary" ? "bg-decorative4-subdued" : "bg-decorative3-subdued";
return (
<OakFlex
$flexDirection={"column"}
$pa={"inner-padding-m"}
$background={backgroundColor}
$borderRadius={"border-radius-l"}
$gap={"space-between-s"}
>
{children}
</OakFlex>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`OakPupilJourneyList matches snapshot 1`] = `
.c0 {
padding: 1rem;
background: #e5d1e0;
border-radius: 1rem;
font-family: Lexend,sans-serif;
}

.c1 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
gap: 1rem;
}

<div
className="c0 c1"
>
<p>
Hello World
</p>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./OakPupilJourneyList";
1 change: 1 addition & 0 deletions src/components/organisms/pupil/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from "./OakPupilJourneyListItem";
export * from "./OakPupilJourneyYearButton";
export * from "./OakPupilJourneySubjectButton";
export * from "./OakPreviousLessonsHeading";
export * from "./OakPupilJourneyList";