Skip to content
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

Added display prop to EuiPopover #2112

Merged
merged 9 commits into from
Jul 12, 2019
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 @@ -5,6 +5,7 @@
- Added TypeScript definition for `EuiFormControlLayout` ([#2086](https://github.com/elastic/eui/pull/2086))
- Changed SASS mixin `euiOverflowShadow()` to use `mask-image` instead of `box-shadow` ([#2088](https://github.com/elastic/eui/pull/2088))
- Added SASS mixin and CSS utility `euiYScrollWithShadows` ([#2088](https://github.com/elastic/eui/pull/2088))
- Added `display` prop to `EuiPopover` ([#2112](https://github.com/elastic/eui/pull/2112))

**Bug fixes**

Expand Down
45 changes: 45 additions & 0 deletions src-docs/src/views/popover/popover_block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { Component } from 'react';

import { EuiButton, EuiPopover } from '../../../../src/components';

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

this.state = {
isPopoverOpen: false,
};
}

onButtonClick = () => {
this.setState({
isPopoverOpen: !this.state.isPopoverOpen,
});
};

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

setPanelRef = node => (this.panel = node);

render() {
const button = (
<EuiButton onClick={this.onButtonClick} fullWidth>
This button is expanded
</EuiButton>
);

return (
<EuiPopover
button={button}
isOpen={this.state.isPopoverOpen}
closePopover={this.closePopover}
display="block">
<div>This is a popover</div>
</EuiPopover>
);
}
}
37 changes: 37 additions & 0 deletions src-docs/src/views/popover/popover_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ import PopoverFixed from './popover_fixed';
const popoverFixedSource = require('!!raw-loader!./popover_fixed');
const popoverFixedHtml = renderToHtml(PopoverFixed);

import PopoverBlock from './popover_block';
const popoverBlockSource = require('!!raw-loader!./popover_block');
const popoverBlockHtml = renderToHtml(PopoverBlock);

const popOverSnippet = `<EuiPopover
button={button}
isOpen={this.state.isPopoverOpen}
Expand Down Expand Up @@ -114,6 +118,14 @@ const popoverFixedSnippet = `<EuiPopover
<!-- Popover on a fixed element -->
</EuiPopover>`;

const popoverBlockSnippet = `<EuiPopover
button={button}
isOpen={this.state.isPopoverOpen}
closePopover={this.closePopover}
display="block">
<!-- Popover anchor is display block -->
</EuiPopover>`;

export const PopoverExample = {
title: 'Popover',
sections: [
Expand Down Expand Up @@ -349,5 +361,30 @@ export const PopoverExample = {
snippet: popoverFixedSnippet,
demo: <PopoverFixed />,
},
{
title: 'Popover with block level display',
source: [
{
type: GuideSectionTypes.JS,
code: popoverBlockSource,
},
{
type: GuideSectionTypes.HTML,
code: popoverBlockHtml,
},
],
text: (
<div>
<p>
Popover anchors default to <EuiCode>display: inline-block</EuiCode>{' '}
so they do not force block display on inline triggers. If you do
need to change this to block display, just add{' '}
<EuiCode>display=&quot;block&quot;</EuiCode>
</p>
</div>
),
snippet: popoverBlockSnippet,
demo: <PopoverBlock />,
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="customizablePagination"
isOpen={false}
Expand Down
32 changes: 16 additions & 16 deletions src/components/color_picker/__snapshots__/color_picker.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`renders EuiColorPicker 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -76,10 +76,10 @@ exports[`renders EuiColorPicker 1`] = `

exports[`renders EuiColorPicker with a color swatch when color is defined 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -150,10 +150,10 @@ exports[`renders EuiColorPicker with a color swatch when color is defined 1`] =

exports[`renders EuiColorPicker with an empty swatch when color is "" 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -223,10 +223,10 @@ exports[`renders EuiColorPicker with an empty swatch when color is "" 1`] = `

exports[`renders EuiColorPicker with an empty swatch when color is null 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -296,10 +296,10 @@ exports[`renders EuiColorPicker with an empty swatch when color is null 1`] = `

exports[`renders compressed EuiColorPicker 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout euiFormControlLayout--compressed"
Expand Down Expand Up @@ -370,10 +370,10 @@ exports[`renders compressed EuiColorPicker 1`] = `

exports[`renders disabled EuiColorPicker 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -445,10 +445,10 @@ exports[`renders disabled EuiColorPicker 1`] = `

exports[`renders fullWidth EuiColorPicker 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout euiFormControlLayout--fullWidth"
Expand Down Expand Up @@ -519,10 +519,10 @@ exports[`renders fullWidth EuiColorPicker 1`] = `

exports[`renders readOnly EuiColorPicker 1`] = `
<div
class="euiPopover euiPopover--anchorDownLeft euiColorPicker__popoverContainer"
class="euiPopover euiPopover--anchorDownLeft euiPopover--displayBlock"
>
<div
class="euiPopover__anchor euiColorPicker__popoverAnchor"
class="euiPopover__anchor"
>
<div
class="euiFormControlLayout euiFormControlLayout--readOnly"
Expand Down
12 changes: 0 additions & 12 deletions src/components/color_picker/_color_picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
padding-bottom: 0 !important;
}

.euiColorPicker__popoverContainer:not(.euiColorPicker__popoverContainer--customButton) {
// Override of EuiPopover display
// sass-lint:disable no-important
display: block !important;
}

.euiColorPicker__popoverAnchor:not(.euiColorPicker__popoverAnchor--customButton) {
// Override of EuiPopover display
// sass-lint:disable no-important
display: block !important;
}

.euiColorPicker__popoverPanel[class*='bottom']:not(.euiColorPicker__popoverPanel--customButton) {
border-top-color: transparentize($euiBorderColor, .2);
border-top-right-radius: 0;
Expand Down
9 changes: 1 addition & 8 deletions src/components/color_picker/color_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export const EuiColorPicker = ({
'euiColorPicker__popoverPanel--pickerOnly': mode === 'picker',
'euiColorPicker__popoverPanel--customButton': button,
});
const popoverClasses = classNames('euiColorPicker__popoverContainer', {
'euiColorPicker__popoverContainer--customButton': button,
});
const anchorClasses = classNames('euiColorPicker__popoverAnchor', {
'euiColorPicker__popoverAnchor--customButton': button,
});
const swatchClass = 'euiColorPicker__swatchSelect';
const testSubjAnchor = 'colorPickerAnchor';
const testSubjPopover = 'colorPickerPopover';
Expand Down Expand Up @@ -246,9 +240,8 @@ export const EuiColorPicker = ({
isOpen={isColorSelectorShown}
closePopover={handleFinalSelection}
zIndex={popoverZIndex}
className={popoverClasses}
anchorClassName={anchorClasses}
panelClassName={panelClasses}
display={button ? 'inlineBlock' : 'block'}
attachToAnchor={button ? false : true}
anchorPosition="downLeft"
panelPaddingSize="s">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.euiDatePopoverButton__popover .euiDatePopoverButton__popoverAnchor {
display: block;
}

.euiDatePopoverButton {
@include euiSuperDatePickerText;
background-size: 100%; // For the bottom "border" via background-image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ export function EuiDatePopoverButton(props) {

return (
<EuiPopover
className="euiDatePopoverButton__popover"
button={button}
isOpen={isOpen}
closePopover={onPopoverClose}
anchorPosition={position === 'start' ? 'downLeft' : 'downRight'}
anchorClassName="euiDatePopoverButton__popoverAnchor"
display="block"
panelPaddingSize="none"
ownFocus
{...rest}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports[`EuiQuickSelectPopover is rendered 1`] = `
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="QuickSelectPopover"
isOpen={false}
Expand Down Expand Up @@ -111,6 +112,7 @@ exports[`EuiQuickSelectPopover isAutoRefreshOnly 1`] = `
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="QuickSelectPopover"
isOpen={false}
Expand Down
Loading