Skip to content

Commit 34413e7

Browse files
authored
Migrate to Storybook 7 (#655)
1 parent 2a12454 commit 34413e7

File tree

169 files changed

+32946
-48051
lines changed

Some content is hidden

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

169 files changed

+32946
-48051
lines changed

.eslintrc.js

+35
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,41 @@ module.exports = {
108108
format: ["PascalCase", "UPPER_CASE"],
109109
},
110110
],
111+
"@typescript-eslint/ban-types": [
112+
"error",
113+
{
114+
types: {
115+
"{}": false,
116+
},
117+
extendDefaults: true,
118+
},
119+
],
120+
},
121+
},
122+
{
123+
// Declare an override that applies to TypeScript files only
124+
files: [".storybook/**/*.{ts,tsx}"],
125+
parser: "@typescript-eslint/parser",
126+
parserOptions: {
127+
// The "project" path is resolved relative to parserOptions.tsconfigRootDir.
128+
// Your local .eslintrc.js must specify that parserOptions.tsconfigRootDir=__dirname.
129+
tsconfigRootDir: __dirname + "/.storybook",
130+
project: ["./tsconfig.json"],
131+
132+
// Allow parsing of newer ECMAScript constructs used in TypeScript source code. Although tsconfig.json
133+
// may allow only a small subset of ES2018 features, this liberal setting ensures that ESLint will correctly
134+
// parse whatever is encountered.
135+
ecmaVersion: "latest",
136+
137+
sourceType: "module",
138+
},
139+
},
140+
{
141+
files: ["**/*.stories.tsx"],
142+
rules: {
143+
"react-hooks/rules-of-hooks": "off",
144+
"no-alert": "off",
145+
"unicorn/consistent-function-scoping": "off",
111146
},
112147
},
113148
{

.github/workflows/codeql-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
# The branches below must be a subset of the branches above
1919
branches: [master]
2020
schedule:
21-
- cron: '20 5 * * 2'
21+
- cron: "20 5 * * 2"
2222

2323
jobs:
2424
analyze:
@@ -70,4 +70,4 @@ jobs:
7070
- name: Perform CodeQL Analysis
7171
uses: github/codeql-action/analyze@v2
7272
with:
73-
category: '/language:${{matrix.language}}'
73+
category: "/language:${{matrix.language}}"

.github/workflows/reviewdog.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
reporter: github-pr-review
2727
level: warning
2828
fail_on_error: false
29-
prettier_flags: '**/*.+(js|json|ts|tsx|md|mdx|yml)'
29+
prettier_flags: "**/*.+(js|json|ts|tsx|md|mdx|yml)"
3030

3131
- name: ESLint
3232
uses: reviewdog/action-eslint@v1
@@ -46,7 +46,7 @@ jobs:
4646
filter_mode: file
4747
level: warning
4848
fail_on_error: false
49-
stylelint_input: '**/*.+(ts|tsx)'
49+
stylelint_input: "**/*.+(ts|tsx)"
5050

5151
- name: TypeScript
5252
uses: EPMatt/reviewdog-action-tsc@v1

.storybook/global.css

-3
This file was deleted.

.storybook/main.js

-19
This file was deleted.

.storybook/main.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
3+
const config: StorybookConfig = {
4+
stories: ["../src/**/*.mdx", "../src/**/*.@(story|stories).@(ts|tsx)"],
5+
addons: [
6+
{
7+
name: "@storybook/addon-essentials",
8+
options: {
9+
backgrounds: false,
10+
},
11+
},
12+
"@storybook/addon-mdx-gfm",
13+
],
14+
15+
staticDirs: ["../public"],
16+
17+
framework: {
18+
name: "@storybook/react-vite",
19+
options: {
20+
legacyRootApi: true,
21+
},
22+
},
23+
24+
core: {
25+
disableTelemetry: true,
26+
},
27+
28+
docs: {
29+
autodocs: "tag",
30+
defaultName: "Docs",
31+
},
32+
};
33+
34+
export default config;

.storybook/manager-head.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<meta charset="utf-8" />
2+
<link rel="icon" href="favicon.ico" />
3+
<meta name="viewport" content="width=device-width, initial-scale=1" />
4+
<meta name="theme-color" content="#000000" />
5+
<meta name="description" content="Storybook of General Nordcloud UI library" />
6+
<link rel="apple-touch-icon" href="logo192.png" />
7+
<!--
8+
manifest.json provides metadata used when your web app is installed on a
9+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
10+
-->
11+
<link rel="manifest" href="manifest.json" />
12+
<title>General Nordcloud UI Storybook</title>

.storybook/manager.js .storybook/manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import NCTheme from "./theme";
44
addons.setConfig({
55
theme: NCTheme,
66
showNav: true,
7-
showPanel: false,
7+
showPanel: true,
88
});

.storybook/preview-head.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<style>
2+
#story-root {
3+
padding: 0 2.5rem;
4+
}
5+
6+
.sbdocs.sbdocs-content {
7+
max-width: 1200px;
8+
}
9+
</style>

