Skip to content

Commit e4e26c8

Browse files
feat: select installation type
1 parent 454b198 commit e4e26c8

2 files changed

Lines changed: 67 additions & 43 deletions

File tree

source/app.tsx

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,46 @@
1-
import { Box } from 'ink'
2-
import BigText from 'ink-big-text'
3-
import Gradient from 'ink-gradient'
4-
import React, { useState } from 'react'
1+
import { Box, Text } from 'ink'
2+
import React, { useState, type ReactNode } from 'react'
3+
import MainTitle from './import/MainTitle.js'
54
import Step1 from './import/Step1.js'
65
import Step2 from './import/Step2.js'
7-
import Step3 from './import/Step3.js'
6+
import Step3, { type ItemProps } from './import/Step3.js'
87
import { canShowStep } from './import/utils.js'
98

109
const App = () => {
1110
const [projectName, setProjectName] = useState<string>('')
1211
const [currentStep, setCurrentStep] = useState(1)
12+
const [setupOption, setSetupOption] = useState<ItemProps | undefined>()
1313

1414
const finishStep = () => setCurrentStep(currentStep + 1)
15+
const onSelect = (item: ItemProps) => setSetupOption(item)
1516

16-
const onSelect = (value: string) => {
17-
console.log(value)
18-
}
17+
const steps: Array<ReactNode> = [
18+
<Step1
19+
onSubmit={setProjectName}
20+
onCompletion={finishStep}
21+
projectName={projectName}
22+
key={1}
23+
/>,
24+
<Step2
25+
onCompletion={finishStep}
26+
projectName={projectName}
27+
key={2}
28+
/>,
29+
<Step3
30+
onCompletion={finishStep}
31+
onSelect={onSelect}
32+
key={3}
33+
/>,
34+
]
1935

2036
return (
2137
<Box
2238
flexDirection={'column'}
2339
rowGap={1}
2440
>
25-
<Gradient colors={['#ff438c', '#bb1d79', '#8b46a4', '#6a2581']}>
26-
<BigText
27-
lineHeight={1}
28-
font={'chrome'}
29-
text="dAppBooster"
30-
/>
31-
</Gradient>
32-
<Step1
33-
onSubmit={setProjectName}
34-
onCompletion={finishStep}
35-
projectName={projectName}
36-
/>
37-
{canShowStep(currentStep, 2) && (
38-
<Step2
39-
projectName={projectName}
40-
onCompletion={finishStep}
41-
/>
42-
)}
43-
{canShowStep(currentStep, 3) && (
44-
<Step3
45-
onCompletion={finishStep}
46-
onSelect={onSelect}
47-
projectName={projectName}
48-
/>
49-
)}
41+
<MainTitle />
42+
{steps.map((item, index) => canShowStep(currentStep, index + 1) && item)}
43+
{canShowStep(currentStep, 4) && <Text>{setupOption?.value}</Text>}
5044
</Box>
5145
)
5246
}

source/import/Step3.tsx

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
1+
import { Box, Text } from 'ink'
12
import Divider from 'ink-divider'
3+
import SelectInput from 'ink-select-input'
24
import React, { type FC } from 'react'
35

6+
export interface ItemProps {
7+
label: string
8+
value: string
9+
}
10+
411
interface Props {
5-
projectName: string
612
onCompletion: () => void
13+
onSelect: (item: ItemProps) => void
714
}
815

9-
const Step3: FC<Props> = ({ projectName, onCompletion }) => (
10-
<>
11-
<Divider
12-
titlePadding={2}
13-
titleColor={'whiteBright'}
14-
title={'Installation setup'}
15-
/>
16-
</>
17-
)
16+
const Step3: FC<Props> = ({ onCompletion, onSelect }) => {
17+
const handleSelect = (item: ItemProps) => {
18+
onSelect(item)
19+
onCompletion()
20+
}
21+
22+
const items = [
23+
{
24+
label: 'Full',
25+
value: 'full',
26+
},
27+
{
28+
label: 'Custom',
29+
value: 'custom',
30+
},
31+
]
32+
33+
return (
34+
<>
35+
<Divider
36+
titlePadding={2}
37+
titleColor={'whiteBright'}
38+
title={'Installation setup'}
39+
/>
40+
<Text color={'whiteBright'}>Choose installation type</Text>
41+
<SelectInput
42+
items={items}
43+
onSelect={handleSelect}
44+
/>
45+
</>
46+
)
47+
}
1848

1949
export default Step3

0 commit comments

Comments
 (0)