Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit68b44d3

Browse files
committed
chore(uptodate): generators
1 parent1170089 commit68b44d3

File tree

8 files changed

+56
-26
lines changed

8 files changed

+56
-26
lines changed
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
/*
2-
*
3-
*{{properCasename}}
4-
*
2+
*
3+
*{{properCasename}}
4+
*
55
*/
66

77
import React from 'react'
88
import 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+
{{#ifwantStyle}}
11+
import { Wrapper } from './styles'
12+
{{/if}}
1413
{{#ifwantMessages}}
1514
import { FormattedMessage } from 'react-intl'
1615
import messages from './messages'
1716
{{/if}}
1817

19-
// @inject('')
20-
// @observer
21-
class{{properCasename}} extends React.Component {
18+
import { makeDebugger } from '../../utils'
19+
20+
/* eslint-disable no-unused-vars */
21+
const debug = makeDebugger('c:{{properCasename}}:index')
22+
/* eslint-enable no-unused-vars */
23+
24+
class{{properCasename}} extends React.PureComponent {
2225
componentDidMount() {}
2326

2427
componentWillUnmount() {}
2528

2629
render() {
2730
return (
2831
<div>
29-
{{properCasename}} component
30-
{{#ifwantMessages}}
31-
<FormattedMessage {...messages.header} />
32-
{{/if}}
32+
{{properCasename}} component
33+
{{#ifwantMessages}}
34+
<FormattedMessage {...messages.header} />
35+
{{/if}}
3336
</div>
3437
)
3538
}
3639
}
3740

38-
export default{{properCasename}}
39-
40-
Index.propTypes = {
41+
{{properCasename}}.propTypes = {
4142
// https://www.npmjs.com/package/prop-types
4243
}
4344

44-
Index.defaultProps = {}
45+
{{properCasename}}.defaultProps = {}
46+
47+
export default{{properCasename}}

‎utils/scripts/generators/component/index.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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
returnactions
8398
},
8499
}

‎utils/scripts/generators/component/stateless.js.hbs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
/*
1+
/*
22
*
33
*{{properCasename}}
44
*
5-
*/
5+
*/
66

77
import React from 'react'
88
import PropTypes from 'prop-types'
99

10+
{{#ifwantStyle}}
11+
import { Wrapper } from './styles'
12+
{{/if}}
1013
{{#ifwantI18n}}
1114
import { FormattedMessage as I18n } from 'react-intl'
1215
import lang from './lang'
1316
{{/if}}
1417

1518
import { makeDebugger } from '../../utils'
19+
1620
/* eslint-disable no-unused-vars */
1721
const debug = makeDebugger('c:{{properCasename}}:index')
1822
/* eslint-enable no-unused-vars */
@@ -34,4 +38,4 @@ const {{ properCase name }} = (props) => {
3438

3539
{{properCasename}}.defaultProps = {}
3640

37-
export default{{properCasename}}
41+
export defaultReact.memo({{properCasename}})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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``

‎utils/scripts/generators/container/class.js.hbs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const debug = makeDebugger('C:{{ properCase name }}')
2222

2323
// NOTE: add me to ../containers/index
2424
class{{properCasename}}Container extends React.Component {
25-
componentWillMount() {
25+
componentDidMount() {
2626
const{{preCurly""}}{{camelCasename}}{{afterCurly""}} = this.props
2727
logic.init({{camelCasename}})
2828
}

‎utils/scripts/generators/container/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
],

‎utils/scripts/generators/container/styles.js.hbs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from 'styled-components'
2-
// import Img from '../../Img'
2+
3+
// import Img from '../../../components/Img'
34
// import { theme } from '../../../utils'
45

56
export const Wrapper = styled.div``

‎utils/scripts/generators/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const componentGenerator = require('./component/index.js')
22
constcontainerGenerator=require('./container/index.js')
33
conststoreGenerator=require('./store/index.js')
44

5-
module.exports=function(plop){
5+
module.exports=functiongenerators(plop){
66
// see: https://github.com/amwmedia/plop/issues/116
77
plop.setHelper('preCurly',t=>`{${t}`)
88
plop.setHelper('afterCurly',t=>`${t}}`)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp