All files / report/components/ChartEditButtons index.jsx

100% Statements 9/9
100% Branches 0/0
100% Functions 4/4
100% Lines 9/9
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 67 68 69                        2x             2x                           2x 3x 1x         1x         1x               2x         2x                    
import React from 'react';
import PropTypes from 'prop-types';
import {
  Button,
} from '@bufferapp/components';
import {
  ArrowUpIcon,
  ArrowDownIcon,
  CloseIcon,
} from '@bufferapp/components/Icon/Icons';
import styled from 'styled-components';
 
const Wrapper = styled.aside`
  position: absolute;
  top: 2.5rem;
  right: 2rem;
  transition: all 50ms linear;
`;
 
const Box = styled.span`
  background: #FFFFFF;
  border: 1px solid #D5E3EF;
  box-sizing: border-box;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  width: 1.75rem;
  height: 1.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  margin: 0 0 0 .25rem;
`;
 
const ChartEditButtons = ({ first, last, moveUp, moveDown, deleteChart, id }) => (
  <Wrapper>
    <Button disabled={first} noStyle onClick={() => moveUp(id)}>
      <Box>
        <ArrowUpIcon />
      </Box>
    </Button>
    <Button disabled={last} noStyle onClick={() => moveDown(id)}>
      <Box>
        <ArrowDownIcon />
      </Box>
    </Button>
    <Button noStyle onClick={() => deleteChart(id)}>
      <Box>
        <CloseIcon />
      </Box>
    </Button>
  </Wrapper>
);
 
ChartEditButtons.defaultProps = {
  first: false,
  last: false,
};
 
ChartEditButtons.propTypes = {
  id: PropTypes.string.isRequired,
  moveUp: PropTypes.func.isRequired,
  moveDown: PropTypes.func.isRequired,
  deleteChart: PropTypes.func.isRequired,
  first: PropTypes.bool,
  last: PropTypes.bool,
};
 
export default ChartEditButtons;