Skip to content

Commit 01ff4d8

Browse files
committed
storybook setup and stuff
1 parent 7cb7510 commit 01ff4d8

File tree

10 files changed

+155
-11
lines changed

10 files changed

+155
-11
lines changed

.storybook/webpack.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
var path = require("path");
12
module.exports = {
23
module: {
34
rules: [
45
{
56
test: /\.(ts|tsx)$/,
7+
include: path.resolve("../"),
68
use: [
79
{
810
loader: require.resolve("awesome-typescript-loader"),
@@ -18,8 +20,16 @@ module.exports = {
1820
},
1921
{
2022
test: /\.(less|css)$/,
23+
include: path.resolve("../"),
2124
use: ["style-loader", "css-loader", "less-loader"]
22-
}
25+
},
26+
{
27+
test: /\.(jpg|png|svg)$/,
28+
include: path.resolve("../"),
29+
use: {
30+
loader: 'url-loader',
31+
},
32+
},
2333
]
2434
},
2535
resolve: {

components/Button/index.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from "react";
2+
import classnames from 'classnames';
3+
4+
import "./styles.less";
5+
6+
type ButtonProps = {
7+
className?: string,
8+
type?: string,
9+
size?: string,
10+
}
11+
12+
/* Default Button is medium sized */
13+
export const Button: React.FunctionComponent<ButtonProps> = ({ className, type, children }) => {
14+
let classes = classnames("acm-btn", {"acm-btn-primary": type === "primary"});
15+
if (className) {
16+
classes = classnames(classes, ...className.split(" "));
17+
}
18+
console.log(classes);
19+
return (
20+
<button className={classes}>
21+
<span>{children}</span>
22+
</button>
23+
);
24+
};

components/Button/styles.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "../../styles/vars.less";
2+
.acm-button {
3+
background-color: rgb(51,56,68);
4+
color: @white;
5+
}

index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export { Button } from "./components/Button";
12
export * from "antd";

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "ACM Components, an extension of Ant Design",
55
"main": "/lib/index.js",
66
"scripts": {
7-
"storybook": "start-storybook",
7+
"storybook": "start-storybook -s ./stories/assets -p 9001",
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"build": "webpack --display-error-details"
9+
"build": "rm -rf lib && webpack --display-error-details"
1010
},
1111
"author": "",
1212
"license": "MIT",
@@ -20,6 +20,7 @@
2020
"@storybook/addon-actions": "^5.2.5",
2121
"@storybook/addon-info": "^5.2.5",
2222
"@storybook/react": "^5.2.5",
23+
"@types/classnames": "^2.2.10",
2324
"@types/jest": "^24.0.22",
2425
"@types/react": "^16.9.11",
2526
"awesome-typescript-loader": "^5.2.1",
@@ -52,6 +53,7 @@
5253
"webpack-node-externals": "^1.7.2"
5354
},
5455
"dependencies": {
55-
"antd": "^3.25.0"
56+
"antd": "^3.25.0",
57+
"classnames": "^2.2.6"
5658
}
5759
}

styles/index.less

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@import './vars.less';
2+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
3+
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img,
4+
ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center,
5+
dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody,
6+
tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure,
7+
figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary,
8+
time, mark, audio, video {
9+
font-family: @font;
10+
}
11+
12+
h1 {
13+
color: @h1-color;
14+
font-size: 6.6rem;
15+
line-height: 125%;
16+
font-weight: bold;
17+
}
18+
h2 {
19+
color: @h2-color;
20+
font-size: 2.4rem;
21+
line-height: 125%;
22+
font-weight: bold;
23+
}
24+
h3 {
25+
color: @h3-color;
26+
font-size: 2.2rem;
27+
line-height: 125%;
28+
font-weight: bold;
29+
}
30+
h4 {
31+
color: @h4-color;
32+
}
33+
h5 {
34+
35+
}
36+
li {
37+
font-family: @body-font;
38+
font-size: 2rem;
39+
color: @b2;
40+
}

styles/vars.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** ACM COMPONENTS **/
2+
@white: white;
3+
4+
/** Screen break points **/
5+
@sm: 576px;
6+
@md: 768px;
7+
@lg: 992px;
8+
@xl: 1200px;
9+
10+
/* Typography */
11+
@font: 'Montserrat', sans-serif;
12+
@body-font: 'Open Sans', sans-serif;

tsconfig.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
"noImplicitAny": true,
55
"module": "commonjs",
66
"target": "es5",
7-
"jsx": "react"
7+
"jsx": "react",
8+
"allowJs": false,
9+
"forceConsistentCasingInFileNames": true,
10+
"noImplicitReturns": true,
11+
"noImplicitThis": true,
12+
"strictNullChecks": true,
13+
"suppressImplicitAnyIndexErrors": true,
14+
"noUnusedLocals": true,
15+
"declaration": true,
16+
"allowSyntheticDefaultImports": true,
17+
"experimentalDecorators": true,
18+
"emitDecoratorMetadata": true
819
}
920
}

webpack.config.js

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var path = require("path");
22
const nodeExternals = require("webpack-node-externals");
3+
const autoprefixer = require('autoprefixer');
4+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
35
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
46
.BundleAnalyzerPlugin;
57
module.exports = {
@@ -14,8 +16,8 @@ module.exports = {
1416
rules: [
1517
{
1618
test: /\.(js|jsx)$/,
17-
exclude: /node_modules/,
18-
include: path.resolve("src"),
19+
exclude: /(node_modules|lib)/,
20+
include: path.resolve("components"),
1921
use: "babel-loader"
2022
},
2123
{
@@ -25,16 +27,47 @@ module.exports = {
2527
use: "ts-loader"
2628
},
2729
{
28-
test: /\.(less|css)$/,
29-
exclude: /node_modules/,
30-
use: ["style-loader", "css-loader", "less-loader"]
30+
test: /\.less$/,
31+
use: [
32+
MiniCssExtractPlugin.loader,
33+
{
34+
loader: 'css-loader',
35+
options: {
36+
sourceMap: true,
37+
},
38+
},
39+
{
40+
loader: require.resolve('less-loader'),
41+
options: {
42+
javascriptEnabled: true,
43+
sourceMap: true,
44+
},
45+
},
46+
],
47+
},
48+
{
49+
test: /\.(jpg|png|svg)$/,
50+
include: path.resolve("./components"),
51+
use: {
52+
loader: 'url-loader',
53+
},
54+
},
55+
{
56+
test: /\.svg$/,
57+
include: path.resolve("./components"),
58+
loader: 'url-loader'
3159
}
3260
]
3361
},
3462
resolve: {
3563
// Add '.ts' and '.tsx' as resolvable extensions.
3664
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".less"]
3765
},
38-
plugins: [new BundleAnalyzerPlugin()],
66+
plugins: [
67+
new BundleAnalyzerPlugin(),
68+
new MiniCssExtractPlugin({
69+
filename: '[name].css',
70+
})
71+
],
3972
externals: [nodeExternals()]
4073
};

0 commit comments

Comments
 (0)