diff options
author | 2021-05-03 12:15:13 -0500 | |
---|---|---|
committer | 2021-05-03 12:15:13 -0500 | |
commit | ed631329e731d31e384dacc1ec399ba60b7c906b (patch) | |
tree | 0c998bb642c1feab773cb0e751dbb0ece1e59d64 /packages/create-astro/src/components/Confirm.tsx | |
parent | 467820996f71b0c78f2000294cb6f3c0a8f3aca4 (diff) | |
download | astro-ed631329e731d31e384dacc1ec399ba60b7c906b.tar.gz astro-ed631329e731d31e384dacc1ec399ba60b7c906b.tar.zst astro-ed631329e731d31e384dacc1ec399ba60b7c906b.zip |
`create-astro` UI (#164)
* refactor: improve create-astro layout, build script
* feat(create-astro): v0.1.0
* docs(create-astro): add README
* feat(create-astro): add meta files to starter templates
Diffstat (limited to 'packages/create-astro/src/components/Confirm.tsx')
-rw-r--r-- | packages/create-astro/src/components/Confirm.tsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/create-astro/src/components/Confirm.tsx b/packages/create-astro/src/components/Confirm.tsx new file mode 100644 index 000000000..1fd1aa862 --- /dev/null +++ b/packages/create-astro/src/components/Confirm.tsx @@ -0,0 +1,49 @@ +import React, { FC } from 'react'; +import { Box, Text, useInput, useApp } from 'ink'; +import Spacer from './Spacer'; +import Select from './Select'; + +const Confirm: FC<{ message?: any; context: any; onSubmit: (value: boolean) => void }> = ({ message, context: { projectName }, onSubmit }) => { + const { exit } = useApp(); + const handleSubmit = (v: boolean) => { + if (!v) return exit(); + onSubmit(v); + }; + + return ( + <> + <Box display="flex"> + {!message ? ( + <> + <Text color="#FFBE2D">{'[uh-oh]'}</Text> + <Text> + {' '} + It appears <Text color="#17C083">./{projectName}</Text> is not empty. Overwrite? + </Text> + </> + ) : ( + message + )} + </Box> + <Box display="flex"> + <Spacer width={6} /> + <Select + items={[ + { + value: false, + label: 'no' + }, + { + value: true, + label: 'yes', + description: <Text color="#FF1639">overwrite</Text>, + }, + ]} + onSelect={handleSubmit} + /> + </Box> + </> + ); +}; + +export default Confirm; |