Skip to content

Commit 6072d85

Browse files
feat: implement level grouping
1 parent e5ba14f commit 6072d85

File tree

88 files changed

+208
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+208
-321
lines changed

.storybook/main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { StorybookConfig } from '@storybook/react-vite';
22
import { mergeConfig } from 'vite';
3+
import path from 'path';
34

45
const config: StorybookConfig = {
56
stories: [
@@ -27,7 +28,12 @@ const config: StorybookConfig = {
2728
},
2829
async viteFinal(baseConfig, { configType }) {
2930
return mergeConfig(baseConfig, {
30-
...(configType === 'PRODUCTION' ? { base: '/storybook/' } : {})
31+
...(configType === 'PRODUCTION' ? { base: '/storybook/' } : {}),
32+
resolve: {
33+
alias: {
34+
'@shared': path.resolve(__dirname, '../src', 'shared')
35+
}
36+
}
3137
});
3238
}
3339
};

.storybook/preview.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ const preview: Preview = {
1212
code: Code
1313
}
1414
},
15-
storySort: ['Introduction', 'Lessons', 'Recipes'],
15+
storySort: [
16+
'Introduction',
17+
'Lessons',
18+
['🥉 Bronze', '🥈 Silver', '🥇 Gold'],
19+
'Recipes'
20+
],
1621
controls: {
1722
matchers: {
1823
color: /(background|color)$/i,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc -b && vite build",
9-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
9+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
1010
"preview": "vite preview",
1111
"storybook": "storybook dev -p 6006",
1212
"build-storybook": "npm run build && storybook build -o dist/storybook",

src/course/01-introduction/01-Welcome.mdx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,26 @@ Each lesson is broken down in an exercise file and a final file. The exercise fi
3838

3939
### Lessons
4040

41-
- 01 - [Conditionally rendering pattern](?path=/docs/lessons-01-conditional-rendering-pattern-01-lesson--docs)
42-
- 02 - [Props combination pattern](?path=/docs/lessons-02-props-combination-pattern-01-lesson--docs)
43-
- 03 - [Render props pattern](?path=/docs/lessons-03-render-props-pattern-01-lesson--docs)
44-
- 04 - [Presentational and container components pattern](?path=/docs/lessons-04-presentational-container-pattern-01-lesson--docs)
45-
- 05 - [React Hooks pattern](?path=/docs/lessons-05-hooks-pattern-01-lesson--docs)
46-
- 06 - [Controlled component pattern](?path=/docs/lessons-06-controlled-components-pattern-01-lesson--docs)
47-
- 07 - [Higher order component](?path=/docs/lessons-07-higher-order-components-pattern-01-lesson--docs)
48-
- 08 - [The Provider pattern](?path=/docs/lessons-08-provider-pattern-01-lesson--docs)
49-
- 09 - [The State Reducer pattern](?path=/docs/lessons-09-state-reducer-pattern-01-lesson--docs)
50-
- 10 - [Compound components pattern](?path=/docs/lessons-10-compound-components-pattern-01-lesson--docs)
51-
- 11 - [Slots pattern](?path=/docs/lessons-11-slots-01-lesson--docs)
52-
- 12 - [Portals pattern](?path=/docs/lessons-12-portals-01-lesson--docs)
41+
#### 🥉 Bronze
42+
43+
- [Conditionally rendering pattern](?path=/docs/lessons-🥉-bronze-conditional-rendering-pattern-01-lesson--docs)
44+
- [Props combination pattern](?path=/docs/lessons-🥉-bronze-props-combination-pattern-01-lesson--docs)
45+
- [React Hooks pattern](?path=/docs/lessons-🥉-bronze-hooks-pattern-01-lesson--docs)
46+
- [Presentational and container components pattern](?path=/docs/lessons-🥉-bronze-presentational-container-pattern-01-lesson--docs)
47+
- [Slots pattern](?path=/docs/lessons-🥉-bronze-slots-01-lesson--docs)
48+
49+
#### 🥈 Silver
50+
51+
- [Compound components pattern](?path=/docs/lessons-🥈-sliver-compound-components-pattern-01-lesson--docs)
52+
- [Controlled component pattern](?path=/docs/lessons-🥈-sliver-controlled-components-pattern-01-lesson--docs)
53+
- [Render props pattern](?path=/docs/lessons-🥈-sliver-render-props-pattern-01-lesson--docs)
54+
- [The Provider pattern](?path=/docs/lessons-🥈-sliver-provider-pattern-01-lesson--docs)
55+
- [The State Reducer pattern](?path=/docs/lessons-🥈-sliver-state-reducer-pattern-01-lesson--docs)
56+
- [Portals pattern](?path=/docs/lessons-🥈-sliver-portals-01-lesson--docs)
57+
58+
#### 🥇 Gold
59+
60+
- [Higher order component](?path=/docs/lessons-🥇-gold-higher-order-components-pattern-01-lesson--docs)
5361

5462
## FAQs
5563

src/course/01-introduction/03-LessonStructure.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Meta } from '@storybook/blocks';
44

55
# Lesson Structure
66

7-
As you will have already noticed in the sidebar that there is a "Lessons" section. Each lesson will get slightly more and more complex as we go on so it eases us into the course. Each lesson will also contain an "exercise.(tsx)" file and a "final.(tsx)".
7+
As you will have already noticed in the sidebar that there is a "Lessons" section. Each lesson sits within a Bronze/Silver/Gold tier folder which mirrors to the complexity of that pattern & we provide more challenging exercises. Each lesson will also contain an "exercise" folder and a "final" folder.
88

99
## Exercise files
1010

@@ -60,6 +60,6 @@ const Component = () => {
6060

6161
## Final files
6262

63-
If you get stuck do not worry! Each lesson.mdx file will have a video going through it all and there will be a final.tsx file showing the final solution of each exercise.
63+
If you get stuck do not worry! Each lesson.mdx file will have a video going through it all and there will be a final folder in the lesson showing the final solution of each exercise.
6464

6565
[Let's get started](?path=/docs/lessons-01-conditional-rendering-pattern-01-lesson--docs)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { userEvent, within, expect } from '@storybook/test';
4+
5+
import { ComponentOne } from './exercise';
6+
7+
const meta: Meta<typeof ComponentOne> = {
8+
title:
9+
'Lessons/🥉 Bronze/Conditional Rendering Pattern/02-Exercise',
10+
component: ComponentOne
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof ComponentOne>;
15+
16+
const username = 'John Doe';
17+
18+
/*
19+
* See https://storybook.js.org/docs/writing-stories/play-function#working-with-the-canvas
20+
* to learn more about using the canvasElement to query the DOM
21+
*/
22+
export const Default: Story = {
23+
play: async ({ canvasElement }) => {
24+
const canvas = within(canvasElement);
25+
26+
await userEvent.click(
27+
canvas.getByRole('button', { name: 'Login' })
28+
);
29+
30+
await expect(
31+
canvas.getByText(`Welcome ${username}`)
32+
).toBeInTheDocument();
33+
await expect(
34+
canvas.queryByRole('button', { name: 'Login' })
35+
).toBeNull();
36+
37+
await userEvent.click(
38+
canvas.getByRole('button', { name: 'Logout' })
39+
);
40+
41+
await expect(
42+
canvas.queryByText(`Welcome ${username}`)
43+
).toBeNull();
44+
await expect(
45+
canvas.queryByRole('button', { name: 'Logout' })
46+
).toBeNull();
47+
},
48+
args: {
49+
username
50+
}
51+
};

src/course/02- lessons/01-ConditionalRendering/exercise.tsx renamed to src/course/02- lessons/01-Bronze/ConditionalRendering/exercise/exercise.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button } from '../../../shared/components/Button/Button.component';
1+
import { Button } from '@shared/components/Button/Button.component';
22

33
interface IComponentProps {
44
username: string;

src/course/02-solutions/01-ConditionalRendering/final.stories.tsx renamed to src/course/02- lessons/01-Bronze/ConditionalRendering/final/final.stories.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22

33
import { userEvent, within, expect } from '@storybook/test';
4-
54
import { ComponentOne } from './final';
65

76
const meta: Meta<typeof ComponentOne> = {
8-
title: 'Lessons/01 - Conditional Rendering Pattern/03-Final',
7+
title: 'Lessons/🥉 Bronze/Conditional Rendering Pattern/03-Final',
98
component: ComponentOne
109
};
1110

@@ -22,15 +21,27 @@ export const Default: Story = {
2221
play: async ({ canvasElement }) => {
2322
const canvas = within(canvasElement);
2423

25-
await userEvent.click(canvas.getByRole('button', { name: 'Login' }));
26-
27-
await expect(canvas.getByText(`Welcome ${username}`)).toBeInTheDocument();
28-
await expect(canvas.queryByRole('button', { name: 'Login' })).toBeNull();
29-
30-
await userEvent.click(canvas.getByRole('button', { name: 'Logout' }));
31-
32-
await expect(canvas.queryByText(`Welcome ${username}`)).toBeNull();
33-
await expect(canvas.queryByRole('button', { name: 'Logout' })).toBeNull();
24+
await userEvent.click(
25+
canvas.getByRole('button', { name: 'Login' })
26+
);
27+
28+
await expect(
29+
canvas.getByText(`Welcome ${username}`)
30+
).toBeInTheDocument();
31+
await expect(
32+
canvas.queryByRole('button', { name: 'Login' })
33+
).toBeNull();
34+
35+
await userEvent.click(
36+
canvas.getByRole('button', { name: 'Logout' })
37+
);
38+
39+
await expect(
40+
canvas.queryByText(`Welcome ${username}`)
41+
).toBeNull();
42+
await expect(
43+
canvas.queryByRole('button', { name: 'Logout' })
44+
).toBeNull();
3445
},
3546
args: {
3647
username

src/course/02-solutions/01-ConditionalRendering/final.tsx renamed to src/course/02- lessons/01-Bronze/ConditionalRendering/final/final.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { Button } from '../../../shared/components/Button/Button.component';
2+
import { Button } from '@shared/components/Button/Button.component';
33

44
interface IComponentProps {
55
username: string;

src/course/02- lessons/01-ConditionalRendering/lesson.mdx renamed to src/course/02- lessons/01-Bronze/ConditionalRendering/lesson.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta } from '@storybook/blocks';
22

3-
<Meta title="Lessons/01 - Conditional Rendering Pattern/01-Lesson" />
3+
<Meta title="Lessons/🥉 Bronze/Conditional Rendering Pattern/01-Lesson" />
44

55
# Conditional Rendering Pattern
66

0 commit comments

Comments
 (0)