Skip to content

Commit 34cfcdf

Browse files
Creates Storybook addon [LG-3478] (#1900)
* initialize sb addon * Moves manager & preview heads * mv static * Create six-sloths-rush.md * Update six-sloths-rush.md
1 parent 00dc600 commit 34cfcdf

24 files changed

+438
-342
lines changed

.changeset/six-sloths-rush.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@lg-tools/storybook': minor
3+
---
4+
5+
Updates `storybook` package to be a Storybook addon.
6+
7+
#### Usage
8+
1. Install
9+
```bash
10+
> yarn add @lg-tools/storybook@latest
11+
```
12+
13+
2. Add to `./storybook/main.ts`
14+
```ts
15+
export default {
16+
addons: ['@lg-tools/storybook'],
17+
framework: {
18+
name: '@storybook/react-webpack5',
19+
options: {
20+
fastRefresh: true,
21+
strictMode: true,
22+
},
23+
},
24+
};
25+
```
26+
- There is no need for a `manager.ts`, `preview.ts`, or `*-head.html` file, unless you need to extend the defaults in this addon

.storybook/main.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
import main from '@lg-tools/storybook';
2-
export default main;
1+
export default {
2+
addons: ['@lg-tools/storybook'],
3+
framework: {
4+
name: '@storybook/react-webpack5',
5+
options: {
6+
fastRefresh: true,
7+
strictMode: true,
8+
},
9+
},
10+
};

.storybook/preview.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,6 @@
1-
import {
2-
ComponentPreview,
3-
ReactStrictMode,
4-
PropCombinations,
5-
} from '@lg-tools/storybook-decorators';
6-
7-
import {
8-
storybookExcludedArgTypes,
9-
storybookExcludedControlParams,
10-
} from '@leafygreen-ui/lib';
11-
import {
12-
H1,
13-
H2,
14-
H3,
15-
Subtitle,
16-
Body,
17-
InlineCode,
18-
Link,
19-
} from '@leafygreen-ui/typography';
201
import { Preview } from '@storybook/react';
212

223
const parameters = {
23-
actions: { argTypesRegex: '^on[A-Z].*' },
24-
argTypes: {
25-
// By default we set specific argTypes to `control: none`
26-
...storybookExcludedArgTypes,
27-
},
28-
controls: {
29-
exclude: [...storybookExcludedControlParams],
30-
expanded: true,
31-
matchers: {
32-
color: /.*(c|C)olor$/,
33-
date: /Date$/,
34-
},
35-
sort: 'requiredFirst',
36-
},
374
options: {
385
storySort: {
396
method: 'alphabetical',
@@ -51,26 +18,10 @@ const parameters = {
5118
locales: '',
5219
},
5320
},
54-
docs: {
55-
components: {
56-
h1: H1,
57-
h2: H2,
58-
h3: H3,
59-
h4: Subtitle,
60-
h5: Body,
61-
p: Body,
62-
a: Link,
63-
code: InlineCode,
64-
},
65-
source: { type: 'code' },
66-
},
6721
};
6822

69-
export const decorators = [PropCombinations, ReactStrictMode, ComponentPreview];
70-
7123
const preview: Preview = {
7224
parameters,
73-
decorators,
7425
};
7526

7627
export default preview;
-58.1 KB
Binary file not shown.

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"esbenp.prettier-vscode",
77
"wayou.vscode-todo-highlight",
88
"styled-components.vscode-styled-components",
9-
"redhat.vscode-yaml"
9+
"redhat.vscode-yaml",
10+
"julienetie.vscode-template-literals"
1011
]
1112
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"react": "^17.0.2",
5151
"react-dom": "^17.0.2",
5252
"react-router-dom": "5.2.0",
53-
"storybook": "^7.1.0",
53+
"storybook": "7.1.1",
5454
"turbo": "^1.10.7",
5555
"typescript": "~4.7.0"
5656
},

tools/storybook/babel.config.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

tools/storybook/main.ts

Lines changed: 0 additions & 119 deletions
This file was deleted.

tools/storybook/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22
"name": "@lg-tools/storybook",
33
"version": "0.1.4",
44
"description": "Storybook config for LeafyGreen",
5-
"main": "main.ts",
65
"license": "Apache-2.0",
6+
"main": "./dist/index.js",
7+
"module": "./dist/esm/index.js",
8+
"types": "./dist/index.d.ts",
79
"scripts": {
10+
"build": "lg-internal-build-package",
11+
"tsc": "tsc --build tsconfig.json",
812
"upgrade": "npx storybook@latest upgrade --config-dir ."
913
},
1014
"publishConfig": {
1115
"access": "public"
1216
},
1317
"dependencies": {
18+
"@leafygreen-ui/lib": "^10.4.0",
1419
"@leafygreen-ui/palette": "^4.0.5",
1520
"@leafygreen-ui/tokens": "^2.1.2",
21+
"@leafygreen-ui/typography": "^16.5.1",
1622
"@lg-tools/build": "^0.2.0",
23+
"@lg-tools/storybook-decorators": "^0.1.2",
1724
"@mdx-js/react": "1.6.22",
1825
"@storybook/addon-a11y": "7.1.1",
1926
"@storybook/addon-actions": "7.1.1",
@@ -34,6 +41,7 @@
3441
"@svgr/webpack": "8.0.1",
3542
"buffer": "6.0.3",
3643
"file-loader": "6.2.0",
44+
"fs-extra": "11.1.1",
3745
"glob": "10.3.3",
3846
"lodash": "4.17.21",
3947
"path-browserify": "1.0.1",
@@ -44,6 +52,7 @@
4452
"webpack": "5.88.0"
4553
},
4654
"peerDependencies": {
55+
4756
"react": "^17.0.0",
4857
"react-dom": "^17.0.0",
4958
"storybook": "^7.1.0"

tools/storybook/preset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./dist/index');

0 commit comments

Comments
 (0)