HabitatMap/AirCasting

View on GitHub
app/assets/stylesheets/modules/crowd-map-slider.scss

Summary

Maintainability
Test Coverage
/*
 * Custom range input
 * Used https://www.cssportal.com/style-input-range/ to generate basic styles and then tweaked.
 * For more info see https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/.
 */

$track-color: #fff;
$thumb-color: $blue;

$thumb-radius: 10px;
$thumb-height: 20px;
$thumb-width: 20px;

$zoom-thumb-width: 4px;
$zoom-thumb-height: 22px;
$zoom-thumb-radius: 2px;

$track-height: 2px;

input[type="range"] {
  @include appearance(none);
  height: $track-height;
  margin: 0 5px;
  width: 100%;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-moz-focus-outer {
  border: 0;
}

input[type="range"]::-webkit-slider-thumb {
  @include appearance(none);
  height: $thumb-height;
  width: $thumb-width;
  border-radius: $thumb-radius;
  background: $blue;
  cursor: pointer;
  margin-top: ($track-height * 0.5) - ($thumb-height * 0.5);
}

input[type="range"]::-moz-range-thumb {
  box-shadow: none;
  border: none;
  height: $thumb-height;
  width: $thumb-width;
  border-radius: $thumb-radius;
  background: $blue;
  cursor: pointer;
}

input[type="range"]::-ms-thumb {
  margin-top: 1px;
  box-shadow: none;
  border: none;
  height: $thumb-height;
  width: $thumb-width;
  border-radius: $thumb-radius;
  background: $blue;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: $track-height;
  cursor: pointer;
  background: $track-color;
  border-radius: 0;
}

input[type="range"]:focus::-webkit-slider-runnable-track {
  background: $track-color;
}

input[type="range"]::-moz-range-track {
  height: $track-height;
  cursor: pointer;
  box-shadow: none;
  background: $track-color;
  border-radius: 0;
  border: none;
}

input[type="range"]::-ms-track {
  width: 100%;
  height: $track-height;
  cursor: pointer;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

input[type="range"]::-ms-fill-lower {
  background: $track-color;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

input[type="range"]::-ms-fill-upper {
  background: $track-color;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

input[type="range"]:focus::-ms-fill-lower {
  background: $track-color;
}

input[type="range"]:focus::-ms-fill-upper {
  background: $track-color;
}

.crowd-map-slider-container {
  align-items: center;
  display: flex;
  margin: 8px 0 24px;

  span {
    font-size: 24px;
    height: $thumb-height;
    line-height: $thumb-height;

    &.minus {
      margin-top: -1px;
      cursor: pointer;
    }

    &.plus {
      margin-top: 2px;
      cursor: pointer;
    }
  }
}

.zoom-slider-container {
  right: 1rem;
  height: 156px;
  position: absolute;
  top: 2rem;
  width: 28px;
  z-index: 1;

  @media screen and (min-width: $small-desktop-min) {
    top: 6rem;
  }
}

.zoom__plus,
.zoom__minus {
  background-color: white;
  border-radius: 50%;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 2px 1px;
  cursor: pointer;
  display: block;
  height: 28px;
  font-size: $medium-font;
  line-height: 29px;
  position: relative;
  text-align: center;
  width: 28px;
  z-index: 1;
}

.zoom__minus {
  margin-top: 100px;
}

input[type="range"].zoom-slider {
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 3px 1px;
  height: 5px;
  position: absolute;
  right: -2.55rem;
  top: 49%;
  transform: rotate(-90deg);
  width: 100px;
}

input[type="range"].zoom-slider::-webkit-slider-thumb {
  @include appearance(none);
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 2px 1px;
  height: $zoom-thumb-height;
  width: $zoom-thumb-width;
  border-radius: $zoom-thumb-radius;
  background: white;
  margin-top: -10px;
}

input[type="range"].zoom-slider::-moz-range-thumb {
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 2px 1px;
  border: none;
  height: $zoom-thumb-height;
  width: $zoom-thumb-width;
  border-radius: $zoom-thumb-radius;
  background: white;
}

input[type="range"].zoom-slider::-ms-thumb {
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 2px 1px;
  margin-top: 1px;
  border: none;
  height: $zoom-thumb-height;
  width: $zoom-thumb-width;
  border-radius: $zoom-thumb-radius;
  background: white;
}