Skip to content

Commit

Permalink
Add readme when creating component for styleguide now
Browse files Browse the repository at this point in the history
  • Loading branch information
kucukkanat committed Feb 22, 2018
1 parent 7031637 commit 0801249
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 76 deletions.
57 changes: 0 additions & 57 deletions src/javascript/components/Navbar/index.js

This file was deleted.

37 changes: 21 additions & 16 deletions tasks/new.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,35 @@ const consolidate = require('gulp-consolidate')
const rename = require('gulp-rename')

module.exports = (done) => {
inquirer.prompt([
{
'type':'input',
'name':'componentName',
'message':'What is your component name ? (Component name should start with a Capital letter)'
},
{
'type':'confirm',
'name':'reduxEnabled',
'message':'Enable redux for component ? '
}
inquirer.prompt([{
'type': 'input',
'name': 'componentName',
'message': 'What is your component name ? (Component name should start with a Capital letter)'
},
{
'type': 'confirm',
'name': 'reduxEnabled',
'message': 'Enable redux for component ? '
}
])
.then(response => {
const initial = response.componentName[0]
const uppercase = initial.toUpperCase() == initial
let params = Object.assign({},response)
let params = Object.assign({}, response)
params.componentName_lowercase = params.componentName.toLowerCase()
if(!uppercase) throw new Error('Component name should start with an uppercase letter!')

if (!uppercase) throw new Error('Component name should start with an uppercase letter!')
// Create component file
gulp.src('./tasks/templates/react.component.js')
.pipe(consolidate('mustache',params))
.pipe(consolidate('mustache', params))
.pipe(rename(`index.js`))
.pipe(gulp.dest(`src/javascript/components/${response.componentName}`))

// Create styleguide file
gulp.src('./tasks/templates/readme.md')
.pipe(consolidate('mustache', params))
.pipe(rename(`readme.md`))
.pipe(gulp.dest(`src/javascript/components/${response.componentName}`))
})
.catch(e => {
console.log(e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Navbar example
{{componentName}} example

```jsx
{{#reduxEnabled}}
const store = require('./../../store').default;
const { Provider } = require('react-redux');

<Provider store={store}>
<Navbar />
{{/reduxEnabled}}

<{{componentName}} />

{{#reduxEnabled}}
</Provider>
{{/reduxEnabled}}
```

0 comments on commit 0801249

Please sign in to comment.