-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from oaknational/feat/pupil-679/pupil-journey…
…-list docs: improve storybook entry
- Loading branch information
Showing
6 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/components/organisms/pupil/OakPupilJourneyList/OakPupilJourneyList.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/components/organisms/pupil/OakPupilJourneyList/OakPupilJourneyList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
src/components/organisms/pupil/OakPupilJourneyList/OakPupilJourneyList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
...nents/organisms/pupil/OakPupilJourneyList/__snapshots__/OakPupilJourneyList.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./OakPupilJourneyList"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters