HBM/md-components

View on GitHub
src/scss/table.scss

Summary

Maintainability
Test Coverage

.mdc-Table-responsive {
  // https://github.com/twbs/bootstrap/blob/9057d8da164bed683f49d30c6414753dad41de3e/scss/_tables.scss#L175-L179
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

.mdc-Table-edit {
  position: relative;
}

.mdc-Table-edit-container {
  background-color: #fafafa;
  position: absolute;
  left: 0;
  right: 0;
  top: -14px;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25);
  padding: 0 24px;
}

.mdc-Table-body-row-cell-edit-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.mdc-Table-edit-icon {
  margin-left: auto;
}

// override textfield font size
.mdc-Table-edit-container .mdc-Textfield-input {
  font-size: 13px;
}

.mdc-Table {
  width: 100%;
  border-collapse: collapse;

  &-head {
    color: rgba(0, 0, 0, 0.54);
    font-size: 12px;

    &-row {
      height: 56px;

      &-cell {
        font-weight: 500;
        padding: 0 28px;
        border-bottom: 1px solid #e1e1e1;

        &:first-child {
          padding-left: 24px;
        }

        &:last-child {
          padding-right: 24px;
        }

        &-button {
          // remove button styles
          background: none;
          border: none;
          outline: none;

          // align arrow icon and cell content
          display: flex;
          align-items: center;
          cursor: pointer;
          justify-content: flex-end;
          color: rgba(0, 0, 0, 0.87);

          &-arrow {
            fill: rgba(0, 0, 0, 0.87);
            transition: transform 0.15s ease-in-out;
            margin-right: 5px;

            &--ascending {
              transform: rotate3d(0, 0, 1, 0deg);
            }

            &--descending {
              transform: rotate3d(0, 0, 1, 180deg);
            }
          }
        }
      }
    }
  }

  &-body {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.87);

    &-row {
      height: 48px;

      &.is-selected {
        background-color: #f5f5f5;
      }

      &:hover,
      &.is-selected:hover {
        background-color: #eee;
      }

      &-cell {
        padding: 0 28px;
        border-top: 1px solid #e1e1e1;

        &:first-child {
          padding-left: 24px;
        }

        &:last-child {
          padding-right: 24px;
        }
      }
    }
  }

  &-footer {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    // set font-size and color for whole footer
    font-size: 12px;
    color: rgba(0, 0, 0, 0.54);

    // override Select component styles explicitly
    .mdc-Select {
      font-size: 12px;
      flex: none;
      color: rgba(0, 0, 0, 0.54);
      margin-right: 32px;

      &-body {
        border-bottom: none;
        padding-bottom: 5px;
      }
    }

    &-xOfY {
      margin-right: 32px;
    }

    &-rowsPerPage {
      margin-right: 40px;
    }
  }
}

.mdc-Table--dense .mdc-Table-head-row {
  height: 48px;
}

.mdc-Table--dense .mdc-Table-body-row {
  height: 40px;
}

.mdc-Table--dense .mdc-Checkbox {
  height: 40px;
}

.mdc-Table--dense .mdc-Checkbox-icon {
  padding: 0;
}