Skip to content

Commit

Permalink
feat(build): adds SFC, prettierrc, styleguidist wrapper, styled-compo…
Browse files Browse the repository at this point in the history
…nents
  • Loading branch information
nikolasleblanc committed Dec 31, 2018
1 parent 0827de0 commit efe5fa4
Show file tree
Hide file tree
Showing 26 changed files with 1,356 additions and 1,021 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ yarn storybook

## Generating new component skeletons

### JSX
### JSX (SFC)

```
yarn generate-jsx
yarn generate-sfc-jsx
```

### TSX
Expand Down
1 change: 1 addition & 0 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"commitmsg": "commitlint -e $GIT_PARAMS",
"styleguidist": "styleguidist server",
"generate-jsx": "ft jsx-component ./packages",
"generate-tsx": "ft tsx-component ./packages"
"generate-tsx": "ft tsx-component ./packages",
"postinstall": "yarn build"
},
"dependencies": {
"@babel/cli": "7.1.2",
Expand All @@ -35,18 +36,19 @@
"@babel/preset-stage-1": "7.0.0",
"@babel/preset-typescript": "7.1.0",
"@babel/runtime": "7.1.2",
"@rebass/components": "^4.0.0-1",
"babel-core": "npm:@babel/core",
"babel-loader": "8.0.2",
"babel-plugin-react-docgen": "2.0.0",
"babel-plugin-react-docgen-typescript": "1.0.1",
"babel-plugin-styled-components": "1.7.1",
"babel-plugin-transform-es2015-modules-simple-commonjs": "0.3.0",
"lerna": "3.4.3",
"prop-types": "^15.6.2",
"react-docgen-typescript": "1.10.0",
"react-docgen-typescript-loader": "3.0.0",
"react-docgen-typescript-webpack-plugin": "1.1.0"
},
"devDependencies": {
"react-docgen-typescript-webpack-plugin": "1.1.0",
"styled-system": "^3.1.11",
"@commitlint/cli": "7.1.2",
"@commitlint/config-conventional": "7.1.2",
"@material-ui/core": "3.0.3",
Expand All @@ -61,12 +63,12 @@
"@types/react": "16.4.14",
"folder-template": "0.1.4",
"husky": "1.0.0-rc.14",
"react": "16.5.1",
"react-dom": "16.5.1",
"styled-components": "3.4.6",
"webpack": "4.19.0",
"react-styleguidist": "7.3.11",
"typescript": "3.1.3"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-styleguidist": "^8.0.6",
"styled-components": "^4.1.3",
"typescript": "3.1.3",
"webpack": "4.19.0"
},
"commitlint": {
"extends": [
Expand Down
3 changes: 0 additions & 3 deletions packages/Hello/Readme

This file was deleted.

3 changes: 3 additions & 0 deletions packages/Hello/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hello

`npm install @coinsquare/hello-component`
12 changes: 8 additions & 4 deletions packages/Hello/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@coinsquare/Hello-component",
"name": "@coinsquare/hello-component",
"version": "0.0.0",
"description": "Hello component",
"scripts": {
Expand All @@ -14,11 +14,15 @@
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1",
"styled-components": "^3.4.6"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"styled-components": "^4.1.3",
"styled-system": "^3.1.3"
},
"dependencies": {
"styled-system": "^3.1.3",

},
"devDependencies": {
"@coinsquare/build": "^0.0.0",
"@coinsquare/storybook": "^0.0.0"
}
Expand Down
29 changes: 13 additions & 16 deletions packages/Hello/src/Hello.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import React from "react";
import PropTypes from "prop-types";
import React from 'react';

export default class Hello extends React.PureComponent {
static propTypes = {
/** Sample prop that you can change */
dummyProp: PropTypes.string
};
import PropTypes from 'prop-types';

static defaultProps = {
dummyProp: 'My dummy prop default value'
};
export const Hello = props => (
<p>Hello Component {props.dummyProp}</p>
);

render() {
return (
<p>Hello Component - {this.props.dummyProp}</p>
);
}
}
Hello.propTypes = {
/** Sample prop that you can change */
dummyProp: PropTypes.string
};

Hello.defaultProps = {
dummyProp: 'My dummy prop default value'
};
2 changes: 1 addition & 1 deletion packages/Hello/src/Hello.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { text } from '@storybook/addon-knobs';
import { withInfo } from '@storybook/addon-info';

import Hello from './Hello';
import { Hello } from './Hello';

import { createStorySetWithDefault, getKnob, getStoryProps } from '@coinsquare/storybook';

Expand Down
2 changes: 1 addition & 1 deletion packages/Hello/src/Hello.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';

import Hello from './Hello';
import { Hello } from './Hello';

const createComponent = newProps => {
const component = renderer.create(
Expand Down
3 changes: 1 addition & 2 deletions packages/Hello/src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default } from "./Hello";
export { default as Hello } from "./Hello";
export { Hello } from "./Hello";
8 changes: 7 additions & 1 deletion packages/World/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"styled-components": "^4.1.3",
"styled-system": "^3.1.3"
},
"dependencies": {

},
"devDependencies": {
"@coinsquare/build": "^0.0.0",
"@coinsquare/storybook": "^0.0.0"
}
Expand Down
9 changes: 3 additions & 6 deletions packages/World/src/World.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import * as React from "react";
import * as React from 'react';

interface WorldProps {
/** Sample prop description */
dummyProp?: string;
}

const World: React.SFC<WorldProps> = props => (
export const World: React.SFC<WorldProps> = props => (
<p>World Component - {props.dummyProp}</p>
);

World.defaultProps = {
/* Sample prop that you can change */
dummyProp: 'My dummy prop default value'
}

export default World;
};
3 changes: 1 addition & 2 deletions packages/World/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default } from './World';
export { default as World } from './World';
export { World } from "./World";
60 changes: 30 additions & 30 deletions packages/_build/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ module.exports = function(api) {
api.cache(false);
}
const presets = [
[
"@babel/preset-env",
{
modules: false,
targets: { browsers: ["last 2 versions", "ie >= 11"] },
include: ["es6.object.assign", "es6.promise", "es6.object.keys"],
useBuiltIns: "usage"
}
],
"@babel/preset-react",
"@babel/preset-typescript"
// [
// '@babel/preset-env',
// {
// modules: false,
// targets: { browsers: ['last 2 versions', 'ie >= 11'] },
// include: ['es6.object.assign', 'es6.promise', 'es6.object.keys'],
// useBuiltIns: 'usage'
// }
// ],
'@babel/preset-react',
'@babel/preset-typescript'
];
const plugins = [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
["@babel/plugin-proposal-optional-chaining", { loose: false }],
["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
["@babel/plugin-proposal-nullish-coalescing-operator", { loose: false }],
"@babel/plugin-proposal-do-expressions",
"babel-plugin-styled-components",
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-logical-assignment-operators',
['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: false }],
'@babel/plugin-proposal-do-expressions',
'babel-plugin-styled-components',
// "@babel/transform-runtime",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-react-jsx-source",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-modules-commonjs",
"babel-plugin-react-docgen",
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-react-jsx-source',
'@babel/plugin-proposal-class-properties',
// "@babel/plugin-transform-modules-commonjs",
'babel-plugin-react-docgen',
[
"babel-plugin-react-docgen-typescript",
'babel-plugin-react-docgen-typescript',
{
docgenCollectionName: "STORYBOOK_REACT_CLASSES",
docgenCollectionName: 'STORYBOOK_REACT_CLASSES',
// include: ".tsx$",
exclude: "story\\.tsx$"
exclude: 'story\\.tsx$'
}
]
];
Expand All @@ -45,10 +45,10 @@ module.exports = function(api) {
plugins,
// extensions: [".ts", ".tsx", ".js", ".jsx"],
ignore: [
"src/*.test.js",
"src/*.story.jsx",
"src/*.test.ts",
"src/*.story.tsx"
'src/*.test.js',
'src/*.story.jsx',
'src/*.test.ts',
'src/*.story.tsx'
]
};
};
12 changes: 9 additions & 3 deletions styleguide.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const path = require('path');

module.exports = {
title: "Coinsquare Styleguide",
components: "packages/**/src/!(*.story).*sx"
title: 'Coinsquare Styleguide',
components: 'packages/**/src/!(*.story).*sx',
// resolver: require("react-docgen").resolver.findAllComponentDefinitions,
// propsParser: (filePath, source, resolver, handlers) => {
// return filePath.indexOf(".tsx") > -1
// ? require("react-docgen-typescript")
// .withDefaultConfig()
// .parse(filePath, source, resolver, handlers)
// : require("react-docgen").parse(source, resolver, handlers);
// }
// },
styleguideComponents: {
Wrapper: path.join(__dirname, 'styleguide.wrapper.jsx')
},
assetsDir: path.join(__dirname, 'assets')
};
11 changes: 11 additions & 0 deletions styleguide.wrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { ThemeProvider } from 'styled-components'
import { theme } from './packages/Theme'

const Wrapper = props => (
<ThemeProvider theme={theme}>
{props.children}
</ThemeProvider>
)

export default Wrapper;
10 changes: 7 additions & 3 deletions templates/jsx-component/{{pascalcase name}}/package.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1",
"styled-components": "^3.4.6"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"styled-components": "^4.1.3",
"styled-system": "^3.1.3"
},
"dependencies": {
"styled-system": "^3.1.3",
},
"devDependencies": {
"@coinsquare/build": "^0.0.0",
"@coinsquare/storybook": "^0.0.0"
}
Expand Down
3 changes: 1 addition & 2 deletions templates/jsx-component/{{pascalcase name}}/src/index.js.tpl
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default } from "./{{pascalcase name}}";
export { default as {{pascalcase name}} } from "./{{pascalcase name}}";
export { {{pascalcase name}} } from "./{{pascalcase name}}";
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import React from "react";
import PropTypes from "prop-types";
import React from 'react';

