You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.4 KiB
108 lines
2.4 KiB
4 years ago
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
4 years ago
|
import MenuDroppo from '../menu-droppo';
|
||
7 years ago
|
|
||
5 years ago
|
export class Dropdown extends Component {
|
||
4 years ago
|
render() {
|
||
7 years ago
|
const {
|
||
|
containerClassName,
|
||
|
isOpen,
|
||
|
onClickOutside,
|
||
|
style,
|
||
|
innerStyle,
|
||
|
children,
|
||
|
useCssTransition,
|
||
4 years ago
|
} = this.props;
|
||
8 years ago
|
|
||
4 years ago
|
const innerStyleDefaults = {
|
||
7 years ago
|
borderRadius: '4px',
|
||
|
padding: '8px 16px',
|
||
|
background: 'rgba(0, 0, 0, 0.8)',
|
||
4 years ago
|
boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
|
||
|
...innerStyle,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
5 years ago
|
return (
|
||
|
<MenuDroppo
|
||
|
containerClassName={containerClassName}
|
||
|
useCssTransition={useCssTransition}
|
||
|
isOpen={isOpen}
|
||
|
zIndex={55}
|
||
|
onClickOutside={onClickOutside}
|
||
|
style={style}
|
||
|
innerStyle={innerStyleDefaults}
|
||
|
>
|
||
|
<style>
|
||
|
{`
|
||
|
li.dropdown-menu-item:hover {
|
||
|
color:rgb(225, 225, 225);
|
||
|
background-color: rgba(255, 255, 255, 0.05);
|
||
|
border-radius: 4px;
|
||
|
}
|
||
|
li.dropdown-menu-item { color: rgb(185, 185, 185); }
|
||
|
`}
|
||
|
</style>
|
||
4 years ago
|
{children}
|
||
5 years ago
|
</MenuDroppo>
|
||
4 years ago
|
);
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
Dropdown.defaultProps = {
|
||
7 years ago
|
useCssTransition: false,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
8 years ago
|
Dropdown.propTypes = {
|
||
7 years ago
|
isOpen: PropTypes.bool.isRequired,
|
||
8 years ago
|
children: PropTypes.node,
|
||
7 years ago
|
style: PropTypes.object.isRequired,
|
||
7 years ago
|
onClickOutside: PropTypes.func,
|
||
|
innerStyle: PropTypes.object,
|
||
|
useCssTransition: PropTypes.bool,
|
||
7 years ago
|
containerClassName: PropTypes.string,
|
||
4 years ago
|
};
|
||
8 years ago
|
|
||
5 years ago
|
export class DropdownMenuItem extends Component {
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { onClick, closeMenu, children, style } = this.props;
|
||
8 years ago
|
|
||
5 years ago
|
return (
|
||
|
<li
|
||
|
className="dropdown-menu-item"
|
||
|
onClick={() => {
|
||
4 years ago
|
onClick();
|
||
|
closeMenu();
|
||
5 years ago
|
}}
|
||
4 years ago
|
onKeyPress={(event) => {
|
||
|
if (event.key === 'Enter') {
|
||
4 years ago
|
onClick();
|
||
|
closeMenu();
|
||
4 years ago
|
}
|
||
|
}}
|
||
4 years ago
|
style={{
|
||
8 years ago
|
listStyle: 'none',
|
||
7 years ago
|
padding: '8px 0px',
|
||
7 years ago
|
fontSize: '18px',
|
||
8 years ago
|
fontStyle: 'normal',
|
||
|
cursor: 'pointer',
|
||
|
display: 'flex',
|
||
|
justifyContent: 'flex-start',
|
||
7 years ago
|
alignItems: 'center',
|
||
4 years ago
|
color: 'white',
|
||
|
...style,
|
||
|
}}
|
||
4 years ago
|
tabIndex="0"
|
||
5 years ago
|
>
|
||
|
{children}
|
||
|
</li>
|
||
4 years ago
|
);
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
|
DropdownMenuItem.propTypes = {
|
||
|
closeMenu: PropTypes.func.isRequired,
|
||
|
onClick: PropTypes.func.isRequired,
|
||
|
children: PropTypes.node,
|
||
7 years ago
|
style: PropTypes.object,
|
||
4 years ago
|
};
|