HBM/md-components

View on GitHub
src/scss/select.scss

Summary

Maintainability
Test Coverage
.mdc-Select {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.mdc-Select-label {
  font-size: 12px;
  padding: 0 0 8px;
  color: rgba($blue-dark, 0.6);
}

.mdc-Select-body {
  border-bottom: 1px solid $black-012;
  padding-bottom: 4px;
  text-align: left;
  outline: 0;
  font-size: 16px;
}

// no label
.mdc-Select-input + .mdc-Select-body {
  margin-top: 40px;
}

// with label
.mdc-Select-input + .mdc-Select-label {
  margin-top: 14px;
}

// with label
.mdc-Select--dense > .mdc-Select-input + .mdc-Select-label {
  margin-top: 8px;
  padding-bottom: 4px;
}

.mdc-Select--dense .mdc-Select-body {
  font-size: 13px;
}

// https://material.google.com/style/color.html#color-text-background-colors
.mdc-Select-body:disabled {
  color: rgba(0, 0, 0, 0.38);
}

// no label
.mdc-Select--dense > .mdc-Select-input + .mdc-Select-body {
  margin-top: 30px;
}

.mdc-Select-input {
  position: absolute;
  opacity: 0;
  z-index: -1;
}

.mdc-Select-input:focus ~ .mdc-Select-label {
  color: $blue-dark;
}

.mdc-Select-input:focus ~ .mdc-Select-body {
  border-bottom-color: $blue-dark;
  box-shadow: 0 1px 0 0 $blue-dark;
}

.mdc-Select-placeholder {
  color: rgba(0, 0, 0, 0.54);
}

.mdc-Select-caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border-top: 4px dashed;
  border-top-color: rgba(0, 0, 0, 0.24);
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

/**
 * Select-list is of type <ul />
 */
.mdc-Select-list {
  margin: 0;
  z-index: 105;
  position: fixed;
  background: #fff;
  padding: 0;
  border-radius: 2px;
  box-shadow: 0 2px 40px rgba(0, 0, 0, 0.4);
  overflow-y: auto;
  font-size: 16px;

  /**
   * max-height is equal to 5 elements + margin top and margin bottom
   */
  max-height: 256px;

  /**
   * fix: Firefox ignores padding when using overflow:scroll
   * https://stackoverflow.com/questions/29986977/firefox-ignores-padding-when-using-overflowscroll
   */
  :first-child {
    margin-top: 8px;
  }

  :last-child {
    margin-bottom: 8px;
  }
}

.mdc-Select--dense .mdc-Select-list {
  font-size: 13px;
  max-height: 196px;
}

.mdc-Select.is-insideTable {
  padding-top: 0;
  padding-bottom: 0;
}

.mdc-Select.is-insideTable .mdc-Select-body {
  border-bottom: none;
  font-size: 13px;
  padding-bottom: 0;
}

.mdc-Select.is-insideTable .mdc-Select-input + .mdc-Select-body {
  margin-top: 0;
}

.mdc-Select.is-insideTable .mdc-Select-list {
  font-size: 13px;
  padding: 0;
  border: 1px solid lightgray;
  box-shadow: 0 3px 2px -1px rgba(0, 0, 0, 0.3);
  background: #f9f9f9;
}

.mdc-Select.is-insideTable .mdc-Select-body:focus {
  box-shadow: none;
}

/**
 * Select-listItem is of type <li />
 */
.mdc-Select-listItem {
  list-style: none;
  margin: 0;
  padding: 0;
  color: initial;
  text-decoration: none;
  height: 48px;
  display: flex;
  align-items: center;
  outline: 0;
}

.mdc-Select--dense .mdc-Select-listItem {
  height: 36px;
}

.mdc-Select-listItem.is-focused,
.mdc-Select-listItem:hover,
.mdc-Select-listItem:focus {
  background: #eee;
}

.mdc-Select-helper {
  min-height: 18px;
  margin-top: 8px;
  font-size: 12px;
}

.mdc-Select-helper--dense {
  margin-top: 4px;
}

.mdc-Select-helper--error {
  color: #f44336;
}