Skip to content

Commit

Permalink
Add suggested updates from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesdev committed Aug 16, 2021
1 parent 54af70d commit 17d1251
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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`,
Expand Down Expand Up @@ -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`,
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions generators/app/templates/Components/functional/Element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import * as React from 'react'
import { Container } from 'Olio/App/Components/<%= componentName %>/styles'

type Props = {}
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/Components/functional/index.js
Original file line number Diff line number Diff line change
@@ -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'))

Expand Down

0 comments on commit 17d1251

Please sign in to comment.