|
6 | 6 | * Side Public License, v 1. |
7 | 7 | */ |
8 | 8 |
|
9 | | -import React from 'react'; |
| 9 | +import React, { useState } from 'react'; |
10 | 10 | import type { Meta, StoryObj } from '@storybook/react'; |
11 | | -import { SPREAD_STORY_ARGS_MARKER } from '../../../.storybook/addons/code-snippet/constants'; |
12 | 11 |
|
13 | | -import { EuiPanel } from '../panel'; |
| 12 | +import { EuiButton, EuiButtonEmpty } from '../button'; |
14 | 13 | import { EuiCode } from '../code'; |
| 14 | +import { EuiPanel } from '../panel'; |
| 15 | +import { EuiPopover } from '../popover'; |
| 16 | +import { SPREAD_STORY_ARGS_MARKER } from '../../../.storybook/addons/code-snippet/constants'; |
15 | 17 |
|
16 | 18 | import { EuiProvider, EuiProviderProps } from './provider'; |
| 19 | +import { EuiToolTip } from '../tool_tip'; |
17 | 20 |
|
18 | 21 | const meta: Meta<EuiProviderProps<{}>> = { |
19 | 22 | title: 'Theming/EuiProvider', |
@@ -121,3 +124,77 @@ export const FontDefaultUnits: Story = { |
121 | 124 | </> |
122 | 125 | ), |
123 | 126 | }; |
| 127 | + |
| 128 | +export const ComponentDefaultsPopover: Story = { |
| 129 | + parameters: { |
| 130 | + controls: { |
| 131 | + include: ['componentDefaults'], |
| 132 | + }, |
| 133 | + }, |
| 134 | + args: { |
| 135 | + componentDefaults: { |
| 136 | + EuiPopover: { |
| 137 | + repositionOnScroll: true, |
| 138 | + }, |
| 139 | + }, |
| 140 | + }, |
| 141 | + render: function Render() { |
| 142 | + const [isPopoverOpen, setIsPopoverOpen] = useState(false); |
| 143 | + |
| 144 | + const openPopover = () => setIsPopoverOpen(true); |
| 145 | + |
| 146 | + const closePopover = () => setIsPopoverOpen(false); |
| 147 | + |
| 148 | + const button = ( |
| 149 | + <EuiButtonEmpty iconType="help" iconSide="right" onClick={openPopover}> |
| 150 | + Show fixed popover |
| 151 | + </EuiButtonEmpty> |
| 152 | + ); |
| 153 | + |
| 154 | + return ( |
| 155 | + <div style={{ position: 'relative', overflowY: 'auto', height: '100%' }}> |
| 156 | + <div style={{ height: 1200 }}> |
| 157 | + <EuiPopover |
| 158 | + button={button} |
| 159 | + isOpen={isPopoverOpen} |
| 160 | + closePopover={closePopover} |
| 161 | + style={{ position: 'fixed', bottom: 32, right: 32, zIndex: 10 }} |
| 162 | + > |
| 163 | + <div>This popover scrolls with the button element!</div> |
| 164 | + </EuiPopover> |
| 165 | + </div> |
| 166 | + </div> |
| 167 | + ); |
| 168 | + }, |
| 169 | +}; |
| 170 | + |
| 171 | +export const ComponentDefaultsTooltip: Story = { |
| 172 | + parameters: { |
| 173 | + controls: { |
| 174 | + include: ['componentDefaults'], |
| 175 | + }, |
| 176 | + }, |
| 177 | + args: { |
| 178 | + componentDefaults: { |
| 179 | + EuiToolTip: { |
| 180 | + repositionOnScroll: true, |
| 181 | + }, |
| 182 | + }, |
| 183 | + }, |
| 184 | + render: function Render() { |
| 185 | + return ( |
| 186 | + <div style={{ position: 'relative', overflowY: 'auto', height: '100%' }}> |
| 187 | + <div style={{ height: 1200 }}> |
| 188 | + <div style={{ position: 'fixed', bottom: 32, right: 32, zIndex: 10 }}> |
| 189 | + <EuiToolTip |
| 190 | + position="top" |
| 191 | + content="This tooltip text scrolls with the button element!" |
| 192 | + > |
| 193 | + <EuiButton fill>Show fixed tooltip</EuiButton> |
| 194 | + </EuiToolTip> |
| 195 | + </div> |
| 196 | + </div> |
| 197 | + </div> |
| 198 | + ); |
| 199 | + }, |
| 200 | +}; |
0 commit comments