Skip to content

Commit

Permalink
build(deps): add storybook (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahboom authored Apr 23, 2024
2 parents 47b4e69 + b19e1e7 commit 37b6398
Show file tree
Hide file tree
Showing 44 changed files with 30,889 additions and 8,737 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"plugin:react-hooks/recommended",
"prettier"
],
"ignorePatterns": ["**/*.stories.tsx"],
"ignorePatterns": [
"**/*.mdx",
"**/*.stories.(ts,tsx)",
"src/stories/**",
"src/modules/*.stories.(js,ts,jsx,tsx)",
"src/modules/components/*.stories.(js,ts,jsx,tsx)"
],
"plugins": ["react-hooks"],
"overrides": [
// Only use Testing Library lint rules in test files
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check prettify code
uses: creyD/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reviewdog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: reviewdog/action-eslint@v1
with:
reporter: github-check
eslint_flags: "src/"
eslint_flags: "src/ --ignore-pattern '**/*.stories.{js,jsx,ts,tsx}' --ignore-pattern '**/*.mdx'"

action-lint:
name: Action lint
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.env.production.local

npm-debug.log*
*storybook.log*
yarn-debug.log*
yarn-error.log*

Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build*
node_modules*
.next*
**/generated/**
LICENSE
.gitignore
.tekton
33 changes: 33 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { StorybookConfig } from "@storybook/nextjs";
import path from "path";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/nextjs",
options: {},
},
docs: {
autodocs: "tag",
},
webpackFinal: async config => {
if (config.resolve) {
config.resolve.alias = {
...config.resolve.alias,
"@": path.resolve(__dirname, "../src"),
react: path.resolve("./node_modules/react"),
"react-dom": path.resolve("./node_modules/react-dom"),
"./src/modules/x509/decode": require.resolve(
"../src/modules/x509/decode",
),
};
}
return config;
},
};
export default config;
21 changes: 21 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "@patternfly/patternfly/patternfly.css";
import "@patternfly/patternfly/utilities/Accessibility/accessibility.css";
import "@patternfly/patternfly/utilities/Display/display.css";
import "@patternfly/patternfly/utilities/Flex/flex.css";
import "@patternfly/patternfly/utilities/Sizing/sizing.css";
import "@patternfly/patternfly/utilities/Spacing/spacing.css";
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Launches the test runner in the interactive watch mode.

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

## Stories

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).

To run Storybook locally: `npm run storybook`

```bash
npm run storybook
```

## Deploy

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

0 comments on commit 37b6398

Please sign in to comment.