All files / posts-table/components/PostsTable/components/PostsHeader/components/TopPostsDropdown/components/DropdownItem index.jsx

85.71% Statements 6/7
0% Branches 0/2
0% Functions 0/1
85.71% Lines 6/7
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                            1x                   1x         1x             1x                             1x                 1x          
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
 
import {
  Button,
  CheckmarkIcon,
  Text,
} from '@bufferapp/components';
 
import {
  dropdownListItem,
} from '../../style.less';
 
const MetricContainer = styled.span`
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  position: relative;
  width: 100%;
  padding: 0.5rem 0.75rem;
`;
 
const MetricText = styled.span`
  display: inline-block;
  margin: 0 0 0 0.2rem;
`;
 
const MetricIcon = styled.span`
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin: 0 0.25rem 0 0;
`;
 
const DropdownItem = ({ metric, handleClick, selected }) => (
  <li className={dropdownListItem}>
    <Button noStyle onClick={handleClick} >
      <MetricContainer>
        <MetricText>
          <Text size="small" color="outerSpace">{metric.label}</Text>
        </MetricText>
        <MetricIcon>
          {selected && <CheckmarkIcon color={'curiousBlue'} />}
        </MetricIcon>
      </MetricContainer>
    </Button>
  </li>
);
 
DropdownItem.propTypes = {
  metric: PropTypes.shape({
    key: PropTypes.string.isRequired,
    label: PropTypes.string.isRequired,
  }).isRequired,
  handleClick: PropTypes.func.isRequired,
  selected: PropTypes.bool,
};
 
DropdownItem.defaultProps = {
  selected: false,
};
 
export default DropdownItem;