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 EuiPopoverFooter (TS) #1666

Merged
merged 5 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -6,6 +6,7 @@
- Added missing `anchorClassName` prop to `EuiToolTip` definition ([#1657](https://github.com/elastic/eui/pull/1657))
- Added `fullWidth` prop to `EuiButton` ([#1665](https://github.com/elastic/eui/pull/1665))
- Added `.eui-fullWidth` utility class ([#1665](https://github.com/elastic/eui/pull/1665))
- Added `EuiPopoverFooter` and converted `EuiPopoverTitle` to TS ([#1666](https://github.com/elastic/eui/pull/1666))

## [`9.0.1`](https://github.com/elastic/eui/tree/v9.0.1)

Expand Down
19 changes: 15 additions & 4 deletions src-docs/src/views/popover/popover_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EuiCode,
EuiPopover,
EuiPopoverTitle,
EuiPopoverFooter,
} from '../../../../src/components';

import Popover from './popover';
Expand Down Expand Up @@ -113,7 +114,7 @@ export const PopoverExample = {
),
demo: <PopoverAnchorPosition />,
}, {
title: 'Popover with title',
title: 'Popover with title and/or footer',
source: [{
type: GuideSectionTypes.JS,
code: popoverWithTitleSource,
Expand All @@ -125,14 +126,24 @@ export const PopoverExample = {
<div>
<p>
Popovers often have need for titling. This can be applied through
a prop or used separately as its own component
<EuiCode>EuiPopoverTitle</EuiCode> nested somwhere in the child
a prop or used separately as its own component{' '}
<EuiCode>EuiPopoverTitle</EuiCode> nested somewhere in the child
prop.
</p>
<p>
You can also add a similiarly styled{' '}
<EuiCode>EuiPopoverFooter</EuiCode> for smaller captions or
call to action buttons.
</p>
</div>
),
props: { EuiPopoverTitle },
props: { EuiPopoverTitle, EuiPopoverFooter },
demo: <PopoverWithTitle />,
snippet: `<EuiPopover>
<EuiPopoverTitle></EuiPopoverTitle>
<div></div>
<EuiPopoverFooter></EuiPopoverFooter>
</EuiPopover>`,
}, {
title: 'Panel class name and padding size',
source: [{
Expand Down
39 changes: 24 additions & 15 deletions src-docs/src/views/popover/popover_with_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import React, {
import {
EuiPopover,
EuiPopoverTitle,
EuiPopoverFooter,
EuiButton,
EuiFlexGroup,
EuiFlexItem,
EuiText
EuiText,
EuiTextColor,
} from '../../../../src/components';

export default class extends Component {
Expand Down Expand Up @@ -61,23 +63,23 @@ export default class extends Component {
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiPopover
id="downCenterWithTitle"
id="withTitle"
ownFocus
button={(
<EuiButton iconType="arrowDown" iconSide="right" onClick={this.onButtonClick1.bind(this)}>
downCenter with title
With title
</EuiButton>
)}
isOpen={this.state.isPopoverOpen1}
closePopover={this.closePopover1.bind(this)}
anchorPosition="downCenter"
withTitle
>
<EuiPopoverTitle>Hello, I&rsquo;m a popover title</EuiPopoverTitle>
<div style={{ width: '300px' }}>
<EuiText>
<p>
Popover content with default padding
Selfies migas stumptown hot chicken quinoa wolf green juice,
mumblecore tattooed trust fund hammock truffaut taxidermy kogi.
</p>
</EuiText>
</div>
Expand All @@ -86,51 +88,58 @@ export default class extends Component {

<EuiFlexItem grow={false}>
<EuiPopover
id="upCenterWithTitle"
id="withFooter"
ownFocus
button={(
<EuiButton iconType="arrowDown" iconSide="right" onClick={this.onButtonClick2.bind(this)}>
upCenter with title
With footer
</EuiButton>
)}
isOpen={this.state.isPopoverOpen2}
closePopover={this.closePopover2.bind(this)}
anchorPosition="upCenter"
withTitle
>
<EuiPopoverTitle>Hello, I&rsquo;m a popover title</EuiPopoverTitle>
<div style={{ width: '300px' }}>
<EuiText>
<p>
Popover content with large padding
Selfies migas stumptown hot chicken quinoa wolf green juice,
mumblecore tattooed trust fund hammock truffaut taxidermy kogi.
</p>
</EuiText>
</div>
<EuiPopoverFooter>
<EuiTextColor color="subdued">
Hello, I&rsquo;m a small popover footer caption
</EuiTextColor>
</EuiPopoverFooter>
</EuiPopover>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiPopover
id="rightUpWithTitle"
id="withTitleAndFooter"
ownFocus
button={(
<EuiButton iconType="arrowDown" iconSide="right" onClick={this.onButtonClick3.bind(this)}>
rightUp with title
With title and footer button
</EuiButton>
)}
isOpen={this.state.isPopoverOpen3}
closePopover={this.closePopover3.bind(this)}
anchorPosition="rightUp"
withTitle
anchorPosition="upCenter"
>
<EuiPopoverTitle>Hello, I&rsquo;m a popover title</EuiPopoverTitle>
<div style={{ width: '300px' }}>
<EuiText>
<p>
Popover content with no padding
Selfies migas stumptown hot chicken quinoa wolf green juice,
mumblecore tattooed trust fund hammock truffaut taxidermy kogi.
</p>
</EuiText>
</div>
<EuiPopoverFooter>
<EuiButton fullWidth size="s">Manage this thing</EuiButton>
</EuiPopoverFooter>
</EuiPopover>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export {
export {
EuiPopover,
EuiPopoverTitle,
EuiPopoverFooter,
EuiWrappingPopover,
} from './popover';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiPopoverFooter is rendered 1`] = `
<div
aria-label="aria-label"
class="euiPopoverFooter testClass1 testClass2"
data-test-subj="test subject string"
/>
`;
1 change: 1 addition & 0 deletions src/components/popover/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import 'mixins';
@import 'popover';
@import 'popover_title';
@import 'popover_footer';
11 changes: 11 additions & 0 deletions src/components/popover/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@
// -- makes for better rounded corners
border-top-left-radius: $euiBorderRadius - 1px;
border-top-right-radius: $euiBorderRadius - 1px;

}
@mixin euiPopoverFooter {
@include euiFontSizeS;
padding: $euiSizeM;
border-top: $euiBorderThin;

// Subtract 1px from the border radius since it's inside another container that also has the border radius
// -- makes for better rounded corners
border-bottom-left-radius: $euiBorderRadius - 1px;
border-bottom-right-radius: $euiBorderRadius - 1px;
}
16 changes: 16 additions & 0 deletions src/components/popover/_popover_footer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import '../panel/variables'; // grab the $euiPanelPaddingModifiers map

.euiPopoverFooter {
@include euiPopoverFooter;

// If the popover's containing panel has padding applied,
// ensure the footer expands to cover that padding and
// take on the same amount of padding horizontally

@each $modifier, $amount in $euiPanelPaddingModifiers {
.euiPopover__panel.euiPanel--#{$modifier} & {
padding: $euiSizeM $amount;
margin: $amount ($amount * -1) ($amount * -1);
}
}
}
4 changes: 0 additions & 4 deletions src/components/popover/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,4 @@ declare module '@elastic/eui' {
export const EuiPopover: FunctionComponent<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiPopoverProps
>;

cchaos marked this conversation as resolved.
Show resolved Hide resolved
export const EuiPopoverTitle: FunctionComponent<
CommonProps & HTMLAttributes<HTMLDivElement>
>;
}
1 change: 1 addition & 0 deletions src/components/popover/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { EuiPopover } from './popover';
export { EuiPopoverTitle } from './popover_title';
export { EuiPopoverFooter } from './popover_footer';
export { EuiWrappingPopover } from './wrapping_popover';
13 changes: 13 additions & 0 deletions src/components/popover/popover_footer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiPopoverFooter } from './popover_footer';

describe('EuiPopoverFooter', () => {
test('is rendered', () => {
const component = render(<EuiPopoverFooter {...requiredProps} />);

expect(component).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions src/components/popover/popover_footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { HTMLAttributes, ReactNode, FunctionComponent } from 'react';
import classNames from 'classnames';
import { CommonProps } from '../common';

export interface EuiPopoverFooterProps
extends CommonProps,
HTMLAttributes<HTMLDivElement> {
children?: ReactNode;
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}

export const EuiPopoverFooter: FunctionComponent<EuiPopoverFooterProps> = ({
children,
className,
...rest
}) => {
const classes = classNames('euiPopoverFooter', className);

return (
<div className={classes} {...rest}>
{children}
</div>
);
};
21 changes: 0 additions & 21 deletions src/components/popover/popover_title.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { EuiPopoverTitle } from './popover_title';

describe('EuiPopoverTitle', () => {
test('is rendered', () => {
const component = render(
<EuiPopoverTitle {...requiredProps} />
);
const component = render(<EuiPopoverTitle {...requiredProps} />);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});
});
23 changes: 23 additions & 0 deletions src/components/popover/popover_title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { HTMLAttributes, ReactNode, FunctionComponent } from 'react';
import classNames from 'classnames';
import { CommonProps } from '../common';

export interface EuiPopoverTitleProps
extends CommonProps,
HTMLAttributes<HTMLDivElement> {
children?: ReactNode;
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}

export const EuiPopoverTitle: FunctionComponent<EuiPopoverTitleProps> = ({
children,
className,
...rest
}) => {
const classes = classNames('euiPopoverTitle', className);

return (
<div className={classes} {...rest}>
{children}
</div>
);
};