openfoodfoundation/openfoodnetwork

View on GitHub
app/webpacker/css/admin_v3/components/dropdown.scss

Summary

Maintainability
Test Coverage
#content-header .ofn-drop-down {
  border: none;
  background-color: $spree-blue;
  color: #fff;
  float: none;
  margin-left: 3px;
}

.ofn-drop-down {
  .dropdown-content {
    display: none;
  }

  .toggle-off {
    display: none;
  }

  &:active:not(.disabled),
  &:focus:not(.disabled) {
    .dropdown-content {
      display: inline-block;
    }
  }
}

.ofn-drop-down:hover,
.ofn-drop-down.expanded {
  border: 1px solid #adadad;
  color: #575757;
}

@mixin ofn-drop-down-style {
  padding: 7px 15px;
  border-radius: 3px;
  border: 1px solid #d4d4d4;
  background-color: #f5f5f5;
  display: block;
  color: #828282;
  cursor: pointer;
  -moz-user-select: none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  text-align: center;
  margin-right: 10px;

  &.disabled {
    opacity: 0.5;
    pointer-events: none;

    &:hover {
      cursor: default;
      border-color: #d4d4d4;
      color: #828282;
    }
  }
}

.ofn-drop-down-with-prepend {
  display: flex;

  &.right {
    float: right;
  }

  .ofn-drop-down {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .ofn-drop-down-prepend {
    @include ofn-drop-down-style;

    border-right: none;
    margin-left: 0;
    margin-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    cursor: default;
  }
}

.ofn-drop-down {
  @include ofn-drop-down-style;

  position: relative;
  float: left;

  &.right {
    float: right;
    margin-right: 0px;
    margin-left: 10px;
  }

  &:hover,
  &.expanded {
    border: 1px solid #adadad;
    color: #575757;
  }

  > span {
    width: auto;
    font-weight: 600;
  }

  .menu {
    margin-top: 1px;
    position: absolute;
    float: none;
    top: 100%;
    left: 0px;
    padding: 5px 0px;
    border-radius: $border-radius;
    background-color: #ffffff;
    box-shadow: 1px 3px 10px #888888;
    z-index: 100;
    white-space: nowrap;

    .filter {
      padding-left: 5px;
      padding-right: 5px;
      position: relative;

      > input[type="text"] {
        border: 1px solid rgba(18, 18, 18, 0.1);
        width: 100%;
        padding-left: 30px;
        padding-top: 10px;
        padding-bottom: 10px;
        font-size: 13px;
        color: #454545;
      }

      &:after {
        content: "\f002";
        font-family: FontAwesome;
        position: absolute;
        left: 15px;
        top: 13px;
        color: #454545;
      }
    }

    .menu_item {
      margin: 0px;
      padding: 2px 10px;
      color: #454545;
      text-align: left;
      display: block;

      .check {
        display: inline-block;
        text-align: center;
        width: 40px;
        &:before {
          content: "\00a0";
        }
      }

      .name {
        display: inline-block;
        padding: 0px 15px 0px 0px;
      }

      &.selected {
        .check:before {
          content: "\2713";
        }
      }

      &.hidden {
        display: none;
      }
    }

    .menu_item:hover {
      background-color: #ededed;
    }
  }

  summary:after {
    content: "\f078";
    font-family: FontAwesome;
    position: relative;
    top: 3px;
    font-size: 13px;
  }


  &[open] >,
  details[open] > {
    summary:after {
      content: "\f077";
      font-family: FontAwesome;
    }
  }
}

.ofn-drop-down:not(.ofn-dropdown-v2) {
  > details {
    margin: -7px -15px;
    padding: 7px 15px;
  }

  > details > summary {
    display: inline-block;
    list-style: none;
    width: auto;
    margin: -8px -15px;
    padding: 8px 15px;

    &:after {
      position: relative;
      top: -1px;
      font-size: 12px;
    }
  }
}

.ofn-drop-down-v2 {
  border: 1px solid $lighter-grey;
  background-color: $lighter-grey;
  padding: 0px;
  line-height: normal;
  @include border-radius($border-radius);

  &:hover,
  &.expanded {
    border-color: $lighter-grey;
  }

  .ofn-drop-down-label {
    color: $near-black;
    padding: 10px;
    width: 235px;
    display: flex;
    justify-content: space-between;

    &:hover {
      color: $near-black;
    }

    .label {
      padding-right: 10px;
    }

    .icon-caret-down,
    .icon-caret-up {
      padding-right: 0px;
      &:before {
        display: none;
      }
      &:after {
        @include arrowDown;
      }
    }

    .icon-caret-up:after {
      transform: rotate(180deg);
    }
  }

  .menu {
    width: 100%;
  }

  .menu_items {
    max-height: 200px;
    overflow-y: scroll;

    .menu_item {
      margin-bottom: 5px;
      color: #454545;
      font-weight: 400;
      cursor: pointer;
      padding-top: 4px;
      padding-bottom: 5px;
      font-size: inherit;

      // Align checkbox and text
      & > * {
        vertical-align: middle;
      }
    }
  }

  .actions {
    margin-top: 5px;
    margin-right: 15px; // Compensate for scrollbar on menu_items
    padding: 2px 10px;

    &:hover {
      background-color: inherit;
    }
  }
}