HBM/md-components

View on GitHub
src/scss/textfield.scss

Summary

Maintainability
Test Coverage

/**
 * http://www.google.com/design/spec/components/text-fields.html
 */
$font-big: 16px;
$font-small: 12px;
$margin-top: 16px;
$transition-function: cubic-bezier(0.25, 0.8, 0.25, 1);
$transition-duration: 0.25s;
$error-color: $color-textfield-error;

.mdc-Textfield {
  display: block;
}

.mdc-Textfield-label {
  order: 1;
  display: block;
  font-size: $font-big;
  color: $color-textfield-label;
  transform: translate3d(0, 24px, 0);
  transform-origin: left top;
  transition: $transition-function $transition-duration;
  pointer-events: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: $margin-top;
  margin-bottom: 6px;
  height: 18px;
}

.mdc-Textfield--nolabel .mdc-Textfield-label {
  display: none;
}

.mdc-Textfield-input {
  line-height: 1.5;
  background: transparent;
  order: 2;
  color: $color-textfield-input;
  width: 100%;
  display: block;
  border-radius: 0;
  font-size: $font-big;
  outline: 0;
  border: none;
  border-bottom: 1px solid $color-textfield-border;
  transition: border-bottom-color $transition-duration;
  padding: 0;
  box-sizing: content-box;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.mdc-Textfield--nolabel .mdc-Textfield-input {
  margin-top: $margin-top;
}

.mdc-Textfield-icon-wrapper {
  display: flex;
}

.mdc-Textfield-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.mdc-Textfield-suffix {
  position: absolute;
  top: 40px;
  right: 0;
  font-size: $font-big;
  color: $color-textfield-suffix;
}

.mdc-Textfield-suffix--dense {
  top: 30px;
  font-size: 13px;
}

.mdc-Textfield-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  margin-top: 22px;
}

.mdc-Textfield--nolabel .mdc-Textfield-icon {
  margin-top: 0;
}

.mdc-Textfield-label--dense {
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  transform: translate3d(0, 22px, 0);
}

.mdc-Textfield-input--dense {
  font-size: 13px;
  margin-bottom: 4px;
  padding-bottom: 4px;
}

.mdc-Textfield-input[readonly] {
  color: rgba(0, 0, 0, 0.38);
  border-bottom: 1px dashed rgba(0, 0, 0, 0.42);
}

.mdc-Textfield-input[readonly] ~ .mdc-Textfield-label {
  color: rgba(0, 0, 0, 0.38);
}

.mdc-Textfield-input:disabled {
  background-color: transparent;
  color: $color-textfield-input--disabled;
  border-bottom: 1px dotted $color-textfield-border--disabled;
}

.mdc-Textfield-input:not([readonly]):focus {
  border-bottom-color: $color-textfield-border--focus;
  box-shadow: 0 1px 0 0 $color-textfield-border--focus;
}

.mdc-Textfield-input:focus ~ .mdc-Textfield-label,
.mdc-Textfield-label--floatup {
  transform: translate3d(0, 0, 0);
  font-size: $font-small;
}

.mdc-Textfield-input:not([readonly]):focus ~ .mdc-Textfield-label:not(.mdc-Textfield-error) {
  color: $color-textfield-input--focus;
}

.mdc-Textfield:not(.mdc-Textfield--nolabel) .mdc-Textfield-input:not(:focus)::-webkit-input-placeholder {
  color: transparent;
}

.mdc-Textfield:not(.mdc-Textfield--nolabel) .mdc-Textfield-input:not(:focus)::-moz-placeholder {
  color: transparent;
}

.mdc-Textfield:not(.mdc-Textfield--nolabel) .mdc-Textfield-input:not(:focus):-ms-input-placeholder {
  color: transparent;
}

.mdc-Textfield-input--error {
  border-bottom-color: $error-color;
}

.mdc-Textfield-input--error:not([readonly]):focus {
  border-bottom-color: $error-color;
  box-shadow: 0 1px 0 0 $error-color;
}

.mdc-Textfield-label--floatup {
  color: $color-textfield-label--floatup;
}

.mdc-Textfield-char-counter {
  color: $color-textfield-charcounter;
}

.mdc-Textfield-states {
  order: 3;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  font-size: $font-small;
  min-height: 18px;
}

.mdc-Textfield-error {
  color: $error-color;
}