.storybook/preview.js

-38
This file was deleted.

.storybook/preview.tsx

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { DocsPage, DocsContainer } from "@storybook/addon-docs";
2+
import { INITIAL_VIEWPORTS } from "@storybook/addon-viewport";
3+
import { Preview } from "@storybook/react";
4+
import { GnuiContainer } from "../src/components/container";
5+
import { SetGlobalStyle } from "../src/theme/globals";
6+
7+
const preview: Preview = {
8+
parameters: {
9+
viewport: {
10+
viewports: INITIAL_VIEWPORTS, // newViewports would be an ViewportMap. (see below for examples)
11+
defaultViewport: "desktop",
12+
},
13+
14+
options: {
15+
sidebar: {
16+
showRoots: true,
17+
},
18+
storySort: {
19+
order: [
20+
"Foundation",
21+
["Grid", "Colors", "Icons", "Spacing"],
22+
"Typography",
23+
"Components",
24+
"Forms",
25+
"Patterns",
26+
"Pages",
27+
"Widgets",
28+
],
29+
},
30+
},
31+
viewMode: "docs",
32+
docs: {
33+
container: DocsContainer,
34+
page: DocsPage,
35+
canvas: {
36+
layout: "padded",
37+
},
38+
},
39+
},
40+
41+
decorators: [
42+
(storyFn) => (
43+
<GnuiContainer>
44+
<SetGlobalStyle />
45+
{storyFn()}
46+
</GnuiContainer>
47+
),
48+
],
49+
};
50+
51+
export default preview;

.storybook/theme.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import logo from "../assets/nclogo.png";
33

44
export default create({
55
base: "light",
6+
brandTitle: "Storybook of General Nordcloud UI library",
7+
brandUrl: "https://nordcloud.com/",
8+
brandImage: logo,
9+
brandTarget: "_self",
610

711
colorPrimary: "#161632",
812
colorSecondary: "#ff2837",
@@ -31,8 +35,4 @@ export default create({
3135
inputBorder: "silver",
3236
inputTextColor: "black",
3337
inputBorderRadius: 4,
34-
35-
brandTitle: "GNUI",
36-
37-
brandImage: logo,
3838
});

.storybook/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["**/*.ts", "**/*.tsx"]
4+
}

amplify.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ frontend:
1212
artifacts:
1313
baseDirectory: storybook-static
1414
files:
15-
- '**/*'
15+
- "**/*"
1616
cache:
1717
paths:
1818
- node_modules/**/*

knip.jsonc

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"project": ["src/**/*.{ts,tsx,mdx}!", ".storybook/**/*.js"],
55
"ignoreDependencies": [
66
// False-positives
7-
"react-copy-to-clipboard",
7+
"@typescript-eslint/parser",
8+
"@storybook/addon-docs",
9+
"@storybook/addon-viewport",
10+
"@storybook/blocks",
811
"lodash",
912
"lodash.clonedeep",
1013
"@types/lodash.clonedeep",
11-
"storybook",
1214
"webpack",
1315
// Can be listed explicitly in the future
1416
"@jest/types",

0 commit comments

Comments
 (0)