-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs(web-react): Add TextField demo #DS-913
- TextField demo in web-react is now same as demo in web and web-twig
- Loading branch information
1 parent
f126dca
commit e179f05
Showing
15 changed files
with
210 additions
and
148 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
packages/web-react/src/components/TextField/demo/TextField.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
packages/web-react/src/components/TextField/demo/TextFieldDefault.tsx
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,21 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
const TextFieldDefault = () => ( | ||
<> | ||
<TextField id="textfieldDefault" label="Label" name="textfieldDefault" placeholder="Placeholder" /> | ||
|
||
<TextField id="textfieldFilled" label="Label" name="textfieldFilled" placeholder="Placeholder" value="Filled" /> | ||
|
||
<TextField | ||
id="textfieldPassword" | ||
label="Label" | ||
name="textfieldPassword" | ||
placeholder="Placeholder" | ||
value="Filled" | ||
type="password" | ||
/> | ||
</> | ||
); | ||
|
||
export default TextFieldDefault; |
23 changes: 12 additions & 11 deletions
23
packages/web-react/src/components/TextField/demo/TextFieldDisabled.tsx
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const Story = (props: unknown) => ( | ||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '1.5rem 1rem' }}> | ||
<TextField id="textfield-disabled" label="Disabled" name="textfield-disabled" isDisabled /> | ||
const TextFieldDisabled = () => ( | ||
<> | ||
<TextField id="textfieldDisabled" label="Label" name="textfieldDisabled" placeholder="Placeholder" isDisabled /> | ||
|
||
<TextField | ||
id="textfield-disabled-filled" | ||
label="Disabled filled" | ||
name="textfield-disabled-filled" | ||
value="TextField value" | ||
id="textfieldDisabledFilled" | ||
label="Label" | ||
name="textfieldDisabledFilled" | ||
placeholder="Placeholder" | ||
value="Filled" | ||
isDisabled | ||
isRequired | ||
/> | ||
</div> | ||
</> | ||
); | ||
|
||
export default Story; | ||
export default TextFieldDisabled; |
8 changes: 4 additions & 4 deletions
8
packages/web-react/src/components/TextField/demo/TextFieldFluid.tsx
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const Story = (props: unknown) => <TextField id="textfield-fluid" label="Fluid" name="textfield-fluid" isFluid />; | ||
const TextFieldFluid = () => ( | ||
<TextField id="textfieldFluid" isFluid label="Label" name="textfieldFluid" placeholder="Placeholder" value="Filled" /> | ||
); | ||
|
||
export default Story; | ||
export default TextFieldFluid; |
24 changes: 10 additions & 14 deletions
24
packages/web-react/src/components/TextField/demo/TextFieldHelperText.tsx
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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
// Because there is no `dist` directory during the CI run | ||
/* eslint-disable import/no-extraneous-dependencies, import/extensions, import/no-unresolved */ | ||
import React from 'react'; | ||
import { ComponentStory } from '@storybook/react'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore: No declaration file | ||
import { SpiritTextFieldProps } from '../../../types'; | ||
import TextField from '../TextField'; | ||
|
||
const Story: ComponentStory<typeof TextField> = (args: SpiritTextFieldProps) => <TextField {...args} />; | ||
const TextFieldHelperText = () => ( | ||
<TextField | ||
helperText="Helper text" | ||
id="textfieldHelperText" | ||
label="Label" | ||
name="textfieldHelperText" | ||
placeholder="Placeholder" | ||
/> | ||
); | ||
|
||
Story.args = { | ||
id: 'textfield-helper-text-example', | ||
label: 'Label with helper text', | ||
helperText: 'Custom helper text', | ||
}; | ||
|
||
export default Story; | ||
export default TextFieldHelperText; |
14 changes: 14 additions & 0 deletions
14
packages/web-react/src/components/TextField/demo/TextFieldHiddenLabel.tsx
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,14 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
const TextFieldHiddenLabel = () => ( | ||
<TextField | ||
id="textfieldHiddenLabel" | ||
label="Label" | ||
name="textfieldHiddenLabel" | ||
placeholder="Placeholder" | ||
isLabelHidden | ||
/> | ||
); | ||
|
||
export default TextFieldHiddenLabel; |
44 changes: 44 additions & 0 deletions
44
packages/web-react/src/components/TextField/demo/TextFieldInline.tsx
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,44 @@ | ||
import React from 'react'; | ||
import { Button } from '../../Button'; | ||
import TextField from '../TextField'; | ||
|
||
const TextFieldInline = () => ( | ||
<> | ||
<div style={{ display: 'flex', gap: '1rem', alignItems: 'flex-start', maxWidth: '320px' }}> | ||
<TextField | ||
id="textfieldInline" | ||
isLabelHidden | ||
label="Hidden Label" | ||
name="textfieldInline" | ||
placeholder="Placeholder" | ||
value="Filled" | ||
/> | ||
<Button>Button</Button> | ||
</div> | ||
|
||
<div style={{ display: 'flex', gap: '1rem', alignItems: 'flex-start', maxWidth: '320px' }}> | ||
<TextField | ||
id="textfieldInlineFirst" | ||
isLabelHidden | ||
label="Hidden Label" | ||
name="textfieldInlineFirst" | ||
placeholder="Placeholder" | ||
value="Filled" | ||
/> | ||
<TextField | ||
id="textfieldInlinePassword" | ||
isLabelHidden | ||
label="Hidden Label" | ||
hasPasswordToggle | ||
name="textfieldInlinePassword" | ||
validationState="danger" | ||
validationText="Too short" | ||
placeholder="Placeholder" | ||
value="1234" | ||
/> | ||
<Button>Button</Button> | ||
</div> | ||
</> | ||
); | ||
|
||
export default TextFieldInline; |
15 changes: 10 additions & 5 deletions
15
packages/web-react/src/components/TextField/demo/TextFieldInputWidth.tsx
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const Story = (props: unknown) => ( | ||
<TextField id="textfield-with-input-width" label="Width 10 em" name="textfield-with-size" inputWidth={10} /> | ||
const TextFieldInputWidth = () => ( | ||
<TextField | ||
id="textfieldSize" | ||
isFluid | ||
label="4000 (in Roman numerals)" | ||
name="textfieldSize" | ||
placeholder="Placeholder" | ||
inputWidth={4} | ||
/> | ||
); | ||
|
||
export default Story; | ||
export default TextFieldInputWidth; |
10 changes: 0 additions & 10 deletions
10
packages/web-react/src/components/TextField/demo/TextFieldLabelHidden.tsx
This file was deleted.
Oops, something went wrong.
30 changes: 20 additions & 10 deletions
30
packages/web-react/src/components/TextField/demo/TextFieldPasswordToggle.tsx
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 |
---|---|---|
@@ -1,15 +1,25 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const Story = (props: unknown) => ( | ||
<TextField | ||
id="textfield-password-toggle" | ||
label="Password toggle" | ||
name="textfield-password-toggle" | ||
hasPasswordToggle | ||
/> | ||
const TextFieldPasswordToggle = () => ( | ||
<> | ||
<TextField | ||
id="textfieldPasswordToggle" | ||
label="Password Toggle" | ||
hasPasswordToggle | ||
name="textfieldPasswordToggle" | ||
placeholder="Password must be at least 6 characters long" | ||
/> | ||
|
||
<TextField | ||
id="textfieldPasswordToggleDisabled" | ||
label="Password Toggle" | ||
hasPasswordToggle | ||
isDisabled | ||
name="textfieldPasswordToggleDisabled" | ||
placeholder="Password must be at least 6 characters long" | ||
/> | ||
</> | ||
); | ||
|
||
export default Story; | ||
export default TextFieldPasswordToggle; |
8 changes: 3 additions & 5 deletions
8
packages/web-react/src/components/TextField/demo/TextFieldRequired.tsx
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
// @see: https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244 | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const Story = (props: unknown) => ( | ||
<TextField id="textfield-required" label="Required" name="textfield-required" isRequired /> | ||
const TextFieldRequired = () => ( | ||
<TextField id="textfieldRequired" label="Label" name="textfieldRequired" placeholder="Placeholder" isRequired /> | ||
); | ||
|
||
export default Story; | ||
export default TextFieldRequired; |
18 changes: 0 additions & 18 deletions
18
packages/web-react/src/components/TextField/demo/TextFieldType.tsx
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
packages/web-react/src/components/TextField/demo/TextFieldValidation.tsx
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,49 @@ | ||
import React from 'react'; | ||
import TextField from '../TextField'; | ||
|
||
const TextFieldValidation = () => ( | ||
<> | ||
<TextField | ||
id="textfieldSuccess" | ||
label="Label" | ||
name="textfieldSuccess" | ||
placeholder="Placeholder" | ||
validationState="success" | ||
value="Filled" | ||
/> | ||
|
||
<TextField | ||
id="textfieldWarning" | ||
label="Label" | ||
validationText="Validation text" | ||
name="textfieldWarning" | ||
placeholder="Placeholder" | ||
validationState="warning" | ||
value="Filled" | ||
/> | ||
|
||
<TextField | ||
id="textfieldDanger" | ||
label="Label" | ||
validationText={['Validation text', 'Second validation text']} | ||
name="textfieldDanger" | ||
placeholder="Placeholder" | ||
validationState="danger" | ||
value="Filled" | ||
/> | ||
|
||
<TextField | ||
id="textfieldDangerHelper" | ||
isRequired | ||
label="Label" | ||
helperText="This is helper text" | ||
validationText="Danger validation text" | ||
validationState="danger" | ||
name="textfieldDangerHelper" | ||
placeholder="Placeholder" | ||
value="Filled" | ||
/> | ||
</> | ||
); | ||
|
||
export default TextFieldValidation; |
32 changes: 0 additions & 32 deletions
32
packages/web-react/src/components/TextField/demo/TextFieldValidationState.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.