import { FADE_DURATION_COEF, FADE_START_COEF, SOLID_PARTY_VALUE } from '../constants';
const VoteHistoryGradient = function VoteHistoryGradient(props) {
  const {
    id,
    scales,
    range
  } = props;
  const {
    x,
    y,
    color,
    fade
  } = scales;
  return <defs>
      <linearGradient id={`${id}-line-gradient`} gradientUnits="userSpaceOnUse" x1={x(SOLID_PARTY_VALUE * -1)} x2={x(SOLID_PARTY_VALUE)} y1="0" y2="0">
        <stop offset={0} stopColor={color(range.x.min)} />
        <stop offset={1} stopColor={color(range.x.max)} />
      </linearGradient>

      <linearGradient id={`${id}-fade-gradient`} gradientUnits="userSpaceOnUse" x1={0} x2={0} y1={y(range.y.penultimate + FADE_START_COEF)} y2={y(range.y.penultimate + FADE_START_COEF + FADE_DURATION_COEF)}>
        <stop offset={0} stopColor="white" stopOpacity={fade(range.y.penultimate)} />
        <stop offset={1} stopColor="white" stopOpacity={fade(range.y.max)} />
      </linearGradient>

    </defs>;
};
export default VoteHistoryGradient;