-
Notifications
You must be signed in to change notification settings - Fork 854
[Storybook] Add stories for more components (letters R-S) - Part 2 #7728
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
mgadewoll
merged 11 commits into
elastic:main
from
mgadewoll:storybook/7482-stories-r-s-part-2
May 10, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4245468
refactor(EuiSelectableList): ensure item props rerender list items
mgadewoll 608504e
docs(storybook): add EuiSelectableList story
mgadewoll 7c3601e
docs(storybook): add EuiSelectableListItem story
mgadewoll bdc7863
docs(storybook): add EuiSelectableSearch story
mgadewoll d0d405c
docs(storybook): add EuiSelectableMessage story
mgadewoll 2cfc9d4
docs(storybook): add EuiSelectableTemplateSidewide story
mgadewoll ab95873
test(VRT): add snapshot references for selectable components
mgadewoll 8f362e7
docs(storybook): update types & add control category name
mgadewoll b98f015
refactor(EuiSelectableList): add listRowRerender count tracker to ens…
mgadewoll a742651
[EuiSelectableTemplateSitewide] Misc story tweaks
mgadewoll 75063bf
[EuiSelectableSitewide] Fix prod bug with popoverButtons anchor
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
+2.43 KB
...ktop_Forms_EuiSelectable_EuiSelectableList_EuiSelectableListItem_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
+19.4 KB
..._desktop_Forms_EuiSelectable_EuiSelectableList_EuiSelectableList_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.92 KB
...eference/chrome_desktop_Forms_EuiSelectable_EuiSelectableMessage_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.31 KB
...reference/chrome_desktop_Forms_EuiSelectable_EuiSelectableSearch_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
+3.79 KB
...reference/chrome_desktop_Templates_EuiSelectableTemplateSitewide_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.71 KB
...bile_Forms_EuiSelectable_EuiSelectableList_EuiSelectableListItem_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
+37.8 KB
...e_mobile_Forms_EuiSelectable_EuiSelectableList_EuiSelectableList_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.84 KB
...reference/chrome_mobile_Forms_EuiSelectable_EuiSelectableMessage_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
.../reference/chrome_mobile_Forms_EuiSelectable_EuiSelectableSearch_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
+8.17 KB
.../reference/chrome_mobile_Templates_EuiSelectableTemplateSitewide_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions
109
src/components/selectable/selectable_list/selectable_list.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,109 @@ | ||
/* | ||
* 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 { action } from '@storybook/addon-actions'; | ||
|
||
import { | ||
enableFunctionToggleControls, | ||
moveStorybookControlsToCategory, | ||
} from '../../../../.storybook/utils'; | ||
import { EuiSelectableOption } from '../selectable_option'; | ||
import { EuiSelectableList, EuiSelectableListProps } from './selectable_list'; | ||
|
||
const options: EuiSelectableOption[] = [ | ||
{ | ||
label: 'Titan', | ||
'data-test-subj': 'titanOption', | ||
}, | ||
{ | ||
label: 'Enceladus is disabled', | ||
disabled: true, | ||
}, | ||
{ | ||
label: 'Mimas', | ||
checked: 'on', | ||
}, | ||
{ | ||
label: 'Dione', | ||
}, | ||
{ | ||
label: 'Iapetus', | ||
checked: 'on', | ||
}, | ||
{ | ||
label: 'Phoebe', | ||
}, | ||
{ | ||
label: 'Rhea', | ||
}, | ||
{ | ||
label: | ||
"Pandora is one of Saturn's moons, named for a Titaness of Greek mythology", | ||
}, | ||
{ | ||
label: 'Tethys', | ||
}, | ||
{ | ||
label: 'Hyperion', | ||
}, | ||
]; | ||
|
||
const meta: Meta<EuiSelectableListProps<{}>> = { | ||
title: 'Forms/EuiSelectable/EuiSelectableList/EuiSelectableList', | ||
component: EuiSelectableList, | ||
argTypes: { | ||
height: { control: 'number' }, | ||
isPreFiltered: { control: 'boolean' }, | ||
singleSelection: { control: 'boolean' }, | ||
}, | ||
args: { | ||
textWrap: 'truncate', | ||
paddingSize: 's', | ||
onFocusBadge: true, | ||
showIcons: true, | ||
// set up for easier testing/QA | ||
listId: '', | ||
allowExclusions: false, | ||
bordered: false, | ||
isPreFiltered: false, | ||
isVirtualized: false, | ||
searchable: false, | ||
singleSelection: true, | ||
}, | ||
}; | ||
enableFunctionToggleControls(meta, ['onOptionClick', 'setActiveOptionIndex']); | ||
moveStorybookControlsToCategory( | ||
meta, | ||
[ | ||
'allowExclusions', | ||
'onFocusBadge', | ||
'paddingSize', | ||
'searchable', | ||
'showIcons', | ||
'textWrap', | ||
], | ||
'EuiSelectableListItem props' | ||
); | ||
|
||
export default meta; | ||
type Story = StoryObj<EuiSelectableListProps<{}>>; | ||
|
||
export const Playground: Story = { | ||
args: { | ||
options, | ||
activeOptionIndex: 0, | ||
makeOptionId: (index) => `selectable_list_item-${index}`, | ||
// ensuring that onOptionClick triggers an action as it's | ||
// only called through setActiveOptionIndex callback | ||
setActiveOptionIndex: (index, callback) => { | ||
callback?.(); | ||
action('setActiveOptionIndex')(index); | ||
}, | ||
}, | ||
}; |
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
65 changes: 65 additions & 0 deletions
65
src/components/selectable/selectable_list/selectable_list_item.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,65 @@ | ||
/* | ||
* 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 { OPTION_CHECKED_STATES } from '../selectable_option'; | ||
import { | ||
EuiSelectableListItem, | ||
EuiSelectableListItemProps, | ||
} from './selectable_list_item'; | ||
|
||
const meta: Meta<EuiSelectableListItemProps> = { | ||
title: 'Forms/EuiSelectable/EuiSelectableList/EuiSelectableListItem', | ||
component: EuiSelectableListItem, | ||
argTypes: { | ||
checked: { | ||
control: 'radio', | ||
options: [undefined, ...OPTION_CHECKED_STATES], | ||
}, | ||
append: { | ||
control: 'boolean', | ||
description: 'Use the control to toggle showing an appended example', | ||
mapping: { | ||
true: <span>Append</span>, | ||
false: undefined, | ||
}, | ||
}, | ||
prepend: { | ||
control: 'boolean', | ||
description: 'Use the control to toggle showing an prepended example', | ||
mapping: { | ||
true: <span>Prepend</span>, | ||
false: undefined, | ||
}, | ||
}, | ||
}, | ||
args: { | ||
showIcons: true, | ||
paddingSize: 's', | ||
onFocusBadge: true, | ||
textWrap: 'truncate', | ||
// set up for easier testing/QA | ||
allowExclusions: false, | ||
searchable: false, | ||
disabled: false, | ||
isFocused: false, | ||
append: false, | ||
prepend: false, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<EuiSelectableListItemProps>; | ||
|
||
export const Playground: Story = { | ||
args: { | ||
children: 'Selectable list item', | ||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/components/selectable/selectable_message/selectable_message.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,31 @@ | ||
/* | ||
* 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 { | ||
EuiSelectableMessage, | ||
EuiSelectableMessageProps, | ||
} from './selectable_message'; | ||
|
||
const meta: Meta<EuiSelectableMessageProps> = { | ||
title: 'Forms/EuiSelectable/EuiSelectableMessage', | ||
component: EuiSelectableMessage, | ||
args: { | ||
bordered: false, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<EuiSelectableMessageProps>; | ||
|
||
export const Playground: Story = { | ||
args: { | ||
children: 'Custom selectable message', | ||
}, | ||
}; |
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
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.