Skip to content

Commit 2eeb173

Browse files
committed
Added storybook addons, initial anchor component and missing config for finding components
1 parent 4222231 commit 2eeb173

10 files changed

Lines changed: 693 additions & 36 deletions

File tree

.storybook/addons.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import "@storybook/addon-actions/register";
2+
import "@storybook/addon-links/register";
3+
import "@storybook/addon-knobs/register";

.storybook/config.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,45 @@
1-
import { configure } from "@storybook/react";
1+
import { configure, addParameters, addDecorator } from "@storybook/react";
2+
import { setDefaults } from "@storybook/addon-info";
3+
import { withInfo } from "@storybook/addon-info";
4+
import { withKnobs } from "@storybook/addon-knobs";
5+
6+
// -----------------------------------------------------------------------------------------
7+
// #region Constants
8+
// -----------------------------------------------------------------------------------------
29

310
const req = require.context("../src", true, /\.stories\.tsx$/);
411

12+
// #endregion Constants
13+
14+
// -----------------------------------------------------------------------------------------
15+
// #region Functions
16+
// -----------------------------------------------------------------------------------------
17+
518
function loadStories() {
619
req.keys().forEach(req);
720
}
821

22+
// #endregion Functions
23+
24+
// -----------------------------------------------------------------------------------------
25+
// #region Configuration
26+
// -----------------------------------------------------------------------------------------
27+
28+
setDefaults({
29+
header: true,
30+
inline: true,
31+
source: true,
32+
});
33+
34+
addParameters({
35+
options: {
36+
panelPosition: "right", // 'Bottom' is the other option.
37+
},
38+
});
39+
40+
addDecorator(withInfo);
41+
addDecorator(withKnobs({ escapeHTML: false }));
42+
943
configure(loadStories, module);
44+
45+
// #endregion Configuration

.storybook/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
stories: ["../src/**/*.stories.tsx"],
3+
};

.storybook/tsconfig.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": "./",
4-
"allowSyntheticDefaultImports": true,
5-
"module": "es2015",
6-
"target": "es5",
7-
"lib": ["es6", "dom"],
8-
"sourceMap": true,
93
"allowJs": false,
4+
"allowSyntheticDefaultImports": true,
5+
"baseUrl": "./src",
6+
"declaration": true,
7+
"esModuleInterop": true,
8+
"experimentalDecorators": true,
109
"jsx": "react",
10+
"lib": ["dom", "dom.iterable", "esnext"],
11+
"module": "es2015",
1112
"moduleResolution": "node",
12-
"rootDir": "../",
13-
"outDir": "dist",
1413
"noImplicitReturns": true,
1514
"noImplicitThis": true,
1615
"noImplicitAny": true,
16+
"rootDir": "../src",
17+
"outDir": "dist",
18+
"sourceMap": true,
1719
"strictNullChecks": true,
18-
"declaration": true
20+
"target": "es5"
1921
},
20-
"include": ["src/**/*"],
22+
"include": ["src"],
2123
"exclude": [
2224
"node_modules",
2325
"build",

.storybook/webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module.exports = ({ config }) => {
1111
},
1212
{
1313
loader: require.resolve("react-docgen-typescript-loader"),
14+
// Set shouldExtractLiteralValuesFromEnum = true to view enum values in storybook.
15+
options: { shouldExtractLiteralValuesFromEnum: true },
1416
},
1517
],
1618
});

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ From there you can import the variety of modules.
2323
import { Card } from "andculturecode-javascript-react-components";
2424
```
2525

26+
## Developer Guide
27+
28+
### Active development
29+
30+
```shell
31+
$: npm run storybook
32+
```
33+
34+
###
35+
2636
## Documentation
2737

2838
[Full API documentation](docs/README.md)

0 commit comments

Comments
 (0)