import styled from "styled-components";

import {Input} from "../../base";

import {
  theme,
  getColor,
  getWidth,
  getHeight
} from "../../styled-config";

const Range = styled(Input)`
  appearance: none;
  background:  ${(props) => getColor(props, 'range', 'background')};
  border-radius: 0.5rem;
  height: 1rem;
  margin: 0 0.5rem;
  outline: none;
  width: 100%;

  &::-webkit-slider-thumb {
    cursor: pointer;
    -webkit-appearance: none;
    background: ${(props) => getColor(props, 'range', 'thumb')};
    border: 0;
    border-radius: 50%;
    height: ${(props) => getHeight(props, 'range', 'default')};
    width:  ${(props) => getWidth(props, 'range', 'default')};
  }

  &:focus::-webkit-slider-thumb {
    outline: -webkit-focus-ring-color auto 0px;
  }

  &::-moz-range-thumb {
    background: ${(props) => getColor(props, 'range', 'thumb')};
    border-radius: 50%;
    border: none;
    cursor: pointer;
    height: ${(props) => getHeight(props, 'range', 'default')};
    width:  ${(props) => getWidth(props, 'range', 'default')};
  }

  &::-moz-range-track {
    background: ${(props) => getColor(props, 'range', 'background')};
    border-radius: 5px;
    cursor: pointer;
    height: 0.125rem;
    width: 100%;
  }
`;

Range.defaultProps = {
  theme,
};

export {Range};
