Skip to content
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

chore(form-field): Update FormField Readme #930

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions modules/form-field/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ import * as React from 'react;
import FormField from '@workday/canvas-kit-react-form-field';
import TextInput from '@workday/canvas-kit-react-text-input';

<FormField
label="Label"
inputId="my-input-field"
error={FormField.ErrorType.Error}
hintText="This field is required."
hintId="my-input-field-error"
required={true}
>
<TextInput value={this.state.value} onChange={() => {}}/>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BYE CLASS COMPONENTS ✌️

</FormField>
const ExampleForm = () => {
const [value, setValue] = React.useState('');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooks, ftw! 🎉

return (
<FormField
label="Label"
inputId="my-input-field"
error={FormField.ErrorType.Error}
hintText="This field is required."
hintId="my-input-field-error"
required={true}
>
<TextInput value={value} onChange={(e) => setValue(e.target.value)}/>
</FormField>
);
}
```

## Static Properties
Expand Down Expand Up @@ -95,7 +100,7 @@ Default: `undefined`

#### `hintId: string`

> The ID of message displayed below the input field. Required for accessibile aria-definedby
> The ID of message displayed below the input field. Required for accessible aria-definedby
> attribute. Required if `error` and `hintText` are defined.

---
Expand All @@ -115,7 +120,8 @@ Default: `undefined`
#### `inputId: string`

> The ID of the input child. If an ID is not specified on the input child, this will be used as it's
> ID. Used for label's `htmlFor` attribute. This is required for accessiblity if `label` is defined.
> ID. Used for label's `htmlFor` attribute. This is required for accessibility if `label` is
> defined.

---

Expand All @@ -134,7 +140,7 @@ Default: `LabelPosition.Top`

#### `required: boolean`

> It set, the label of the field will be suffixed by a red astrisk.
> It set, the label of the field will be suffixed by a red asterisk.

Default: `false`

Expand Down Expand Up @@ -230,4 +236,4 @@ Default: `LabelPosition.Top`

#### `htmlFor: string`

> The ID of the input being labelled. This is required for accessiblity.
> The ID of the input being labelled. This is required for accessibility.