ananthamapod/GridAI

View on GitHub
src/sass/main.scss

Summary

Maintainability
Test Coverage
/*********** CONSTANTS ************/
$start: #27ae60;
$end: #c0392b;

$player: #1C86EE;
$dfs: #FF6666;
$bfs: #FBB829;
$bestfirst: #16a085;
$astar: #8e44ad;

/**********************************/

/************ MIXINS **************/
@mixin stripe($color1, $color2, $color3: $color1, $color4: $color2, $angle: 45deg) {
  background: repeating-linear-gradient(
  $angle,
  $color1,
  $color2 10px,
  $color3 10px,
  $color4 20px);
}

@mixin alpha-attribute($attribute, $color, $background) {
  $percent: alpha($color) * 100%;
  $opaque: opacify($color, 1);
  $solid-color: mix($opaque, $background, $percent);
  #{$attribute}: $solid-color;
  #{$attribute}: $color;
}

@mixin alpha-background($color, $background) {
  @include alpha-attribute('background', $color, $background);
}

/**********************************/

/****** OVERALL BODY STYLES *******/
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Liberation Sans', sans-serif;
  font-size: 16px;
  min-height: 100%;
}

header {
  padding: 2rem;
  text-align: center;

  img {
    width: 100%;
    max-width: 600px;
    height: auto;
  }
}

a.github {
  line-height: 1.4em;

  img {
    width: 1.4em;
    height: auto;
    margin-right: 1em;
  }
}

body.theme-dark {
  background: #2D2D2D;
  transition: .4s;

  header {
    color: #ccc;
    transition: .4s;
  }

  label.theme-label {
    color: #ccc;

    &::after {
      content: "dark";
    }
  }

  a.github {
    color: ghostwhite;

    img {
      opacity: 1;
    }
  }

  .maze {
    background: #313131;
  }

  #legend {
    background: #313131;
    color: ghostwhite;
  }
}

#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 3em;
  line-height: 3em;
  background: #e9ecef;
}

/**********************************/


/************** FORM **************/
#maze_form {
  display: flex;
  text-align: center;
  font-family: sans-serif;
  margin: 1em;

  button.btn {
    cursor: pointer;
  }

  .mode-toggle {
    border-radius: 0.5em;
    background: linear-gradient(to right, $bfs, $dfs);
    margin: 0;

    input[type=radio] {
      display: none;

      &:checked + label {
        color: ghostwhite;
        font-weight: bolder;
        background: transparent;
      }
    }

    label {
      display: block;
      cursor: pointer;
      background: rgba(ghostwhite, 0.3);
      text-align: center;
      padding: 0.5rem 0.75rem;
      z-index: 50;
      transition: all 0.4s ease;
      margin: 0;
    }

    .mode-slider {
      width: 33%;
      height: 1em;
      position: absolute;
      top: 3px;
      border-radius: 50px;
      -webkit-transition: all 0.4s ease;
      -moz-transition: all 0.4s ease;
      -o-transition: all 0.4s ease;
      -ms-transition: all 0.4s ease;
      transition: all 0.4s ease;
      z-index: 0;
    }

    #mode1:checked ~ .mode-slider {
      background: rgba($dfs, 0.3);
      left: 0%;
    }

    #mode2:checked ~ .mode-slider {
      background: rgba($dfs, 0.7);
      left: 33%;
    }

    #mode3:checked ~ .mode-slider {
      background: rgba($dfs, 0.7);
      left: 66%;
    }
  }
}

.theme-toggle {
  label.theme-label {
    color: #333;
    display: block;

    &::after {
      content: "light";
    }
  }

  /* The switch - the box around the slider */
  .switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;

    /* Hide default HTML checkbox */
    input {
      display: none;
    }
  }

  /* The slider */
  .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    -webkit-transition: .4s;
    transition: .4s;

    &:before {
      position: absolute;
      content: "";
      height: 26px;
      width: 26px;
      left: 4px;
      bottom: 4px;
      background-color: white;
      -webkit-transition: .4s;
      transition: .4s;
    }

    /* Rounded sliders */
    &.round {
      border-radius: 34px;
    }

    &.round:before {
      border-radius: 50%;
    }
  }

  input:checked + .slider {
    background-color: #ccc;
  }

  input:focus + .slider {
    box-shadow: 0 0 1px #ccc;
  }

  input:checked + .slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
  }
}

/**********************************/


/************ MAIN MAZE ***********/
.maze {
  position: relative;
  margin: 1em;
  text-align: center;
  border-radius: 2em;
  padding: 2em;
  background: #f1f1f1;
  transition: .4s;

  #canvas {
    width: 100%;
  }

  .row {
    margin: 0;
    padding: 0;
    line-height: 0;
    flex-wrap: nowrap;

    .cell {
      width: 100px;
      height: 100px;
      margin: 0;
      background: #777;
      display: inline-block;
      border: 2px solid black;
      position: relative;
    }

    .right {
      border-right: 2px solid #888;
    }

    .left {
      border-left: 2px solid #888;
    }

    .up {
      border-top: 2px solid #888;
    }

    .down {
      border-bottom: 2px solid #777;
    }

    .current {
      background-color: $player;
    }

    .dfs {
      background-color: $dfs;
    }

    .bestfirst {
      background-color: $bestfirst;
    }

    .astar {
      background-color: $astar;
    }

    .bfs {
      background-color: $bfs;
    }

    .start {
      box-shadow: -5px -5px 0px 4px $start;
      border-top-width: 0;
      border-left-width: 0;
    }

    .end {
      box-shadow: 5px 5px 0px 4px $end;
      border-bottom-width: 0;
      border-right-width: 0;
    }
  }
}

/**********************************/


/************* LEGEND *************/
#legend {
  position: relative;
  margin: 1em;
  border-radius: 2em;
  padding: 1em;
  background: #f1f1f1;
  transition: .4s;

  .legend-swatch {
    height: 1.3em;
    width: 1.3em;
    border-radius: 0.7em;
    margin-right: 1em;

    &.current {
      background-color: $player;
    }

    &.dfs {
      background-color: $dfs;
    }

    &.bestfirst {
      background-color: $bestfirst;
    }

    &.astar {
      background-color: $astar;
    }

    &.bfs {
      background-color: $bfs;
    }
  }
}

/**********************************/