export default class {{pascalcase name}} extends React.PureComponent {
static propTypes = {
/** Sample prop that you can change */
dummyProp: PropTypes.string
};
import PropTypes from 'prop-types';

static defaultProps = {
dummyProp: 'My dummy prop default value'
};
export const {{pascalcase name}} = props => (
<p>{{pascalcase name}} Component {props.dummyProp}</p>
);

render() {
return (
<p>{{pascalcase name}} Component - {this.props.dummyProp}</p>
);
}
}
{{pascalcase name}}.propTypes = {
/** Sample prop that you can change */
dummyProp: PropTypes.string
};

{{pascalcase name}}.defaultProps = {
dummyProp: 'My dummy prop default value'
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { text } from '@storybook/addon-knobs';
import { withInfo } from '@storybook/addon-info';

import {{pascalcase name}} from './{{pascalcase name}}';
import { {{pascalcase name}} } from './{{pascalcase name}}';

import { createStorySetWithDefault, getKnob, getStoryProps } from '@coinsquare/storybook';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';

import {{pascalcase name}} from './{{pascalcase name}}';
import { {{pascalcase name}} } from './{{pascalcase name}}';

const createComponent = newProps => {
const component = renderer.create(
Expand Down
Loading

0 comments on commit efe5fa4

Please sign in to comment.