RyanofWoods/rails-react-swedish-birds

View on GitHub
app/assets/stylesheets/components/_checkbox.scss

Summary

Maintainability
Test Coverage
input[type="checkbox"] {
  position: relative;
  transition: transform ease-in 0.1s;
  width: 24px;
  height: 24px;
  cursor: pointer;
  border-radius: $border-radius;
  margin: 0 0.5rem 0 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-print-color-adjust: exact;
  background-color: $white;
  border: 1px solid $dark-brown;
}
input[type="checkbox"]:checked {
  background-color: $primary !important;
  color: #fff !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
  border: none;

  &.checkbox-checked-hover-pointer-none {
    cursor: auto;
  }
}
input[type="checkbox"]:before, input[type="checkbox"]:after {
  position: absolute;
  content: '';
  display: block;
  width: 200%;
  height: 100%;
  left: -50%;
  z-index: 30;
  transition: all ease-in-out 0.5s;
  background-repeat: no-repeat;
}
input[type="checkbox"]:before {
  display: none;
  top: -75%;
  background-image: radial-gradient(circle, $orange 20%, transparent 20%), radial-gradient(circle, transparent 20%, $primary 20%, transparent 30%), radial-gradient(circle, $blue 20%, transparent 20%), radial-gradient(circle, $orange 20%, transparent 20%), radial-gradient(circle, transparent 10%, $primary 15%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%), radial-gradient(circle, $blue 20%, transparent 20%);
  background-size: 40% 40%, 50% 50%, 45% 45%, 50% 50%, 48% 48%, 40% 40%, 45% 45%, 40% 40%, 48% 48%;
}
input[type="checkbox"]:after {
  display: none;
  bottom: -75%;
  background-image: radial-gradient(circle, $blue 20%, transparent 20%), radial-gradient(circle, $orange 20%, transparent 20%), radial-gradient(circle, transparent 10%, $orange 15%, transparent 20%), radial-gradient(circle, $blue 20%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%), radial-gradient(circle, $primary 20%, transparent 20%);
  background-size: 45% 45%, 50% 50%, 48% 48%, 50% 50%, 45% 45%, 40% 40%, 50% 50%;
}
input[type="checkbox"].animate:before {
  display: block;
  animation: topBubbles ease-in-out 0.75s forwards;
}
input[type="checkbox"].animate:after {
  display: block;
  animation: bottomBubbles ease-in-out 0.75s forwards;
}
@keyframes topBubbles {
  0% {
    background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%;
  }
  50% {
    background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%;
  }
  100% {
    background-position: 0% 70%, 0% 10%, 10% 30%, 20% -10%, 30% 20%, 22% 40%, 50% 40%, 65% 10%, 90% 20%;
    background-size: 0% 0%, 0% 0%,  0% 0%,  0% 0%,  0% 0%,  0% 0%;
  }
}
@keyframes bottomBubbles {
  0% {
    background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%;
  }
  50% {
    background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%;
  }
  100% {
    background-position: 0% 90%, 20% 90%, 45% 70%, 60% 110%, 75% 80%, 95% 70%, 110% 10%;
    background-size: 0% 0%, 0% 0%,  0% 0%,  0% 0%,  0% 0%,  0% 0%;
  }
}

.checkbox-container {
 width: 36px;
 display: flex;
 align-items: center;
}

input[type="checkbox"]:checked.fadeaway {
  animation: fadeaway 1s linear forwards;
}

@keyframes fadeaway {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}