-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storybook] Add stories for more components (letters R-S) - Part 2 (#…
- Loading branch information
Showing
19 changed files
with
474 additions
and
7 deletions.
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 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 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 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 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 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.