All files DropdownContent.jsx

0% Statements 0/3
100% Branches 0/0
0% Functions 0/3
0% Lines 0/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                         
import React from 'react';
import PropTypes from 'prop-types';
import { List, Card } from '@procore/core-react';
 
/** must be class component because passing ref as prop for position */
class DropdownContent extends React.Component {
  static propTypes = {
    children: PropTypes.node,
    onItemClick: PropTypes.func.isRequired,
    styles: PropTypes.shape()
  };
 
  static defaultProps = {
    children: null,
    onItemClick: () => {},
    styles: {}
  };
 
  render() {
    const { styles, children, onItemClick } = this.props;
 
    return (
      <div className={styles.dropdownContainer}>
        <Card className={styles.card}>
          <List className={styles.listItem}>
            {React.Children.map(children, (child => (
              <List.Item>
                {React.cloneElement(child,
                  {
                    ...child.props,
                    onClick: onItemClick(child.props.onClick),
                    styles
                  })
                }
              </List.Item>
            )))}
          </List>
        </Card>
      </div>
    );
  }
}
 
export default DropdownContent;