bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/dropdown/content/component.jsx

66 lines
1.4 KiB
React
Raw Normal View History

import React, { Component, Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
2018-01-08 14:17:18 +08:00
import { styles } from '../styles';
const PLACEMENTS = [
'top left', 'top', 'top right',
'right top', 'right', 'right bottom',
'bottom right', 'bottom', 'bottom left',
'left bottom', 'left', 'left top',
];
const propTypes = {
/**
* Placements of the dropdown and its caret
* @defaultValue 'top'
*/
placement: PropTypes.oneOf(PLACEMENTS),
};
const defaultProps = {
placement: 'top',
'aria-expanded': false,
};
export default class DropdownContent extends Component {
render() {
const {
placement,
children,
className,
dropdownToggle,
dropdownShow,
dropdownHide,
dropdownIsOpen,
keepOpen,
...restProps
} = this.props;
2017-06-03 03:25:02 +08:00
const placementName = placement.split(' ').join('-');
const boundChildren = Children.map(children, child => cloneElement(child, {
dropdownIsOpen,
2017-06-03 03:25:02 +08:00
dropdownToggle,
dropdownShow,
dropdownHide,
keepOpen,
}));
return (
<div
data-test="dropdownContent"
2017-06-03 03:25:02 +08:00
className={cx(styles.content, styles[placementName], className)}
{...restProps}
2017-06-03 03:25:02 +08:00
>
<div className={styles.scrollable}>
{boundChildren}
</div>
</div>
);
}
}
DropdownContent.propTypes = propTypes;
DropdownContent.defaultProps = defaultProps;