Progress Indicator

By Rafi

F6
#
How do I use This?

A progress indicator that is useful for showing steps. Can be used with text or without.

HTML
<ol class="progress-indicator">
  <li class="is-complete" data-step="1">
  </li>
  <li class="is-complete" data-step="2">
  </li>
  <li class="is-current" data-step="3">
  </li>
</ol>

<ol class="progress-indicator">
  <li class="is-complete" data-step="1">
  </li>
  <li class="is-current" data-step="2">
  </li>
  <li class="" data-step="3">
  </li>
</ol>

<ol class="progress-indicator">
  <li class="is-complete" data-step="">
  <span>Arrive</span>
  </li>
  <li class="is-current" data-step="">
  <span>Check In</span>
  </li>
  <li class="" data-step="">
  <span>Depart</span>
  </li>
</ol>

$progress-indicator-complete: $primary-color;
$progress-indicator-current: lighten($primary-color, 20%);
$progress-indicator-incomplete: $light-gray;
$progress-indicator-step-size: 1.5em;
$progress-indicator-width: 100%;

.progress-indicator {
  list-style: none;
  width: $progress-indicator-width;
  margin: 0 auto;
  padding: 0;
  display: table;
  table-layout: fixed;

  > li {
    position: relative;
    display: table-cell;
    text-align: center;
    font-size: 1.5em;

    span {
      position: absolute;
      color: $light-gray;
      transform: translateX(-50%);
      font-weight: 600;
      font-size: rem-calc(14);
      letter-spacing: 0.05px;
      text-transform: uppercase;
    }

    &::before {
      content: attr(data-step);
      display: block;
      margin: 0 auto;
      background: $progress-indicator-incomplete;
      width: $progress-indicator-step-size;
      height: $progress-indicator-step-size;
      text-align: center;
      margin-bottom: 0.25em;
      line-height: $progress-indicator-step-size;
      border-radius: 100%;
      position: relative;
      z-index: 1000;
    }

    &::after {
      content: '';
      position: absolute;
      display: block;
      background: $progress-indicator-incomplete;
      width: 100%;
      height: $progress-indicator-step-size/10;
      top: 50%; // height of bar
      transform: translateY(-100%);
      left: 50%;
      margin-left: 1.5em\9;
      z-index: 0;
    }

    &:last-child:after {
      display: none;
    }

    &.is-complete {
      color: $progress-indicator-complete;

      &::before,
      &::after {
        color: $white;
        background: $progress-indicator-complete;
      }

      span {
        color: $progress-indicator-complete;
      }
    }

    &.is-current {
      color: $progress-indicator-current;

      &::before {
        color: $white;
        background: $progress-indicator-current;
      }

      span {
        color: $progress-indicator-current;
      }
    }
  }
}





.progress-indicator {
  list-style: none;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  display: table;
  table-layout: fixed;
}

.progress-indicator > li {
  position: relative;
  display: table-cell;
  text-align: center;
  font-size: 1.5em;
}

.progress-indicator > li span {
  position: absolute;
  color: #e6e6e6;
  -webkit-transform: translateX(-50%);
      -ms-transform: translateX(-50%);
          transform: translateX(-50%);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.05px;
  text-transform: uppercase;
}

.progress-indicator > li::before {
  content: attr(data-step);
  display: block;
  margin: 0 auto;
  background: #e6e6e6;
  width: 1.5em;
  height: 1.5em;
  text-align: center;
  margin-bottom: 0.25em;
  line-height: 1.5em;
  border-radius: 100%;
  position: relative;
  z-index: 1000;
}

.progress-indicator > li::after {
  content: '';
  position: absolute;
  display: block;
  background: #e6e6e6;
  width: 100%;
  height: 0.15em;
  top: 50%;
  -webkit-transform: translateY(-100%);
      -ms-transform: translateY(-100%);
          transform: translateY(-100%);
  left: 50%;
  margin-left: 1.5em\9;
  z-index: 0;
}

.progress-indicator > li:last-child:after {
  display: none;
}

.progress-indicator > li.is-complete {
  color: #1779ba;
}

.progress-indicator > li.is-complete::before, .progress-indicator > li.is-complete::after {
  color: #fefefe;
  background: #1779ba;
}

.progress-indicator > li.is-complete span {
  color: #1779ba;
}

.progress-indicator > li.is-current {
  color: #4eabe9;
}

.progress-indicator > li.is-current::before {
  color: #fefefe;
  background: #4eabe9;
}

.progress-indicator > li.is-current span {
  color: #4eabe9;
}

JS