Skip to content

Commit 37b6398

Browse files
authored
build(deps): add storybook (#53)
2 parents 47b4e69 + b19e1e7 commit 37b6398

Some content is hidden

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

44 files changed

+30889
-8737
lines changed

.eslintrc.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
"plugin:react-hooks/recommended",
66
"prettier"
77
],
8-
"ignorePatterns": ["**/*.stories.tsx"],
8+
"ignorePatterns": [
9+
"**/*.mdx",
10+
"**/*.stories.(ts,tsx)",
11+
"src/stories/**",
12+
"src/modules/*.stories.(js,ts,jsx,tsx)",
13+
"src/modules/components/*.stories.(js,ts,jsx,tsx)"
14+
],
915
"plugins": ["react-hooks"],
1016
"overrides": [
1117
// Only use Testing Library lint rules in test files

.github/workflows/format.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
17+
1718
- name: Check prettify code
1819
uses: creyD/prettier_action@v4.3
1920
with:

.github/workflows/reviewdog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: reviewdog/action-eslint@v1
2121
with:
2222
reporter: github-check
23-
eslint_flags: "src/"
23+
eslint_flags: "src/ --ignore-pattern '**/*.stories.{js,jsx,ts,tsx}' --ignore-pattern '**/*.mdx'"
2424

2525
action-lint:
2626
name: Action lint

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.env.production.local
2121

2222
npm-debug.log*
23+
*storybook.log*
2324
yarn-debug.log*
2425
yarn-error.log*
2526

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
build*
33
node_modules*
44
.next*
5-
**/generated/**
65
LICENSE
76
.gitignore
87
.tekton

.storybook/main.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { StorybookConfig } from "@storybook/nextjs";
2+
import path from "path";
3+
4+
const config: StorybookConfig = {
5+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
6+
addons: [
7+
"@storybook/addon-links",
8+
"@storybook/addon-essentials",
9+
"@storybook/addon-interactions",
10+
],
11+
framework: {
12+
name: "@storybook/nextjs",
13+
options: {},
14+
},
15+
docs: {
16+
autodocs: "tag",
17+
},
18+
webpackFinal: async config => {
19+
if (config.resolve) {
20+
config.resolve.alias = {
21+
...config.resolve.alias,
22+
"@": path.resolve(__dirname, "../src"),
23+
react: path.resolve("./node_modules/react"),
24+
"react-dom": path.resolve("./node_modules/react-dom"),
25+
"./src/modules/x509/decode": require.resolve(
26+
"../src/modules/x509/decode",
27+
),
28+
};
29+
}
30+
return config;
31+
},
32+
};
33+
export default config;

.storybook/preview.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "@patternfly/patternfly/patternfly.css";
2+
import "@patternfly/patternfly/utilities/Accessibility/accessibility.css";
3+
import "@patternfly/patternfly/utilities/Display/display.css";
4+
import "@patternfly/patternfly/utilities/Flex/flex.css";
5+
import "@patternfly/patternfly/utilities/Sizing/sizing.css";
6+
import "@patternfly/patternfly/utilities/Spacing/spacing.css";
7+
import type { Preview } from "@storybook/react";
8+
9+
const preview: Preview = {
10+
parameters: {
11+
actions: { argTypesRegex: "^on[A-Z].*" },
12+
controls: {
13+
matchers: {
14+
color: /(background|color)$/i,
15+
date: /Date$/,
16+
},
17+
},
18+
},
19+
};
20+
21+
export default preview;

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ Launches the test runner in the interactive watch mode.
4242

4343
Tests are co-located and live as closely to corresponding code as possible.
4444

45+
## Stories
46+
47+
We use [Storybook](https://storybook.js.org/) for [Component Driven Development](https://www.componentdriven.org/) (CDD) where possible. Storybook makes it easy to keep presentational components isolated. You can learn more about how to create a story for your UI component [here](https://storybook.js.org/docs/react/writing-stories/introduction).
48+
49+
To run Storybook locally: `npm run storybook`
50+
51+
```bash
52+
npm run storybook
53+
```
54+
4555
## Deploy
4656

4757
The app is based on [Next.JS](https://nextjs.org/) and is automatically built & deployed to GitHub Pages when pushing to the `main` branch.

0 commit comments

Comments
 (0)