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

Update Popovers to have close button #57

Merged
merged 4 commits into from
Jun 28, 2017
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 docs/build/0.f1b59a03.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/build/0.fcebfce1.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/build/bundle.3a0b71f3.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/build/bundle.3ce32862.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Exchange Solutions React Components v3.9.0</title>
<title>Exchange Solutions React Components v3.10.0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
@font-face {
Expand Down Expand Up @@ -35,5 +35,5 @@
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="build/bundle.3a0b71f3.js"></script></body>
<script type="text/javascript" src="build/bundle.3ce32862.js"></script></body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "es-components",
"version": "3.9.0",
"version": "3.10.0",
"description": "React components built for Exchange Solutions products",
"repository": "https://github.com/TWExchangeSolutions/es-components",
"main": "lib/index.js",
Expand Down
29 changes: 25 additions & 4 deletions src/components/containers/popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import styled from 'styled-components';
import { colors, sizes } from '../../theme';
import classNames from 'classnames';
import DismissButton from '../../controls/DismissButton';

const ArrowBase = styled.div`
border-color: transparent;
Expand Down Expand Up @@ -129,7 +130,6 @@ const PopoverContent = styled.div`
`;

const PopoverTitle = styled.div`
background-color: ${colors.accent};
color: ${colors.white};
padding: 8px 14px;
`;
Expand All @@ -138,6 +138,19 @@ const PopoverBodyContent = styled.div`
padding: 9px 14px;
`;

const DismissPopover = styled(DismissButton)`
color: ${props => (props.hasTitle ? colors.white : colors.grayDark)};
padding: ${props => (props.hasTitle ? '4px 14px' : '0px 14px')};
margin-left: auto;
`;

const PopoverHeader = styled.div`
display: flex;
justify-content: space-between;
height: ${props => (props.hasTitle || props.containsFormElement ? 'auto' : '7px')};
background-color: ${props => (props.hasTitle ? colors.accent : 'none')};
`;

// className, positionLeft and positionTop props get passed to by the Overlay component
const Popover = props => {
const {
Expand All @@ -147,7 +160,8 @@ const Popover = props => {
positionTop,
children,
containsFormElement,
className
className,
dismissPopover
} = props;

const popoverClassNames = classNames(className, arrowPlacement);
Expand All @@ -163,7 +177,13 @@ const Popover = props => {
positionTop={positionTop}
tabIndex={containsFormElement ? 0 : null}
>
{popoverTitle}
<PopoverHeader
hasTitle={hasTitle}
containsFormElement={containsFormElement}
>
{popoverTitle}
<DismissPopover hasTitle={hasTitle} onClick={dismissPopover} />
</PopoverHeader>
<PopoverBodyContent>
{children}
</PopoverBodyContent>
Expand All @@ -179,7 +199,8 @@ Popover.propTypes = {
positionTop: PropTypes.number,
children: PropTypes.node,
containsFormElement: PropTypes.bool,
className: PropTypes.string
className: PropTypes.string,
dismissPopover: PropTypes.func
};

Popover.defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions src/components/containers/popover/PopoverTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PopoverTrigger({
title={popoverTitle}
arrowPlacement={arrowPlacement}
containsFormElement={containsFormElement}
dismissPopover={onHideOverlay}
>
<FocusTrap
active={containsFormElement}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports[`popoverLink component renders as expected 1`] = `
<span>
<button
aria-haspopup="dialog"
className="sc-fjdhpX jzETuU sc-bZQynM kMNeGw sc-bwzfXH ebzKCJ"
className="sc-chPdSV gDBNOW sc-bZQynM kMNeGw sc-bwzfXH ebzKCJ"
data-trigger="focus"
onClick={[Function]}>
This is the popover link text.
Expand Down