-
Notifications
You must be signed in to change notification settings - Fork 388
chore(TextInput): converted examples to typescript #8137
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
packages/react-core/src/components/TextInput/examples/TextInputBasic.tsx
This file contains hidden or 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,7 @@ | ||
| import React from 'react'; | ||
| import { TextInput } from '@patternfly/react-core'; | ||
|
|
||
| export const TextInputBasic: React.FunctionComponent = () => { | ||
| const [value, setValue] = React.useState(''); | ||
| return <TextInput value={value} type="text" onChange={value => setValue(value)} aria-label="text input example" />; | ||
| }; |
6 changes: 6 additions & 0 deletions
6
packages/react-core/src/components/TextInput/examples/TextInputDisabled.tsx
This file contains hidden or 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,6 @@ | ||
| import React from 'react'; | ||
| import { TextInput } from '@patternfly/react-core'; | ||
|
|
||
| export const TextInputBasic: React.FunctionComponent = () => ( | ||
| <TextInput value="disabled text input example" type="text" aria-label="disabled text input example" isDisabled /> | ||
| ); |
39 changes: 39 additions & 0 deletions
39
packages/react-core/src/components/TextInput/examples/TextInputIcon.tsx
This file contains hidden or 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,39 @@ | ||
| import React from 'react'; | ||
| import { TextInput } from '@patternfly/react-core'; | ||
|
|
||
| export const TextInputIcon: React.FunctionComponent = () => { | ||
| const [calendar, setCalendar] = React.useState(''); | ||
| const [clock, setClock] = React.useState(''); | ||
| const [custom, setCustom] = React.useState(''); | ||
|
|
||
| return ( | ||
| <> | ||
| <TextInput | ||
| value={calendar} | ||
| type="text" | ||
| iconVariant="calendar" | ||
| onChange={value => setCalendar(value)} | ||
| aria-label="text input example" | ||
| /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput | ||
| value={clock} | ||
| type="text" | ||
| iconVariant="clock" | ||
| onChange={value => setClock(value)} | ||
| aria-label="text input example" | ||
| /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput | ||
| value={custom} | ||
| type="text" | ||
| customIconDimensions="24px 24px" | ||
| customIconUrl='data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"%3E%3Cpath fill="%23a18fff" d="M158.87.15c-16.16-1.52-31.2 8.42-35.33 24.12l-14.81 56.27c187.62 5.49 314.54 130.61 322.48 317l56.94-15.78c15.72-4.36 25.49-19.68 23.62-35.9C490.89 165.08 340.78 17.32 158.87.15zm-58.47 112L.55 491.64a16.21 16.21 0 0 0 20 19.75l379-105.1c-4.27-174.89-123.08-292.14-299.15-294.1zM128 416a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm48-152a32 32 0 1 1 32-32 32 32 0 0 1-32 32zm104 104a32 32 0 1 1 32-32 32 32 0 0 1-32 32z"/%3E%3C/svg%3E' | ||
| onChange={value => setCustom(value)} | ||
| aria-label="text input example" | ||
| /> | ||
| </> | ||
| ); | ||
| }; |
39 changes: 39 additions & 0 deletions
39
packages/react-core/src/components/TextInput/examples/TextInputIconSprite.tsx
This file contains hidden or 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,39 @@ | ||
| import React from 'react'; | ||
| import { TextInput } from '@patternfly/react-core'; | ||
|
|
||
| export const TextInputIconSprite: React.FunctionComponent = () => { | ||
| const [calendar, setCalendar] = React.useState(''); | ||
| const [clock, setClock] = React.useState(''); | ||
|
|
||
| return ( | ||
| <> | ||
| <TextInput validated={'success'} isIconSprite type="text" aria-label="success icon sprite text input example" /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput validated={'warning'} isIconSprite type="text" aria-label="warning icon sprite text input example" /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput validated={'error'} isIconSprite type="text" aria-label="error icon sprite text input example" /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput | ||
| value={calendar} | ||
| isIconSprite | ||
| type="text" | ||
| iconVariant="calendar" | ||
| onChange={value => setCalendar(value)} | ||
| aria-label="calendar icon sprite text input example" | ||
| /> | ||
| <br /> | ||
| <br /> | ||
| <TextInput | ||
| value={clock} | ||
| isIconSprite | ||
| type="text" | ||
| iconVariant="clock" | ||
| onChange={value => setClock(value)} | ||
| aria-label="clock icon sprite text input example" | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
16 changes: 16 additions & 0 deletions
16
packages/react-core/src/components/TextInput/examples/TextInputInvalid.tsx
This file contains hidden or 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,16 @@ | ||
| import React from 'react'; | ||
| import { TextInput, ValidatedOptions } from '@patternfly/react-core'; | ||
|
|
||
| export const TextInputInvalid: React.FunctionComponent = () => { | ||
| const [value, setValue] = React.useState(''); | ||
| return ( | ||
| <TextInput | ||
| value={value} | ||
| onChange={value => setValue(value)} | ||
| isRequired | ||
| validated={ValidatedOptions.error} | ||
| type="text" | ||
| aria-label="invalid text input example" | ||
| /> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.