Skip to content

Commit 6056fa5

Browse files
committed
Update docs CUSTOM_TEMPLATES
1 parent 2fadb78 commit 6056fa5

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

docs/CUSTOM-TEMPLATES.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,41 @@
22

33
With this library you can create your own templates and use them to generate your components in a second!
44

5-
### 1) Create your custom templates folder
5+
### 1) Create your custom template folder
66

7-
Create a folder where you want.
8-
In this folder we will put the custom templates.
7+
Create a folder to contain all your custom templates.
8+
In this folder we will put the custom templates folders.
99

1010
### 2) Add the folder to the config
1111

12-
Create a `config.json` (in the `.ccarc` folder or where you want) file where you write the options to generate your components from the custom templates.
12+
Create a [config file](https://github.com/CVarisco/create-component-app#you-can-create-a-configuration-file-in-your-current-project-directory) where you write the options to generate your components from the custom templates folder
1313

14-
config.json:
14+
config:
1515

1616
```json
1717
{
18-
"templatesDirPath": "PATH/OF/CUSTOM/TEMPLATES/FOLDER",
19-
"templateName": "NAME_OF_TEMPLATE_FOLDER"
18+
"type": "custom",
19+
"templatesDirPath": "PATH/OF/CUSTOM/TEMPLATES/FOLDER",
20+
"templateName": "NAME_OF_TEMPLATE_FOLDER"
2021
}
2122
```
2223

2324
### 3) Create a folder for your template
2425

2526
Create a folder inside the templates folder
2627
Inside this folder we will put all the files of the template.
28+
[Examples](https://github.com/CVarisco/create-component-app/tree/master/templates)
2729

2830
### 4) Create your templates
2931

3032
Create your templates file.
31-
The only thing that you need to set in the template is the name of the component.
33+
The only thing that you need to set in the template is the name of the component.
3234

33-
- *Note: filenames with **COMPONENT_NAME** will be replaced with the component name.*
34-
- *Note: filename that includes "index" will not renamed*
35-
- *Note: the extension of the file will be used (so, use whatever you want)*
35+
* _Note: filenames with **COMPONENT_NAME** will be replaced with the component name._
36+
* _Note: filename that includes "index" will not renamed_
37+
* _Note: the extension of the file will be used (so, use whatever you want)_
3638

37-
#### You can create a configuration file in your template directory
39+
#### (Optional) You can create a configuration file in your template directory
3840

3941
Create-component-app uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support.
4042
This means you can configure cca via:
@@ -47,7 +49,6 @@ and searching up the file tree until a config file is (or isn't) found.
4749

4850
Example of component custom template `.ccarc`:
4951

50-
5152
```js
5253
{
5354
"noMkdir": true, // will spread the template files in the output directory
@@ -57,53 +58,53 @@ Example of component custom template `.ccarc`:
5758
Example of component custom template `template.js`:
5859

5960
```javascript
60-
import React, {Component} from 'react'
61-
import PropTypes from 'prop-types'
61+
import React, { Component } from "react";
62+
import PropTypes from "prop-types";
6263

6364
class COMPONENT_NAME extends Component {
64-
constructor(props) {
65-
super(props)
66-
}
67-
68-
render() {
69-
return (
70-
<div className="COMPONENT_NAME"></div>
71-
);
72-
}
65+
constructor(props) {
66+
super(props);
67+
}
68+
69+
render() {
70+
return <div className="COMPONENT_NAME" />;
71+
}
7372
}
7473

75-
COMPONENT_NAME.propTypes = {}
74+
COMPONENT_NAME.propTypes = {};
7675

77-
COMPONENT_NAME.defaultProps = {}
76+
COMPONENT_NAME.defaultProps = {};
7877

79-
export default COMPONENT_NAME
78+
export default COMPONENT_NAME;
8079
```
8180

8281
Example of custom style file `style.scss`:
8382

8483
```css
85-
@import 'partials/variables'
86-
87-
.COMPONENT_NAME{
88-
background-color: $grey;
84+
@import "partials/variables" .COMPONENT_NAME {
85+
background-color: $grey;
8986
}
9087

91-
.container .COMPONENT_NAME{
92-
background-color: $yellow;
88+
.container .COMPONENT_NAME {
89+
background-color: $yellow;
9390
}
9491
```
9592

96-
9793
### 5) Launch the tool
9894

9995
Launch the tool to generate components or pass a arg
10096

10197
```bash
102-
create-component-app --template $TEMPLATE_NAME
98+
create-component-app
10399
```
104100

105-
**$TEMPLATE_NAME should be the name of the subfolder
101+
Optional:
102+
103+
```bash
104+
create-component-app --template $TEMPLATE_NAME
105+
```
106106

107-
Select the name and the destination path of your templates.
107+
$TEMPLATE_NAME should be the name of the subfolder.
108+
This argument override the `templateName` option in your config file.
108109

109110
**NOTE: With this configuration, you can add only the `path` parameter to set the default destination. The others parameters will be ignored**

0 commit comments

Comments
 (0)