forked from adeyahya/regenr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.js
48 lines (40 loc) · 1.01 KB
/
template.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
const template = (() => {
const options = {
css: "scss",
cssModules: false
};
const getIndex = (componentName) => `import ${componentName} from './${componentName}';
export default ${componentName};
`;
const getReact = (componentName, style, cssModules = options.cssModules) => `import React, { Component } from 'react';
${cssModules ? "import styles from './" + componentName + "." + style + "';" : ""}
export default class ${componentName} extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div ${cssModules ? "className={" + "styles." + componentName + "}" : "" }>
{/* Your code here */}
</div>
);
}
}
`;
const getStyle = (componentName, style = "scss") => {
if (style === "sass") {
return `.${componentName}
/* Your stylesheet here */`;
}
return `.${componentName} {
/* Your stylesheet here */
}`;
};
return {
getStyle,
getReact,
getIndex
};
})();
module.exports = template;