-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
import TextAreaComponent from './TextArea'; | ||
|
||
const TextArea = (args) => { | ||
const [value, setValue] = React.useState(args.value ?? ''); | ||
const onChange = (block, value) => { | ||
args.onChange({ value }); | ||
setValue(value); | ||
}; | ||
|
||
return <TextAreaComponent {...args} onChange={onChange} value={value} />; | ||
}; | ||
|
||
export const Default = TextArea.bind({}); | ||
Default.args = { | ||
id: 'field-empty', | ||
title: 'field 1 title', | ||
description: 'Optional help text', | ||
placeholder: 'Type something…', | ||
}; | ||
|
||
export const Required = TextArea.bind({}); | ||
Required.args = { | ||
id: 'field-empty', | ||
title: 'field 1 title', | ||
description: 'Optional help text', | ||
placeholder: 'Type something…', | ||
required: true, | ||
}; | ||
|
||
export const Filled = TextArea.bind({}); | ||
Filled.args = { | ||
id: 'field-filled', | ||
title: 'Filled field title', | ||
description: 'Optional help text', | ||
value: 'Filled with value A', | ||
placeholder: 'Type something…', | ||
required: true, | ||
}; | ||
|
||
export const Errored = TextArea.bind({}); | ||
Errored.args = { | ||
id: 'field-errored', | ||
title: 'Errored field title', | ||
description: 'Optional help text', | ||
placeholder: 'Type something…', | ||
value: 'Filled with value A', | ||
error: ['This is the error'], | ||
required: true, | ||
}; | ||
|
||
export const Disabled = TextArea.bind({}); | ||
Disabled.args = { | ||
id: 'field-disabled', | ||
title: 'Disabled field title', | ||
description: 'Optional help text', | ||
placeholder: 'Type something…', | ||
disabled: true, | ||
}; | ||
|
||
export default { | ||
title: 'TextArea', | ||
component: TextAreaComponent, | ||
decorators: [ | ||
(Story) => ( | ||
<div style={{ width: '400px' }}> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
argTypes: { | ||
// controlled value prop | ||
value: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
// excludeStories: ['searchResults'], | ||
// subcomponents: { ArgsTable }, | ||
}; |