openfoodfoundation/openfoodnetwork

View on GitHub
app/webpacker/css/darkswarm/menu.scss

Summary

Maintainability
Test Coverage
//@import 'compass';

nav.top-bar {
  @include textpress;
  text-shadow: none;
  text-align: center;
  font-size: 16px;
  margin-bottom: 0;
  height: $topbar-height;
  z-index: 190;
}

@media #{$large-up} {
  .top-bar--menu-item-with-icon span {
    display: none;
  }

  .top-bar--current-hub-prefix,
  .top-bar--current-hub-name {
    display: inline-block;
    vertical-align: middle;
  }

  .top-bar--current-hub-name {
    max-width: 10em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.top-bar-section ul li > a.top-bar--menu-item-with-icon {
  display: inline;
}

.top-bar--menu-item-with-icon i,
.top-bar--menu-item-with-icon img {
  line-height: $topbar-height;
}

.top-bar-section {
  border-bottom: 1px solid $light-grey-transparency;
  display: flex;
  justify-content: space-between;

  .nav-main-menu,
  .nav-icons-menu {
    flex-shrink: 0;
  }

  a.icon {
    &:hover {
      text-decoration: none;
    }

    > span {
      display: inline-block;
      font-weight: 300;
      height: $topbar-height;
      line-height: $topbar-height;
      vertical-align: top;
    }
  }

  // Avoid menu items blocking logo
  li:not(.has-form), li:not(.has-form) a:not(.button), li:not(.has-form) a:not(.button):hover {
    background-color: transparent;
  }

  li.cart {
    background-color: #f4704c;

    a span {
      color: white;
    }

    i {
      color: white;
    }

    .count {
      position: relative;

      img {
        width: 32px;
        height: 26px;
        margin-top: 16px;
        margin-right: 5px;
      }

      span {
        background-color: white;
        border-radius: 20px;
        color: #f4704c;
        font-size: 12px;
        line-height: 18px;
        position: absolute;
        right: -8px;
        top: 8px;
        width: 18px;
      }
    }
  }

  ul.dropdown {
    border: 1px solid $smoke;
    border-top: none;
    left: auto;
    right: 0;
  }

  .nav-icons-menu {
    > li {
      border-left: 1px solid #ddd;
      padding: 0 14px;

      @media screen and (max-width: 1450px) {
        padding: 0 6px;
      }
    }

    li > a {
      opacity: 0.8;

      &:hover, &:focus, &:active {
        opacity: 1;
      }

      i {
        color: #f4704c;
        display: inline-block;
        margin-right: 2px;
        margin-top: -3px;
        vertical-align: middle;
      }

      img {
        margin-right: 2px;
        margin-top: -5px;
      }
    }
  }

  ul li > a {
    font-size: 16px;
    height: $topbar-height;
  }

  ul li.ofn-logo > a {
    display: table-cell;
    vertical-align: middle;
  }

  ul .nav-primary {
    @include headingFont;
    text-transform: uppercase;
    font-weight: 300;
    font-size: 16px;
  }

  .joyride-tip-guide .button {
    text-shadow: none;
  }
}

// Mobile Menu

.tab-bar {
  background-color: white;
  border-bottom: 1px solid $light-grey-transparency;
  height: $mobile-nav-height;
  position: fixed;
  width: 100%;
  z-index: 190; // Above cart sidebar and shaded overlay

  .cart-span {
    background-color: #f4704c;
    padding: 13px;

    a,
    span {
      color: white;
      display: inline-block;
    }

    .count {
      position: relative;

      img {
        margin-left: 2px;
        width: 26px;
      }

      span {
        background-color: white;
        border-radius: 20px;
        color: #f4704c;
        font-size: 12px;
        line-height: 16px;
        position: absolute;
        right: -10px;
        text-align: center;
        top: -9px;
        width: 16px;
      }
    }
  }
}

.off-canvas-wrap {
  overflow: initial;
}

.off-canvas-list li.language-switcher ul li {
  list-style-type: none;
  padding-left: 0.5em;
}

.off-canvas-wrap.move-right .tab-bar .menu-icon {
  @include box-shadow(inset 0 0 6px 2px rgba(0, 0, 0, 0.5));
}

.off-canvas-wrap .tab-bar .menu-icon {
  @include box-shadow(none);
  text-indent: 0;
}

.tab-bar .ofn-logo {
  padding: 9px 0 0 9px;
}

// Leave space for tab bar, in screens smaller than large.
[role="main"] {
  margin-top: 2.8em;

  @media  #{$large-up} {
    margin-top: 0;
  }
}

.top-bar .ofn-logo img {
  height: auto;
  max-height: 44px;
}

.left-off-canvas-menu {
  background-color: white;
}

.off-canvas-wrap ul.off-canvas-list {
  font-size: 0.875rem;

  .li-menu {
    @include headingFont;

    font-size: 1rem;

    a {
      color: rgba(0, 0, 0, 0.9);
    }
  }

  li a {
    color: rgba(0, 0, 0, 0.9);

    &:hover {
      background-color: transparent;
      color: $brand-colour;
    }
  }
}

.off-canvas-wrap ul.off-canvas-list i {
  font-size: 1.5rem;
  margin-right: 0.25rem;
}

// Responsive

@media screen and (max-width: 1450px) {
  nav .top-bar-section {
    ul li a,
    .has-dropdown > a {
      padding: 0 ($topbar-height * 0.125) !important;
    }
  }
}

@media screen and (min-width: 1025px) {
  body.off-canvas {
    // padding required to placehold for fixed menu bar
    padding-top: $topbar-height;
  }
}

@media screen and (max-width: 1025px) {
  body.off-canvas {
    // padding required to placehold for fixed menu bar
    padding-top: 0;
  }
}