Created
August 7, 2019 07:01
-
-
Save wickstjo/c01d7e32a263e91124d9be2bb5c5138b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import { render } from 'ink'; | |
import Input from './components/input'; | |
function Container() { | |
// LOCAL STATE | |
const [local, set_local] = useState({ | |
name: 'testing' | |
}) | |
// UPDATE FIELD | |
function update({ property, value }) { | |
set_local({ | |
...local, | |
[property]: value | |
}) | |
} | |
return ( | |
<Input | |
header={ 'Enter your query' } | |
value={ local.name } | |
placeholder={ 'something' } | |
dispatch={ update } | |
id={ 'name' } | |
/> | |
) | |
} | |
render(<Container />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Fragment } from 'react'; | |
import { Box } from 'ink'; | |
import TextInput from 'ink-select-input'; | |
function Input({ header, value, placeholder, dispatch, id }) { return ( | |
<Fragment> | |
<Box marginRight={ 1 }>{ header }:</Box> | |
<TextInput | |
value={ value } | |
placeholder={ placeholder } | |
onChange={ | |
query => dispatch({ | |
property: id, | |
value: query | |
}) | |
} | |
/> | |
</Fragment> | |
)} | |
export default Input; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment