Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fixed `EuiFlyout` scrolling in Safari ([#2033](https://github.com/elastic/eui/pull/2033))
- Fixed `EuiCallOut` header icon alignment ([#2006](https://github.com/elastic/eui/pull/2006))
- Fixed `EuiInMemoryTable` sort value persistence through lifecycle updates ([#2035](https://github.com/elastic/eui/pull/2035))
- Fixed `EuiColorPicker` positioning and keyboard navigation in certain portal contexts ([#2038](https://github.com/elastic/eui/pull/2038))

**Breaking changes**

Expand Down
25 changes: 25 additions & 0 deletions src-docs/src/views/color_picker/color_picker_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const modesPickerSnippet = `// Gradient map only
/>
`;

import Containers from './containers';
const containersSource = require('!!raw-loader!./containers');
const containersHtml = renderToHtml(Containers);

import { KitchenSink } from './kitchen_sink';
const kitchenSinkSource = require('!!raw-loader!./kitchen_sink');
const kitchenSinkHtml = renderToHtml(KitchenSink);
Expand Down Expand Up @@ -211,6 +215,27 @@ export const ColorPickerExample = {
snippet: [modesSwatchSnippet, modesPickerSnippet],
demo: <Modes />,
},
{
title: 'Containers',
source: [
{
type: GuideSectionTypes.JS,
code: containersSource,
},
{
type: GuideSectionTypes.HTML,
code: containersHtml,
},
],
text: (
<p>
Demonstrating that <EuiCode>EuiColorPicker</EuiCode> can exist in
portal containers and that its popover position works in nested
contexts.
</p>
),
demo: <Containers />,
},
{
title: 'Kitchen sink',
source: [
Expand Down
114 changes: 114 additions & 0 deletions src-docs/src/views/color_picker/containers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import React, { Component, Fragment } from 'react';

import {
EuiColorPicker,
EuiButton,
EuiPopover,
EuiFormRow,
EuiModal,
EuiModalBody,
EuiModalHeader,
EuiModalHeaderTitle,
EuiOverlayMask,
EuiSpacer,
} from '../../../../src/components';

export default class extends Component {
constructor(props) {
super(props);

this.state = {
color: '#FFF',
isModalVisible: false,
isPopoverOpen: false,
};
}

closeModal = () => {
this.setState({ isModalVisible: false });
};

showModal = () => {
this.setState({ isModalVisible: true });
};

togglePopover = () => {
this.setState(prevState => ({
isPopoverOpen: !prevState.isPopoverOpen,
}));
};

closePopover = () => {
this.setState({
isPopoverOpen: false,
});
};

onChange = color => {
this.setState({
color,
});
};

render() {
const { color, isModalVisible, isPopoverOpen } = this.state;

const colorPicker = (
<EuiColorPicker color={color} onChange={this.onChange} />
);

const button = (
<EuiButton
iconType="arrowDown"
iconSide="right"
onClick={this.togglePopover}>
Open popover
</EuiButton>
);

let modal;

if (isModalVisible) {
modal = (
<EuiOverlayMask>
<EuiModal onClose={this.closeModal} style={{ width: '800px' }}>
<EuiModalHeader>
<EuiModalHeaderTitle>Color picker in a modal</EuiModalHeaderTitle>
</EuiModalHeader>

<EuiModalBody>
<EuiFormRow label="Color picker">{colorPicker}</EuiFormRow>
</EuiModalBody>
</EuiModal>
</EuiOverlayMask>
);
}

return (
<Fragment>
<EuiFormRow
label="Color picker"
helpText="This color picker is inside of a form row">
{colorPicker}
</EuiFormRow>

<EuiPopover
id="popover"
ownFocus
button={button}
isOpen={isPopoverOpen}
closePopover={this.closePopover}>
<div style={{ width: '300px' }}>
<EuiFormRow label="Color picker">{colorPicker}</EuiFormRow>
</div>
</EuiPopover>

<EuiSpacer size="m" />

<EuiButton onClick={this.showModal}>Show modal</EuiButton>

{modal}
</Fragment>
);
}
}
Loading