This repository was archived by the owner on Nov 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +56
-26
lines changed Expand file tree Collapse file tree 8 files changed +56
-26
lines changed Original file line number Diff line number Diff line change 11/*
2- *
3- * {{ properCase name }}
4- *
2+ *
3+ * {{ properCase name }}
4+ *
55*/
66
77import React from 'react'
88import PropTypes from 'prop-types'
99
10- // import { inject, observer } from 'mobx-react'
11- // import Link from 'next/link'
12- // import styled from 'styled-components'
13-
10+ {{ #if wantStyle }}
11+ import { Wrapper } from './styles'
12+ {{ /if }}
1413{{ #if wantMessages }}
1514import { FormattedMessage } from 'react-intl'
1615import messages from './messages'
1716{{ /if }}
1817
19- // @inject('')
20- // @observer
21- class {{ properCase name }} extends React.Component {
18+ import { makeDebugger } from '../../utils'
19+
20+ /* eslint-disable no-unused-vars */
21+ const debug = makeDebugger('c:{{ properCase name }} :index')
22+ /* eslint-enable no-unused-vars */
23+
24+ class {{ properCase name }} extends React.PureComponent {
2225 componentDidMount() {}
2326
2427 componentWillUnmount() {}
2528
2629 render() {
2730 return (
2831 <div >
29- {{ properCase name }} component
30- {{ #if wantMessages }}
31- <FormattedMessage {...messages.header} />
32- {{ /if }}
32+ {{ properCase name }} component
33+ {{ #if wantMessages }}
34+ <FormattedMessage {...messages.header} />
35+ {{ /if }}
3336 </div >
3437 )
3538 }
3639}
3740
38- export default {{ properCase name }}
39-
40- Index.propTypes = {
41+ {{ properCase name }} .propTypes = {
4142 // https://www.npmjs.com/package/prop-types
4243}
4344
44- Index.defaultProps = {}
45+ {{ properCase name }} .defaultProps = {}
46+
47+ export default {{ properCase name }}
Original file line number Diff line number Diff line change @@ -36,9 +36,15 @@ module.exports = {
3636 {
3737 type : 'confirm' ,
3838 name : 'wantI18n' ,
39- default : true ,
39+ default : false ,
4040 message : 'Do you want i18n messages (i.e. will this component use text)?' ,
4141 } ,
42+ {
43+ type : 'confirm' ,
44+ name : 'wantStyle' ,
45+ default : true ,
46+ message : 'Does it have styles?' ,
47+ } ,
4248 ] ,
4349 actions : data => {
4450 // Generate index.js and index.test.js
@@ -79,6 +85,15 @@ module.exports = {
7985 } )
8086 }
8187
88+ if ( data . wantStyle ) {
89+ actions . push ( {
90+ type : 'add' ,
91+ path : '../../../components/{{properCase name}}/styles/index.js' ,
92+ templateFile : './component/styles.js.hbs' ,
93+ abortOnFail : true ,
94+ } )
95+ }
96+
8297 return actions
8398 } ,
8499}
Original file line number Diff line number Diff line change 1- /*
1+ /*
22 *
33 * {{ properCase name }}
44 *
5- */
5+ */
66
77import React from 'react'
88import PropTypes from 'prop-types'
99
10+ {{ #if wantStyle }}
11+ import { Wrapper } from './styles'
12+ {{ /if }}
1013{{ #if wantI18n }}
1114import { FormattedMessage as I18n } from 'react-intl'
1215import lang from './lang'
1316{{ /if }}
1417
1518import { makeDebugger } from '../../utils'
19+
1620/* eslint-disable no-unused-vars */
1721const debug = makeDebugger('c:{{ properCase name }} :index')
1822/* eslint-enable no-unused-vars */
@@ -34,4 +38,4 @@ const {{ properCase name }} = (props) => {
3438
3539{{ properCase name }} .defaultProps = {}
3640
37- export default {{ properCase name }}
41+ export default React.memo( {{ properCase name }} )
Original file line number Diff line number Diff line change 1+ import styled from 'styled-components'
2+
3+ // import Img from '../../Img'
4+ // import { theme } from '../../../utils'
5+
6+ export const Wrapper = styled.div``
7+ export const Title = styled.div``
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const debug = makeDebugger('C:{{ properCase name }}')
2222
2323// NOTE: add me to ../containers/index
2424class {{ properCase name }} Container extends React.Component {
25- componentWillMount () {
25+ componentDidMount () {
2626 const {{ preCurly " " }} {{ camelCase name }} {{ afterCurly " " }} = this.props
2727 logic.init({{ camelCase name }} )
2828 }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ module.exports = {
3535 {
3636 type : 'confirm' ,
3737 name : 'wantI18n' ,
38- default : true ,
38+ default : false ,
3939 message : 'Do you want i18n messages (i.e. will this container use text)?' ,
4040 } ,
4141 ] ,
Original file line number Diff line number Diff line change 11import styled from 'styled-components'
2- // import Img from '../../Img'
2+
3+ // import Img from '../../../components/Img'
34// import { theme } from '../../../utils'
45
56export const Wrapper = styled.div``
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const componentGenerator = require('./component/index.js')
22const containerGenerator = require ( './container/index.js' )
33const storeGenerator = require ( './store/index.js' )
44
5- module . exports = function ( plop ) {
5+ module . exports = function generators ( plop ) {
66 // see: https://github.com/amwmedia/plop/issues/116
77 plop . setHelper ( 'preCurly' , t => `{${ t } ` )
88 plop . setHelper ( 'afterCurly' , t => `${ t } }` )
You can’t perform that action at this time.
0 commit comments