From 460e8a3a7460a81bcbd7a8a92387cc5bbbed99b1 Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Thu, 3 Nov 2016 11:37:18 +0000 Subject: [PATCH] starting a fresh with plotly --- spikes/graphs-fe/plotly/.babelrc | 15 +++ spikes/graphs-fe/plotly/.eslintignore | 3 + spikes/graphs-fe/plotly/.eslintrc | 29 +++++ spikes/graphs-fe/plotly/.gitignore | 4 + spikes/graphs-fe/plotly/.storybook/config.js | 5 + spikes/graphs-fe/plotly/lib/data.js | 18 +++ spikes/graphs-fe/plotly/package.json | 59 ++++++++++ spikes/graphs-fe/plotly/readme.md | 15 +++ .../plotly/src/components/base/index.css | 103 ++++++++++++++++++ .../plotly/src/components/base/index.js | 12 ++ .../plotly/src/components/base/variables.css | 12 ++ .../plotly/src/components/button/index.js | 9 ++ .../plotly/src/components/container/index.css | 38 +++++++ .../plotly/src/components/container/index.js | 12 ++ .../graphs-fe/plotly/src/components/index.js | 5 + spikes/graphs-fe/plotly/src/index.js | 1 + spikes/graphs-fe/plotly/src/showcase/index.js | 17 +++ spikes/graphs-fe/plotly/src/showcase/root.js | 25 +++++ spikes/graphs-fe/plotly/static/index.html | 11 ++ spikes/graphs-fe/plotly/stories/index.js | 10 ++ spikes/graphs-fe/plotly/test/index.js | 13 +++ spikes/graphs-fe/plotly/webpack.config.js | 68 ++++++++++++ 22 files changed, 484 insertions(+) create mode 100644 spikes/graphs-fe/plotly/.babelrc create mode 100644 spikes/graphs-fe/plotly/.eslintignore create mode 100644 spikes/graphs-fe/plotly/.eslintrc create mode 100644 spikes/graphs-fe/plotly/.gitignore create mode 100644 spikes/graphs-fe/plotly/.storybook/config.js create mode 100644 spikes/graphs-fe/plotly/lib/data.js create mode 100644 spikes/graphs-fe/plotly/package.json create mode 100644 spikes/graphs-fe/plotly/readme.md create mode 100644 spikes/graphs-fe/plotly/src/components/base/index.css create mode 100644 spikes/graphs-fe/plotly/src/components/base/index.js create mode 100644 spikes/graphs-fe/plotly/src/components/base/variables.css create mode 100644 spikes/graphs-fe/plotly/src/components/button/index.js create mode 100644 spikes/graphs-fe/plotly/src/components/container/index.css create mode 100644 spikes/graphs-fe/plotly/src/components/container/index.js create mode 100644 spikes/graphs-fe/plotly/src/components/index.js create mode 100644 spikes/graphs-fe/plotly/src/index.js create mode 100644 spikes/graphs-fe/plotly/src/showcase/index.js create mode 100644 spikes/graphs-fe/plotly/src/showcase/root.js create mode 100644 spikes/graphs-fe/plotly/static/index.html create mode 100644 spikes/graphs-fe/plotly/stories/index.js create mode 100644 spikes/graphs-fe/plotly/test/index.js create mode 100644 spikes/graphs-fe/plotly/webpack.config.js diff --git a/spikes/graphs-fe/plotly/.babelrc b/spikes/graphs-fe/plotly/.babelrc new file mode 100644 index 00000000..82cc857a --- /dev/null +++ b/spikes/graphs-fe/plotly/.babelrc @@ -0,0 +1,15 @@ +{ + "presets": [ + "react", + "es2015" + ], + "plugins": [ + ["transform-object-rest-spread", { + "useBuiltIns": true + }], + "add-module-exports", + "transform-es2015-modules-commonjs", + "react-hot-loader/babel" + ], + "sourceMaps": "both" +} diff --git a/spikes/graphs-fe/plotly/.eslintignore b/spikes/graphs-fe/plotly/.eslintignore new file mode 100644 index 00000000..683e721c --- /dev/null +++ b/spikes/graphs-fe/plotly/.eslintignore @@ -0,0 +1,3 @@ +/node_modules +coverage +.nyc_output diff --git a/spikes/graphs-fe/plotly/.eslintrc b/spikes/graphs-fe/plotly/.eslintrc new file mode 100644 index 00000000..19bd88dc --- /dev/null +++ b/spikes/graphs-fe/plotly/.eslintrc @@ -0,0 +1,29 @@ +{ + "extends": "semistandard", + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 7, + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + "plugins": [ + "babel", + "react" + ], + "rules": { + "generator-star-spacing": 0, + "babel/generator-star-spacing": 1, + "space-before-function-paren": [2, "never"], + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/react-in-jsx-scope": 2, + "object-curly-newline": ["error", { + "minProperties": 1 + }], + "sort-vars": ["error", { + "ignoreCase": true + }] + } +} \ No newline at end of file diff --git a/spikes/graphs-fe/plotly/.gitignore b/spikes/graphs-fe/plotly/.gitignore new file mode 100644 index 00000000..c21b0ba0 --- /dev/null +++ b/spikes/graphs-fe/plotly/.gitignore @@ -0,0 +1,4 @@ +/node_modules +coverage +.nyc_output +npm-debug.log diff --git a/spikes/graphs-fe/plotly/.storybook/config.js b/spikes/graphs-fe/plotly/.storybook/config.js new file mode 100644 index 00000000..d17d412a --- /dev/null +++ b/spikes/graphs-fe/plotly/.storybook/config.js @@ -0,0 +1,5 @@ +const Storybook = require('@kadira/storybook'); + +Storybook.configure(() => { + require('../stories'); +}, module); diff --git a/spikes/graphs-fe/plotly/lib/data.js b/spikes/graphs-fe/plotly/lib/data.js new file mode 100644 index 00000000..fc36391b --- /dev/null +++ b/spikes/graphs-fe/plotly/lib/data.js @@ -0,0 +1,18 @@ +const data = [ + { + type: 'scatter', // all "scatter" attributes: https://plot.ly/javascript/reference/#scatter + x: [1, 2, 3], // more about "x": #scatter-x + y: [6, 2, 3], // #scatter-y + marker: { // marker is an object, valid marker keys: #scatter-marker + color: 'rgb(16, 32, 77)' // more about "marker.color": #scatter-marker-color + } + }, + { + type: 'bar', // all "bar" chart attributes: #bar + x: [1, 2, 3], // more about "x": #bar-x + y: [6, 2, 3], // #bar-y + name: 'bar chart example' // #bar-name + } +]; + +module.exports = data; diff --git a/spikes/graphs-fe/plotly/package.json b/spikes/graphs-fe/plotly/package.json new file mode 100644 index 00000000..bf193104 --- /dev/null +++ b/spikes/graphs-fe/plotly/package.json @@ -0,0 +1,59 @@ +{ + "name": "redux-thunks-spike", + "private": true, + "license": "private", + "main": "src/index.js", + "scripts": { + "start": "webpack-dev-server --open --config webpack.config.js", + "lint": "eslint .", + "test": "NODE_ENV=test nyc ava test/*.js --fail-fast --verbose --tap", + "open": "nyc report --reporter=html & open coverage/index.html", + "coverage": "nyc check-coverage --statements 100 --functions 100 --lines 100 --branches 100", + "storybook": "start-storybook -p 6006", + "build-storybook": "build-storybook" + }, + "dependencies": { + "autoprefixer": "^6.5.1", + "babel-eslint": "^7.0.0", + "babel-loader": "^6.2.5", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.16.0", + "babel-plugin-transform-object-rest-spread": "^6.16.0", + "babel-plugin-transform-runtime": "^6.15.0", + "babel-preset-es2015": "^6.16.0", + "babel-preset-react": "^6.16.0", + "babel-preset-react-hmre": "^1.1.1", + "babel-runtime": "^6.11.6", + "css-loader": "^0.25.0", + "postcss-loader": "^1.0.0", + "postcss-modules-values": "^1.2.2", + "postcss-nested": "^1.0.0", + "react": "^15.3.2", + "react-dom": "^15.3.2", + "react-hot-loader": "^3.0.0-beta.6", + "style-loader": "^0.13.1", + "webpack": "^1.13.2", + "webpack-dev-server": "^1.16.2" + }, + "devDependencies": { + "@kadira/storybook": "^2.24.1", + "ava": "^0.16.0", + "babel-register": "^6.16.3", + "enzyme": "^2.5.1", + "eslint": "^3.8.1", + "eslint-config-semistandard": "^7.0.0", + "eslint-config-standard": "^6.2.0", + "eslint-plugin-babel": "^3.3.0", + "eslint-plugin-promise": "^3.3.0", + "eslint-plugin-react": "^6.4.1", + "eslint-plugin-standard": "^2.0.1", + "nyc": "^8.3.1", + "react-addons-test-utils": "^15.3.2" + }, + "ava": { + "require": [ + "babel-register" + ], + "babel": "inherit" + } +} diff --git a/spikes/graphs-fe/plotly/readme.md b/spikes/graphs-fe/plotly/readme.md new file mode 100644 index 00000000..1c57af1b --- /dev/null +++ b/spikes/graphs-fe/plotly/readme.md @@ -0,0 +1,15 @@ +# postcss + css-modules + +#### src/showcase + +contains all the files to showcase the components + +#### src/components + +contains all the css files and react components + +## usage + +## todo + + - [ ] mixins (https://github.com/postcss/postcss-mixins) \ No newline at end of file diff --git a/spikes/graphs-fe/plotly/src/components/base/index.css b/spikes/graphs-fe/plotly/src/components/base/index.css new file mode 100644 index 00000000..1eda3b18 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/base/index.css @@ -0,0 +1,103 @@ +@value color_primary_dark, font_primary, font_secondary, font_tertiary from "./variables.css"; + +.base { + :global { + h1, + h2, + h3, + h4, + h5, + p, + li { + color: color_primary_dark; + } + + h1, + h2, + h3 { + font-family: font_primary; + } + + h4, + p, + li { + font-family: font_secondary; + } + + a { + font-family: inherit; + text-decoration: none; + + &:hover { + text-decoration: none; + } + } + + h5, + p, + li { + & > a:hover { + text-decoration: underline; + } + } + + h1 { + font-size: 14px; + line-height: 35px; + } + + h2 { + font-size: 10px; + line-height: 25px; + } + + h3 { + font-size: 6px; + line-height: 20px; + } + + h4 { + font-size: 15px; + line-height: 20px; + letter-spacing: -0.025em; + } + + h5 { + font-family: font_tertiary; + font-style: italic; + font-size: 15px; + line-height: 20px; + } + + p { + font-size: 14px; + line-height: 18px; + letter-spacing: -0.025em; + + a { + text-decoration: underline; + } + + &.small { + font-size: 12px; + line-height: 16px; + } + } + + span { + font-family: inherit; + } + + button, + select, + a { + outline: none; + } + + /* Removes the grey background when you tap on a link in IOS */ + button, + a { + -webkit-tap-highlight-color: rgba(0,0,0,0); + } + } +} diff --git a/spikes/graphs-fe/plotly/src/components/base/index.js b/spikes/graphs-fe/plotly/src/components/base/index.js new file mode 100644 index 00000000..a08c8138 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/base/index.js @@ -0,0 +1,12 @@ +const React = require('react'); +const styles = require('./index.css'); + +module.exports = ({ + children +}) => { + return ( +
+ {children} +
+ ); +}; diff --git a/spikes/graphs-fe/plotly/src/components/base/variables.css b/spikes/graphs-fe/plotly/src/components/base/variables.css new file mode 100644 index 00000000..eb2fc224 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/base/variables.css @@ -0,0 +1,12 @@ +@value font_primary: "freddiesflowerstitle-webfont", "Times", serif; +@value font_secondary: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; +@value font_tertiary: Georgia, Times, "Times New Roman", serif; + +@value color_primary: #ccc; +@value color_primary_dark: #222; +@value color_primary_mid: #959595; +@value color_primary_light: #f4f4f4; +@value color_warning: #C93F3F; +@value color_valid: #547954; +@value color_cta_primary: #60b4d6; +@value color_cta_secondary: #e5eef2; diff --git a/spikes/graphs-fe/plotly/src/components/button/index.js b/spikes/graphs-fe/plotly/src/components/button/index.js new file mode 100644 index 00000000..9cd63df1 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/button/index.js @@ -0,0 +1,9 @@ +const React = require('react'); + +module.exports = (props) => { + return ( + + ); +}; diff --git a/spikes/graphs-fe/plotly/src/components/container/index.css b/spikes/graphs-fe/plotly/src/components/container/index.css new file mode 100644 index 00000000..f2157be6 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/container/index.css @@ -0,0 +1,38 @@ +@value color_background from "../base/variables.css"; + +.container { + margin-left: auto; + margin-right: auto; + padding-left: 15px; + padding-right: 15px; +} + +.container::after { + content: ""; + display: table; + clear: both; +} + +@media (min-width: 544px) { + .container { + max-width: 576px; + } +} + +@media (min-width: 768px) { + .container { + max-width: 720px; + } +} + +@media (min-width: 992px) { + .container { + max-width: 940px; + } +} + +@media (min-width: 1200px) { + .container { + max-width: 1140px; + } +} \ No newline at end of file diff --git a/spikes/graphs-fe/plotly/src/components/container/index.js b/spikes/graphs-fe/plotly/src/components/container/index.js new file mode 100644 index 00000000..b4809480 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/container/index.js @@ -0,0 +1,12 @@ +const React = require('react'); +const styles = require('./index.css'); + +module.exports = ({ + children +}) => { + return ( +
+ {children} +
+ ); +}; diff --git a/spikes/graphs-fe/plotly/src/components/index.js b/spikes/graphs-fe/plotly/src/components/index.js new file mode 100644 index 00000000..a405120e --- /dev/null +++ b/spikes/graphs-fe/plotly/src/components/index.js @@ -0,0 +1,5 @@ +module.exports = { + Button: require('./button'), + Container: require('./container'), + Base: require('./base') +}; diff --git a/spikes/graphs-fe/plotly/src/index.js b/spikes/graphs-fe/plotly/src/index.js new file mode 100644 index 00000000..94017e32 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/index.js @@ -0,0 +1 @@ +module.exports = require('./components'); diff --git a/spikes/graphs-fe/plotly/src/showcase/index.js b/spikes/graphs-fe/plotly/src/showcase/index.js new file mode 100644 index 00000000..af547af9 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/showcase/index.js @@ -0,0 +1,17 @@ +const ReactDOM = require('react-dom'); +const React = require('react'); + +const render = () => { + const Root = require('./root'); + + ReactDOM.render( + , + document.getElementById('root') + ); +}; + +render(); + +if (module.hot) { + module.hot.accept('./root', render); +} diff --git a/spikes/graphs-fe/plotly/src/showcase/root.js b/spikes/graphs-fe/plotly/src/showcase/root.js new file mode 100644 index 00000000..a522bd40 --- /dev/null +++ b/spikes/graphs-fe/plotly/src/showcase/root.js @@ -0,0 +1,25 @@ +const React = require('react'); +const ReactHotLoader = require('react-hot-loader'); + +const { + Button, + Container, + Base +} = require('../'); + +const { + AppContainer +} = ReactHotLoader; + +module.exports = () => { + return ( + + + +

Hello

+ +
+ +
+ ); +}; diff --git a/spikes/graphs-fe/plotly/static/index.html b/spikes/graphs-fe/plotly/static/index.html new file mode 100644 index 00000000..c5a61365 --- /dev/null +++ b/spikes/graphs-fe/plotly/static/index.html @@ -0,0 +1,11 @@ + + + + React Boilerplate + + + +
+ + + diff --git a/spikes/graphs-fe/plotly/stories/index.js b/spikes/graphs-fe/plotly/stories/index.js new file mode 100644 index 00000000..3b098180 --- /dev/null +++ b/spikes/graphs-fe/plotly/stories/index.js @@ -0,0 +1,10 @@ +const React = require('react'); +const Storybook = require('@kadira/storybook'); + +const Home = require('../src/client/containers/home'); + +const homeStories = Storybook.storiesOf('Home', module); + +homeStories.add('with nothing', () => ( + +)); diff --git a/spikes/graphs-fe/plotly/test/index.js b/spikes/graphs-fe/plotly/test/index.js new file mode 100644 index 00000000..62cf17c3 --- /dev/null +++ b/spikes/graphs-fe/plotly/test/index.js @@ -0,0 +1,13 @@ +const test = require('ava'); +const enzyme = require('enzyme'); +const React = require('react'); + +const { + shallow +} = enzyme; + +test('renders without exploding', (t) => { + const Home = require('../src/client/containers/home'); + const wrapper = shallow(); + t.deepEqual(wrapper.length, 1); +}); diff --git a/spikes/graphs-fe/plotly/webpack.config.js b/spikes/graphs-fe/plotly/webpack.config.js new file mode 100644 index 00000000..fedf3ddc --- /dev/null +++ b/spikes/graphs-fe/plotly/webpack.config.js @@ -0,0 +1,68 @@ +const webpack = require('webpack'); +const path = require('path'); + +const config = { + debug: true, + devtool: 'eval', + context: path.join(__dirname, './src'), + entry: [ + 'webpack-dev-server/client?http://localhost:8080', + 'webpack/hot/only-dev-server', + 'react-hot-loader/patch', + './showcase/index.js' + ], + output: { + path: path.join(__dirname, './static'), + publicPath: '/static/', + filename: 'bundle.js' + }, + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new webpack.NoErrorsPlugin() + ], + postcss: () => { + return [ + require('postcss-modules-values'), + require('postcss-nested'), + require('autoprefixer') + ]; + }, + module: { + loaders: [{ + test: /js?$/, + exclude: /node_modules/, + include: [ + path.join(__dirname, './src') + ], + loaders: ['babel'] + }, { + test: /\.json?$/, + exclude: /node_modules/, + include: [ + path.join(__dirname, './src') + ], + loaders: ['json'] + }, { + test: /\.css$/, + exclude: /node_modules/, + include: [ + path.join(__dirname, './src') + ], + loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader' + }] + } +}; + +const devServer = { + hot: true, + compress: true, + lazy: false, + publicPath: config.output.publicPath, + historyApiFallback: { + index: './static/index.html' + } +}; + +module.exports = Object.assign({ + devServer +}, config);