HBM/md-components

View on GitHub
src/scss/list.scss

Summary

Maintainability
Test Coverage
/**
 * https://material.google.com/components/lists.html#lists-specs
 */

@import "./mixins";

.mdc-List {
  padding: 8px 0;
  margin: 0;
  list-style: none;
  background-color: white;
}

.mdc-List-row-text {
  flex-shrink: 1;
  min-width: 150px;
}

.mdc-List-row-text-primary {
  a {
    text-decoration: none; // no further default appearance (color -> client), but underline looks really odd as primary.
  }

  font-size: 16px;
  margin: 0;
  margin-bottom: 6px;
  font-weight: normal;
  padding: 0;
}

.mdc-List-row--oneline .mdc-List-row-text-primary {
  margin-bottom: 0;
}

.mdc-List-row--selectable {
  cursor: pointer;
}

.mdc-List-row--selectable:hover {
  background-color: #f5f5f5;
  transition: background-color 0.3s ease;
  outline: none;
}

.mdc-List-row {
  transition: background-color 0.3s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding-left: 16px;
  padding-right: 16px;

  /** This article suggest to increase padding for table and above
   * https://material.google.com/layout/metrics-keylines.html#metrics-keylines-keylines-spacing
   */
  @include medium {
    padding-left: 24px;
    padding-right: 24px;
  }

  text-decoration: none;
  width: 100%;
  color: inherit;
}

.mdc-List-row:focus {
  background-color: #e9e9e9;
  outline: none;
}

.mdc-List-row-text-secondary,
.mdc-List-row-text-subheader {
  font-size: 14px;
  font-weight: normal;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: inline-block;
  width: 100%;
  overflow: hidden;
}

.mdc-List-row-text-secondary {
  color: #808080;
}

.mdc-List-row--twoline {
  height: 72px;
}

.mdc-List-row--threeline {
  height: 88px;

  .mdc-List-row-text-secondary {
    margin-top: 2px;
  }
}

.mdc-List-row-icon-right {
  margin-left: auto;

  svg {
    float: right;
  }
}

.mdc-List-row-avatar {
  height: 56px;
  display: flex;
  align-items: center;

  // use wildcard since element is user defined and can be anything
  & > * {
    border-radius: 100%;
    width: 40px;
  }
}

.mdc-List-row-icon-left,
.mdc-List-row-icon-right,
.mdc-List-row-avatar {
  flex-shrink: 0;
  width: 56px;
}

/* Three line rows have top aligned icons */
.mdc-List-row.mdc-List-row--threeline {
  align-items: flex-start;

  .mdc-List-row-avatar,
  .mdc-List-row-text,
  .mdc-List-row-icon-right,
  .mdc-List-row-icon-left {
    margin-top: 12px;
  }

  .mdc-List-row-avatar {
    align-items: flex-start;
  }
}