2019-06-10 12:28:54 +00:00
|
|
|
import React from 'react'
|
|
|
|
import styled, { css } from 'styled-components'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
const StyledDropdown = styled.div`
|
2019-06-18 14:07:57 +00:00
|
|
|
font-family: Open Sans;
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: 600;
|
|
|
|
font-size: 13px;
|
|
|
|
line-height: 36px;
|
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 100%;
|
|
|
|
left: 0;
|
|
|
|
z-index: 1000;
|
2019-06-18 14:07:57 +00:00
|
|
|
margin-top: 0px;
|
2019-06-10 12:28:54 +00:00
|
|
|
display: ${props => (props.isOpen || props.opened ? 'block' : 'none')};
|
2019-06-18 14:07:57 +00:00
|
|
|
border-radius: 6px;
|
|
|
|
-moz-border-radius: 6px;
|
|
|
|
-webkit-border-radius: 6px;
|
|
|
|
background: #FFFFFF;
|
|
|
|
box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.13);
|
|
|
|
-moz-box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.13);
|
|
|
|
-webkit-box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.13);
|
2019-06-10 12:28:54 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledDropdownItem = styled.button`
|
2019-06-17 08:58:02 +00:00
|
|
|
width: 100%;
|
|
|
|
text-align: left;
|
2019-06-10 12:28:54 +00:00
|
|
|
background: none;
|
|
|
|
border: 0;
|
|
|
|
color: #333333;
|
|
|
|
cursor: pointer;
|
|
|
|
display: block;
|
2019-06-18 14:07:57 +00:00
|
|
|
line-height: 36px;
|
2019-06-10 12:28:54 +00:00
|
|
|
margin: 0;
|
|
|
|
padding: 0 12px;
|
|
|
|
text-decoration: none;
|
2019-06-18 14:07:57 +00:00
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
user-select: none;
|
|
|
|
-o-user-select: none;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-webkit-user-select: none;
|
2019-06-18 14:07:57 +00:00
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
white-space: nowrap;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-ms-user-select: none;
|
|
|
|
-o-user-select: none;
|
|
|
|
-webkit-user-select: none;
|
2019-06-18 14:07:57 +00:00
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
stroke: none;
|
|
|
|
|
|
|
|
&:hover{
|
2019-06-18 14:07:57 +00:00
|
|
|
background-color: #F8F9F9;
|
2019-06-17 08:58:02 +00:00
|
|
|
width: 100%;
|
|
|
|
text-align: left;
|
2019-06-18 14:07:57 +00:00
|
|
|
|
|
|
|
&:first-of-type{
|
|
|
|
border-radius: 6px 6px 0 0;
|
|
|
|
-moz-border-radius: 6px 6px 0 0;
|
|
|
|
-webkit-border-radius: 6px 6px 0 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-of-type{
|
|
|
|
border-radius: 0 0 6px 6px;
|
|
|
|
-moz-border-radius: 0 0 6px 6px;
|
|
|
|
-webkit-border-radius: 0 0 6px 6px;
|
|
|
|
}
|
2019-06-10 12:28:54 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const DropDown = props => {
|
|
|
|
return (
|
|
|
|
<StyledDropdown {...props}>
|
|
|
|
{React.Children.map(props.children, (child) =>
|
|
|
|
<StyledDropdownItem
|
|
|
|
tabIndex={child.props.tabIndex || -1}
|
|
|
|
onClick={child.props.clickAction || child.props.onClick}
|
|
|
|
>
|
|
|
|
{child.props.text || child.props.label}
|
|
|
|
</StyledDropdownItem>)}
|
|
|
|
</StyledDropdown>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DropDown
|