diff --git a/.storybook/config.js b/.storybook/config.js new file mode 100644 index 00000000..3d286cee --- /dev/null +++ b/.storybook/config.js @@ -0,0 +1,7 @@ +import {configure} from '@kadira/storybook'; + +function loadStories() { + require('../src/components/stories/'); +} + +configure(loadStories, module); diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js new file mode 100644 index 00000000..08191f16 --- /dev/null +++ b/.storybook/webpack.config.js @@ -0,0 +1,34 @@ +/* global module, __dirname, require */ +var webpack = require("webpack"); +const path = require("path"); + +module.exports = { + module: { + loaders: [ + { + test: /\.((png)|(eot)|(woff)|(woff2)|(ttf)|(svg)|(gif))(\?v=\d+\.\d+\.\d+)?$/, + loader: 'url-loader?limit=100000' + }, + { test: /\.json$/, loader: 'json-loader' }, + { + test: /\.css$/, + loader: 'style!css?modules&importLoaders=1!postcss' + }, + { + loader: 'babel', + test: /\.js?$/, + exclude: /(node_modules|bower_components)/, + query: { + cacheDirectory: true, + presets: ['react', 'es2015'], + plugins: ['transform-class-properties', 'transform-object-assign', 'transform-object-rest-spread'] + } + } + ] + }, + + postcss: [ + require("postcss-import")({addDependencyTo: webpack}), + require("postcss-cssnext")() + ], +}; diff --git a/package.json b/package.json index 10bcb53d..7eddf1cf 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "start": "webpack-dev-server -d --inline --config webpack.config.js", "test": "NODE_ENV=test mocha --recursive --compilers js:babel-register --require ./test/setup.js", "test:watch": "npm test -- --watch", - "build": "webpack --config webpack.config.js" + "build": "webpack --config webpack.config.js", + "storybook": "start-storybook -p 9001" }, "keywords": [ "netlify", @@ -16,6 +17,7 @@ "author": "Netlify", "license": "MIT", "devDependencies": { + "@kadira/storybook": "^1.36.0", "autoprefixer": "^6.3.3", "babel-core": "^6.5.1", "babel-eslint": "^4.1.8", @@ -42,6 +44,7 @@ "moment": "^2.11.2", "normalizr": "^2.0.0", "postcss-cssnext": "^2.7.0", + "postcss-import": "^8.1.2", "postcss-loader": "^0.9.1", "react": "^15.1.0", "react-dom": "^15.1.0", diff --git a/src/components/stories/Card.js b/src/components/stories/Card.js new file mode 100644 index 00000000..a791f268 --- /dev/null +++ b/src/components/stories/Card.js @@ -0,0 +1,50 @@ +import React from 'react'; +import { Card } from '../UI'; +import { storiesOf } from '@kadira/storybook'; + +const styles = { + fixedWidth: { width: 280 }, + footer: { + color: '#aaa', + backgroundColor: '#555', + textAlign: 'center', + marginTop: 5, + padding: 10 + } + +} + +storiesOf('Card', module) + .add('Default View', () => ( +
+ Margins are applied to all elements inside a card.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. lobortis vel. Nulla porttitor enim at tellus eget
+ malesuada eleifend. Nunc tellus turpis, tincidunt sed felis facilisis, lacinia condimentum quam. Cras quis
+ tortor fermentum, aliquam tortor eu, consequat ligula. Nulla eget nulla act odio varius ullamcorper turpis.
+ In consequat egestas nulla condimentum faucibus. Donec scelerisque convallis est nec fringila. Suspendisse
+ non lorem non erat congue consequat.
+
Media Elements such as video, img (and iFrame for embeds) don't have margin
+header and footer elements are also not subject to margin
+ +