-
Notifications
You must be signed in to change notification settings - Fork 883
[Storybook] Add stories for more components (form components) - Part 1 #7781
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
cee-chen
merged 17 commits into
elastic:main
from
mgadewoll:storybook/7614-form-stories
May 30, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aad312d
docs(storybook): add checkbox component stories
mgadewoll 43c7597
test(VRT): add checkbox component reference images
mgadewoll b62831c
docs(storybook): add radio component stories
mgadewoll 5f9acc0
test(VRT): add radio component reference images
mgadewoll eea4287
docs(storybook): update fied_text and field_number stories
mgadewoll 2157221
docs(storybook): update password field stories
mgadewoll 36b45af
test(VRT): add password field reference images
mgadewoll ccf2db1
docs(storybook): update search field stories
mgadewoll 995a9d7
test(VRT): add search field reference images
mgadewoll a1d728d
docs(storybook): add textarea field stories
mgadewoll f0bc660
test(VRT): add textarea reference images
mgadewoll 4a25340
docs(storybook): add switch stories
mgadewoll ac84d13
test(VRT): add switch reference images
mgadewoll 7c6f10b
docs(storybook): revert tags constant changes
mgadewoll c6d7bdd
docs(storybook): slim down TextArea icons tory controls
mgadewoll 91cb317
refactor: inherit EuiSwitch type for prop type from HTMLButton
mgadewoll 28b6232
styles: fix my fat finger typos
mgadewoll 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
Binary file added
BIN
+7.76 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiCheckboxGroup_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.55 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiCheckbox_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+913 Bytes
packages/eui/.loki/reference/chrome_desktop_Forms_EuiFieldPassword_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.1 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiFieldSearch_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.58 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiRadioGroup_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.21 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiRadio_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.42 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiSwitch_Checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.45 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiSwitch_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.82 KB
packages/eui/.loki/reference/chrome_desktop_Forms_EuiTextArea_Icon_Shape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+993 Bytes
packages/eui/.loki/reference/chrome_desktop_Forms_EuiTextArea_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiCheckboxGroup_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.51 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiCheckbox_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.88 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiFieldPassword_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.43 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiFieldSearch_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.5 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiRadioGroup_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.66 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiRadio_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.96 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiSwitch_Checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiSwitch_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.48 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiTextArea_Icon_Shape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.4 KB
packages/eui/.loki/reference/chrome_mobile_Forms_EuiTextArea_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { addons } from '@storybook/manager-api'; | ||
|
|
||
| // filter out stories based on tags that should not | ||
| // be shown in the Storybook sidebar menu | ||
| addons.setConfig({ | ||
| sidebar: { | ||
| filters: { | ||
| patterns: (item) => { | ||
| // Storybook only accepts string literals in the tags | ||
| // handling this centrally via a map doesn't work :( | ||
| return !item.tags?.includes('vrt-only'); | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
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
47 changes: 47 additions & 0 deletions
47
packages/eui/src/components/form/checkbox/checkbox.stories.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,47 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { | ||
| disableStorybookControls, | ||
| enableFunctionToggleControls, | ||
| } from '../../../../.storybook/utils'; | ||
| import { EuiCheckbox, EuiCheckboxProps, TYPES } from './checkbox'; | ||
|
|
||
| const meta: Meta<EuiCheckboxProps> = { | ||
| title: 'Forms/EuiCheckbox', | ||
| component: EuiCheckbox, | ||
| argTypes: { | ||
| label: { control: 'text' }, | ||
| type: { | ||
| control: 'radio', | ||
| options: [undefined, ...TYPES], | ||
| }, | ||
| }, | ||
| args: { | ||
| checked: false, | ||
| compressed: false, | ||
|
mgadewoll marked this conversation as resolved.
|
||
| disabled: false, | ||
| indeterminate: false, | ||
| // set up for easier testing/QA | ||
| id: '', | ||
| }, | ||
| }; | ||
| enableFunctionToggleControls(meta, ['onChange']); | ||
| disableStorybookControls(meta, ['inputRef']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiCheckboxProps>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| id: 'checkbox', | ||
| label: 'Checkbox label', | ||
| }, | ||
| }; | ||
44 changes: 44 additions & 0 deletions
44
packages/eui/src/components/form/checkbox/checkbox_group.stories.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,44 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { enableFunctionToggleControls } from '../../../../.storybook/utils'; | ||
| import { EuiCheckboxGroup, EuiCheckboxGroupProps } from './checkbox_group'; | ||
|
|
||
| const meta: Meta<EuiCheckboxGroupProps> = { | ||
| title: 'Forms/EuiCheckboxGroup', | ||
| component: EuiCheckboxGroup, | ||
| args: { | ||
| disabled: false, | ||
| compressed: false, | ||
| }, | ||
| }; | ||
| enableFunctionToggleControls(meta, ['onChange']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiCheckboxGroupProps>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| options: [ | ||
| { id: 'checkbox-1', label: 'Checkbox 1' }, | ||
| { id: 'checkbox-2', label: 'Checkbox 2' }, | ||
| { id: 'checkbox-3', label: 'Checkbox 3', disabled: true }, | ||
| ], | ||
| idToSelectedMap: { | ||
| 'checkbox-2': true, | ||
| }, | ||
| // set up for easier testing/QA | ||
| legend: { | ||
| children: 'Group label', | ||
| compressed: false, | ||
| display: 'visible', | ||
| }, | ||
| }, | ||
| }; |
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
60 changes: 60 additions & 0 deletions
60
packages/eui/src/components/form/field_password/field_password.stories.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,60 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { | ||
| disableStorybookControls, | ||
| enableFunctionToggleControls, | ||
| } from '../../../../.storybook/utils'; | ||
| import { EuiIcon } from '../../icon'; | ||
| import { EuiFieldPassword, EuiFieldPasswordProps } from './field_password'; | ||
|
|
||
| const meta: Meta<EuiFieldPasswordProps> = { | ||
| title: 'Forms/EuiFieldPassword', | ||
| component: EuiFieldPassword, | ||
| argTypes: { | ||
| append: { | ||
| control: 'radio', | ||
| options: [undefined, 'icon', 'text'], | ||
| mapping: { | ||
| icon: <EuiIcon type="faceHappy" />, | ||
| text: 'Appended', | ||
| undefined: undefined, | ||
| }, | ||
| }, | ||
| prepend: { | ||
| control: 'radio', | ||
| options: [undefined, 'icon', 'text'], | ||
| mapping: { | ||
|
mgadewoll marked this conversation as resolved.
|
||
| icon: <EuiIcon type="faceHappy" />, | ||
| text: 'Prepended', | ||
| undefined: undefined, | ||
| }, | ||
| }, | ||
| }, | ||
| args: { | ||
| type: 'password', | ||
| fullWidth: false, | ||
| isLoading: false, | ||
| compressed: false, | ||
| // set up for easier testing/QA | ||
| isInvalid: false, | ||
| placeholder: '', | ||
| id: '', | ||
| name: '', | ||
| }, | ||
| }; | ||
| enableFunctionToggleControls(meta, ['onChange']); | ||
| disableStorybookControls(meta, ['inputRef']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiFieldPasswordProps>; | ||
|
|
||
| export const Playground: Story = {}; | ||
64 changes: 64 additions & 0 deletions
64
packages/eui/src/components/form/field_search/field_search.stories.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,64 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { | ||
| disableStorybookControls, | ||
| enableFunctionToggleControls, | ||
| } from '../../../../.storybook/utils'; | ||
| import { EuiIcon } from '../../icon'; | ||
| import { EuiFieldSearch, EuiFieldSearchProps } from './field_search'; | ||
|
|
||
| const meta: Meta<EuiFieldSearchProps> = { | ||
| title: 'Forms/EuiFieldSearch', | ||
| component: EuiFieldSearch, | ||
| argTypes: { | ||
| append: { | ||
| control: 'radio', | ||
| options: [undefined, 'icon', 'text'], | ||
| mapping: { | ||
| icon: <EuiIcon type="faceHappy" />, | ||
| text: 'Appended', | ||
| undefined: undefined, | ||
| }, | ||
| }, | ||
| prepend: { | ||
| control: 'radio', | ||
| options: [undefined, 'icon', 'text'], | ||
| mapping: { | ||
| icon: <EuiIcon type="faceHappy" />, | ||
| text: 'Prepended', | ||
| undefined: undefined, | ||
| }, | ||
| }, | ||
| }, | ||
| args: { | ||
| isLoading: false, | ||
| incremental: false, | ||
| compressed: false, | ||
| isClearable: true, | ||
| // set up for easier testing/QA | ||
| fullWidth: false, | ||
| isInvalid: false, | ||
| id: '', | ||
| name: '', | ||
| placeholder: '', | ||
| }, | ||
| }; | ||
| // adding onChange for visibility | ||
| enableFunctionToggleControls(meta, ['onSearch', 'onChange']); | ||
| disableStorybookControls(meta, ['inputRef']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiFieldSearchProps>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: {}, | ||
| }; |
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
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,40 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { enableFunctionToggleControls } from '../../../../.storybook/utils'; | ||
| import { EuiRadio, EuiRadioProps } from './radio'; | ||
|
|
||
| const meta: Meta<EuiRadioProps> = { | ||
| title: 'Forms/EuiRadio', | ||
| component: EuiRadio, | ||
| argTypes: { | ||
| label: { control: 'text' }, | ||
| }, | ||
| args: { | ||
| checked: false, | ||
| compressed: false, | ||
|
mgadewoll marked this conversation as resolved.
|
||
| disabled: false, | ||
| // set up for easier testing/QA | ||
| id: '', | ||
| name: '', | ||
| }, | ||
| }; | ||
| enableFunctionToggleControls(meta, ['onChange']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiRadioProps>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| id: 'radio', | ||
| label: 'Radio label', | ||
| value: 'radio-1', | ||
| }, | ||
| }; | ||
43 changes: 43 additions & 0 deletions
43
packages/eui/src/components/form/radio/radio_group.stories.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,43 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { enableFunctionToggleControls } from '../../../../.storybook/utils'; | ||
| import { EuiRadioGroup, EuiRadioGroupProps } from './radio_group'; | ||
|
|
||
| const meta: Meta<EuiRadioGroupProps> = { | ||
| title: 'Forms/EuiRadioGroup', | ||
| component: EuiRadioGroup, | ||
| args: { | ||
| compressed: false, | ||
| disabled: false, | ||
| }, | ||
| }; | ||
| enableFunctionToggleControls(meta, ['onChange']); | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<EuiRadioGroupProps>; | ||
|
|
||
| export const Playground: Story = { | ||
| args: { | ||
| options: [ | ||
| { id: 'radio-1', label: 'Radio 1', value: 'radio-1' }, | ||
| { id: 'radio-2', label: 'Radio 2', value: 'radio-2' }, | ||
| { id: 'radio-3', label: 'Radio 3', value: 'radio-3', disabled: true }, | ||
| ], | ||
| idSelected: 'radio-2', | ||
| name: 'radio-group', | ||
| // set up for easier testing/QA | ||
| legend: { | ||
| children: 'Group label', | ||
| compressed: false, | ||
| display: 'visible', | ||
| }, | ||
| }, | ||
| }; |
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.