-
Notifications
You must be signed in to change notification settings - Fork 0
/
reactCreator.js
81 lines (65 loc) · 1.63 KB
/
reactCreator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// IIFE를 사용한 모듈패턴으로 함수의 이름이나, 변수가 겹치는 것을 방지하고 reactCreator로 네임스페이스를 만들어준다.
const reactCreator = (function() {
const reactPresentTemplate = function(name) {
const temp = `import React from 'react';
import styles from './index.scss';
import classNames from 'classnames/bind';
const cx = classNames.bind(styles);
const ${name} = (props) => {
return(
<>
</>
);
};
export default ${name};
`;
return temp;
};
const reactContainerTemplate = function(name) {
const temp = `import React, {Component} from 'react';
import styles from './index.scss';
import classNames from 'classnames/bind';
const cx = classNames.bind(styles);
class ${name} extends Component{
render(){
return(
<>
</>
);
}
};
export default ${name};
`;
return temp;
};
const reactPresentTemplateStyled = function(name) {
const temp = `import React from 'react';
import styled from 'styled-components';
const ${name} = (props) => {
return(
<>
</>
);
};
export default ${name};
`;
return temp;
};
const reactContainerTemplateStyled = function(name) {
const temp = `import React, {Component} from 'react';
import styled from 'styled-components';
class ${name} extends Component{
render(){
return(
<>
</>
);
}
};
export default ${name};
`;
return temp;
};
return { reactPresentTemplate, reactContainerTemplate, reactContainerTemplateStyled, reactPresentTemplateStyled };
})();
module.exports = reactCreator;