diff --git a/generators/app/index.js b/generators/app/index.js index b3a745e..222ddd4 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -4,10 +4,10 @@ var yosay = require('yosay') const CLASS_COMPONENT = 'Class Component' const CLASS_SCENE = 'Class Scene' -const FUNCTIONAL_COMPONENT = 'Functional Component' -const FUNCTIONAL_SCENE = 'Functional Scene' +const FUNCTION_COMPONENT = 'Function Component' +const FUNCTION_SCENE = 'Function Scene' const CLASS_COMPONENT_TYPE = 'class' -const FUNCTIONAL_COMPONENT_TYPE = 'functional' +const FUNCTION_COMPONENT_TYPE = 'functional' module.exports = class extends Generator { async prompting() { @@ -18,15 +18,15 @@ module.exports = class extends Generator { this.element = await this.prompt([ { type: 'list', - choices: [FUNCTIONAL_COMPONENT, FUNCTIONAL_SCENE, CLASS_COMPONENT, CLASS_SCENE], - default: FUNCTIONAL_COMPONENT, + choices: [FUNCTION_COMPONENT, FUNCTION_SCENE, CLASS_COMPONENT, CLASS_SCENE], + default: FUNCTION_COMPONENT, name: 'type', message: 'What type of element would you like to create?', required: true, }, ]) - if ([FUNCTIONAL_COMPONENT, CLASS_COMPONENT].includes(this.element.type) === true) { + if ([FUNCTION_COMPONENT, CLASS_COMPONENT].includes(this.element.type) === true) { this.answers = await this.prompt([ { type: 'input', @@ -43,7 +43,7 @@ module.exports = class extends Generator { ]) } - if ([FUNCTIONAL_SCENE, CLASS_SCENE].includes(this.element.type) === true) { + if ([FUNCTION_SCENE, CLASS_SCENE].includes(this.element.type) === true) { this.answers = await this.prompt([ { type: 'input', @@ -64,7 +64,7 @@ module.exports = class extends Generator { } createComponent() { - if ([FUNCTIONAL_COMPONENT, CLASS_COMPONENT].includes(this.element.type) === true) { + if ([FUNCTION_COMPONENT, CLASS_COMPONENT].includes(this.element.type) === true) { let elements = [ { templatePath: `Components/${getComponentType(this.element.type)}/index.js`, @@ -134,7 +134,7 @@ module.exports = class extends Generator { } createScene() { - if ([FUNCTIONAL_SCENE, CLASS_SCENE].includes(this.element.type) === true) { + if ([FUNCTION_SCENE, CLASS_SCENE].includes(this.element.type) === true) { const elements = [ { templatePath: `Scenes/${getComponentType(this.element.type)}/index.js`, @@ -192,7 +192,7 @@ module.exports = class extends Generator { } const getComponentType = (type) => { - let componentType = FUNCTIONAL_COMPONENT_TYPE + let componentType = FUNCTION_COMPONENT_TYPE if ([CLASS_SCENE, CLASS_COMPONENT].includes(type) === true) { componentType = CLASS_COMPONENT_TYPE } diff --git a/generators/app/templates/Components/functional/Element.js b/generators/app/templates/Components/functional/Element.js index 3ba49aa..d27ce19 100644 --- a/generators/app/templates/Components/functional/Element.js +++ b/generators/app/templates/Components/functional/Element.js @@ -1,4 +1,5 @@ // @flow +import * as React from 'react' import { Container } from 'Olio/App/Components/<%= componentName %>/styles' type Props = {} diff --git a/generators/app/templates/Components/functional/index.js b/generators/app/templates/Components/functional/index.js index 4ee2fdd..09b8de2 100644 --- a/generators/app/templates/Components/functional/index.js +++ b/generators/app/templates/Components/functional/index.js @@ -1,7 +1,10 @@ // @flow +import * as React from 'react' import Element from 'Olio/App/Components/<%= componentName %>/<%= componentName %>' import useSelector from 'Olio/App/Utils/useSelector' +type Props = {} + const <%= componentName %> = ({}: Props): React.Node => { const id: number = useSelector(state => state.account.get('id'))