Initial commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* <%= componentName %> Component
|
||||
* Generated by <%= generatorName %>
|
||||
* Created: <%= timestamp %>
|
||||
*/
|
||||
|
||||
<% if (language === 'typescript') { %>
|
||||
import { <%= imports.join(', ') %> } from '<%= importPath %>'
|
||||
|
||||
export interface <%= componentName %>Props {
|
||||
<% props.forEach(prop => { %>
|
||||
<%= prop.name %>: <%= prop.type %><%= prop.optional ? '?' : '' %>
|
||||
<% }) %>
|
||||
}
|
||||
|
||||
export class <%= componentName %> {
|
||||
<% properties.forEach(property => { %>
|
||||
private <%= property.name %>: <%= property.type %>
|
||||
<% }) %>
|
||||
|
||||
constructor(props: <%= componentName %>Props) {
|
||||
<% properties.forEach(property => { %>
|
||||
this.<%= property.name %> = props.<%= property.name %>
|
||||
<% }) %>
|
||||
}
|
||||
|
||||
<% methods.forEach(method => { %>
|
||||
<%= method.name %>(<%= method.params %>): <%= method.returnType %> {
|
||||
// TODO: Implement <%= method.name %>
|
||||
<% if (method.returnType !== 'void') { %>
|
||||
return <%= method.defaultReturn %>
|
||||
<% } %>
|
||||
}
|
||||
<% }) %>
|
||||
}
|
||||
<% } else if (language === 'javascript') { %>
|
||||
/**
|
||||
* <%= componentName %> Component
|
||||
*/
|
||||
class <%= componentName %> {
|
||||
constructor(options = {}) {
|
||||
<% properties.forEach(property => { %>
|
||||
this.<%= property.name %> = options.<%= property.name %> || <%= property.default %>
|
||||
<% }) %>
|
||||
}
|
||||
|
||||
<% methods.forEach(method => { %>
|
||||
<%= method.name %>(<%= method.params %>) {
|
||||
// TODO: Implement <%= method.name %>
|
||||
}
|
||||
<% }) %>
|
||||
}
|
||||
|
||||
module.exports = <%= componentName %>
|
||||
<% } %>
|
||||
|
||||
<% if (includeTests) { %>
|
||||
|
||||
/**
|
||||
* Tests for <%= componentName %>
|
||||
*/
|
||||
describe('<%= componentName %>', () => {
|
||||
<% methods.forEach(method => { %>
|
||||
test('<%= method.name %> should work', () => {
|
||||
// TODO: Write test for <%= method.name %>
|
||||
})
|
||||
<% }) %>
|
||||
})
|
||||
<% } %>
|
||||
|
||||
<% if (includeDocumentation) { %>
|
||||
|
||||
/**
|
||||
* DOCUMENTATION
|
||||
*
|
||||
* Usage Example:
|
||||
* ```<%= language %>
|
||||
* <% if (language === 'typescript') { %>
|
||||
* const instance = new <%= componentName %>({
|
||||
* <% props.forEach(prop => { %>
|
||||
* <%= prop.name %>: <%= prop.exampleValue %>,
|
||||
* <% }) %>
|
||||
* })
|
||||
* <% } else { %>
|
||||
* const instance = new <%= componentName %>({
|
||||
* <% properties.forEach(property => { %>
|
||||
* <%= property.name %>: <%= property.exampleValue %>,
|
||||
* <% }) %>
|
||||
* })
|
||||
* <% } %>
|
||||
*
|
||||
* <% methods.forEach(method => { %>
|
||||
* instance.<%= method.name %>(<%= method.exampleArgs %>)
|
||||
* <% }) %>
|
||||
* ```
|
||||
*/
|
||||
<% } %>
|
||||
Reference in New Issue
Block a user