add-react-component
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -5,3 +5,2 @@ const path = require('path') | ||
module.exports = ComponentIndex | ||
@@ -8,0 +7,0 @@ |
const path = require('path') | ||
const fs = require('fs') | ||
const toTitleCase = require('titlecase') | ||
@@ -15,2 +16,4 @@ module.exports = FunctionComponent | ||
function templateWithCSS (name) { | ||
const proper = toTitleCase(name) | ||
return `import React from 'react' | ||
@@ -20,3 +23,3 @@ | ||
export default function ${name} (props) { | ||
export default function ${proper} (props) { | ||
return ( | ||
@@ -23,0 +26,0 @@ <div className={style.container}>${name}</div> |
const path = require('path') | ||
const fs = require('fs') | ||
const toTitleCase = require('titlecase') | ||
@@ -15,2 +16,4 @@ module.exports = PureComponent | ||
function templateWithCSS (name) { | ||
const proper = toTitleCase(name) | ||
return `import React, { PureComponent } from 'react' | ||
@@ -20,3 +23,3 @@ | ||
class ${name} extends PureComponent { | ||
class ${proper} extends PureComponent { | ||
render () { | ||
@@ -29,3 +32,3 @@ return ( | ||
export default ${name} | ||
export default ${proper} | ||
` | ||
@@ -32,0 +35,0 @@ } |
{ | ||
"name": "add-react-component", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Create React Component CLI", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -11,33 +11,62 @@ # add-react-component | ||
## Usage | ||
<br> | ||
``` | ||
# Generate PureComponent and shallow render test | ||
$ add-react-component | ||
## Usage | ||
# Generate PureComponent and shallow render test with stylesheet | ||
$ add-react-component -c | ||
### Generate Class PureComponent | ||
# Generate Functional Component and shallow render test with stylesheet | ||
$ add-react-component -c -f | ||
``` | ||
Run | ||
## Example | ||
```add-react-component ComponentName``` | ||
```sh | ||
add-react-component example -c | ||
``` | ||
Generates `example` folder with the following: | ||
This will create a folder of your component name, and a **Class PureComponent** js file with the same name. | ||
`index.js` | ||
```js | ||
import Example from './example.js' | ||
<br> | ||
export default Example | ||
``` | ||
### Generate Function Component | ||
`style.css` | ||
```css | ||
.container {} | ||
``` | ||
Run | ||
`example.js` | ||
```js | ||
import React, { PureComponent } from 'react' | ||
```add-react-component ComponentName -f``` | ||
import style from './style.css' | ||
This will create a folder of your component name, and **Function Component** js file of the same name. | ||
class Example extends PureComponent { | ||
render () { | ||
return ( | ||
<div className={style.container}>test</div> | ||
) | ||
} | ||
} | ||
<br> | ||
### Generate PureComponent or Function Component with a CSS file | ||
export default Example | ||
``` | ||
Run | ||
`example.test.js` | ||
``` | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
```add-react-component ComponentName -p -c``` | ||
import Example from './example.js' | ||
This will create a folder of your component name, and component (Functional if ```-f```) js file of the same name, and a css file of the same name. | ||
it('renders without props', () => { | ||
shallow(<Example />) | ||
}) | ||
``` | ||
@@ -44,0 +73,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6621
150
75