DocSpace-buildtools/web/ASC.Web.Components/src/components/drop-down/index.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

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`
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%;
${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;
margin-top: 0px;
2019-06-10 12:28:54 +00:00
display: ${props => (props.isOpen || props.opened ? 'block' : 'none')};
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
};
DropDown.propTypes = {
direction: PropTypes.oneOf(['left', 'right'])
};
DropDown.defaultProps = {
direction: 'left'
};
2019-06-10 12:28:54 +00:00
export default DropDown