import ElectionIcon from "../../../ElectionIcon/index.js";
import { useCallback } from 'react';
import classnames from 'classnames';
import classes from './styles.module.scss';
import getLabel from './getLabel';
const ExpandButton = function ExpandButton(props) {
  const {
    isExpanded,
    setIsExpanded,
    expandLabel,
    collapseLabel,
    hasBorder
  } = props;
  const iconType = isExpanded ? 'Collapse' : 'Expand';
  const label = getLabel(isExpanded, expandLabel, collapseLabel);
  const clickHandler = useCallback(() => {
    setIsExpanded(prev => !prev);
  }, [setIsExpanded]);
  return <button className={classnames(classes.container, {
    [classes['has-border']]: hasBorder
  })} type="button" aria-label={label} onClick={clickHandler}>
      <ElectionIcon type={iconType} color="warmgray-60" size="3" />
    </button>;
};
export default ExpandButton;