Skip to content

Commit

Permalink
Add story example to illustrate resetting ReactCodeInput 40818419#69 4…
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Oct 15, 2021
1 parent 1b0b5ab commit 61410ec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/ReactCodeInput.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ const darkStyle = {
stories.addDecorator((story, context) => withInfo('Details')(story)(context));
stories.addDecorator(withKnobs);

// Component for With Reset story
function WithReset() {
const [value, setValue] = React.useState(null);

return (
<React.Fragment>
<ReactCodeInput onChange={() => setValue(null)} value={value} />
<button style={{ ...inputStyle, width: 'auto', backgroundColor: 'lightgray' }} onClick={() => setValue('')}>Reset</button>
</React.Fragment>
)
}

// Stories for Input Field
stories
.add(
Expand All @@ -72,7 +84,8 @@ stories
.add(
'Force Uppercase', () =>
<CodeInputField fields={4} type="text" forceUppercase value="test" onChange={action('onChange')} />
);
)
.add('With Reset', WithReset);

// Creation of Props
propVariantStories.addDecorator((story, context) => withInfo('Details')(story)(context));
Expand Down

0 comments on commit 61410ec

Please sign in to comment.