2019-06-10 12:28:54 +00:00
|
|
|
import React from 'react'
|
|
|
|
import styled, { css } from 'styled-components'
|
|
|
|
import PropTypes from 'prop-types'
|
2019-06-24 13:18:47 +00:00
|
|
|
import DropDownItem from '../drop-down-item'
|
2019-06-10 12:28:54 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 100%;
|
2019-06-28 11:37:43 +00:00
|
|
|
${props => (props.direction === 'right' && css`right: 0px;`)}
|
|
|
|
${props => (props.direction === 'left' && css`left: 0px;`)}
|
2019-06-10 12:28:54 +00:00
|
|
|
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 DropDown = props => {
|
|
|
|
return (
|
|
|
|
<StyledDropdown {...props}>
|
2019-06-24 13:18:47 +00:00
|
|
|
{React.Children.map(props.children, (child) =>
|
|
|
|
<DropDownItem {...child.props}/>
|
|
|
|
)}
|
|
|
|
</StyledDropdown>
|
2019-06-10 12:28:54 +00:00
|
|
|
);
|
2019-06-24 13:18:47 +00:00
|
|
|
};
|
|
|
|
|
2019-06-28 11:37:43 +00:00
|
|
|
DropDown.propTypes = {
|
|
|
|
direction: PropTypes.oneOf(['left', 'right'])
|
|
|
|
};
|
|
|
|
|
|
|
|
DropDown.defaultProps = {
|
|
|
|
direction: 'left'
|
|
|
|
};
|
|
|
|
|
2019-06-10 12:28:54 +00:00
|
|
|
export default DropDown
|