-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add text-area component #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
8b926db
2a64807
149d10d
1f3ebfb
16eb057
fba24ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { ScoutTextArea } from "@scouterna/ui-react"; | ||
| import preview from "#.storybook/preview"; | ||
|
|
||
| const meta = preview.meta({ | ||
| title: "Uncategorized/Text-Area", | ||
| component: ScoutTextArea, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| }); | ||
|
|
||
| export default meta; | ||
|
|
||
| export const BasicExample = meta.story({ | ||
| args: { | ||
| label: "", | ||
| }, | ||
| render: (args) => <ScoutTextArea {...args} />, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # scout-text-area | ||
|
|
||
| <!-- Auto Generated Below --> | ||
|
|
||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Attribute | Description | Type | Default | | ||
| | ------------- | ------------- | ----------- | --------- | ----------- | | ||
| | `autofocus` | `autofocus` | | `boolean` | `false` | | ||
| | `disabled` | `disabled` | | `boolean` | `undefined` | | ||
| | `form` | `form` | | `string` | `undefined` | | ||
| | `label` | `label` | | `string` | `undefined` | | ||
| | `maxLength` | `max-length` | | `number` | `undefined` | | ||
| | `placeholder` | `placeholder` | | `string` | `undefined` | | ||
| | `readOnly` | `read-only` | | `boolean` | `undefined` | | ||
| | `required` | `required` | | `boolean` | `undefined` | | ||
| | `value` | `value` | | `string` | `undefined` | | ||
|
|
||
|
|
||
| ---------------------------------------------- | ||
|
|
||
| *Built with [StencilJS](https://stenciljs.com/)* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| :host { | ||
| display: inline-flex; | ||
| } | ||
|
|
||
| .flexbox{ | ||
| display: inline-flex; | ||
| flex-direction: column; | ||
| padding: 0.5rem; | ||
| } | ||
|
|
||
| .textarea{ | ||
| resize: none; | ||
| height: var(--spacing-24); | ||
| width: var(--spacing-50); | ||
| padding: var(--spacing-2); | ||
| font: var(--type-body-base); | ||
| border: 1px solid var(--color-gray-300); | ||
| border-radius: var(--spacing-2); | ||
| background-color: var(--color-white); | ||
| color: var(--color-text-base); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||
| import { Component, h, Prop } from "@stencil/core"; | ||||||||||
|
|
||||||||||
| @Component({ | ||||||||||
| tag: "scout-text-area", | ||||||||||
| styleUrl: "text-area.css", | ||||||||||
| shadow: { | ||||||||||
| delegatesFocus: true, | ||||||||||
| }, | ||||||||||
|
||||||||||
| shadow: { | |
| delegatesFocus: true, | |
| }, | |
| scoped: true, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the name prop? Just realized we're missing that on all inputs. I'll add it to the others in a separate PR 😊
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you've added a label as well! We've set up a generic Field component that wraps all input type components. I forgot to tell you about that, sorry 😣 I think we should add support for that here as well and remove the label from this component. In other words:
- Remove the
divandlabelso that only thetextareais left. - Implement the following from the
Inputcomponent (reference code):- Add the
scoutInputChangeevent that tells the form field about changes that should cause re-validation. - Add the
scoutBlurevent that tells the form field that the field is ready to be validated. - Add the internal
_fieldIdevent that's used by the form field to connect it to the text area. - Add the internal
ariaIdstate that keeps track of the internal ID used for connecting to form field. - Assign the
ariaIdstate in thecomponentWillLoadhook. - Handle the
onInputevent and potential validation.
- Add the
- See other comment about shadow DOM.
- Finally you might want to add another story in
field.stories.tsxto test it out together, like we did for the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the width and height unset so that the consumer can choose how to size the component. What we could do instead is expose the rows attribute as a prop and maybe set it to a higher default, say 3?