presidential-innovation-fellows/hack-the-paygap

View on GitHub
scss/web-design-standards/_scss/elements/_inputs.scss

Summary

Maintainability
Test Coverage
// Block form elements
input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="file"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"],
input[type="week"],
textarea,
select  {
  appearance: none;
  border: 1px solid $color-gray;
  border-radius: 0;
  box-sizing: border-box;
  color: $color-base; // standardize on firefox 
  display: block;
  font-size: $base-font-size;
  margin: 0.2em 0;
  max-width: $input-max-width;
  outline: none;
  padding: 1rem 0.7em;
  width: 100%;

  &:focus, 
  &.usa-input-focus {
    box-shadow: $focus-shadow;
  }

  &.usa-input-success {
    border: 3px solid $color-green-light;
  }
}

.usa-input-error {
  border-left: 4px solid $color-secondary-dark;
  margin-top: 3rem;
  padding-bottom: 0.8rem;
  padding-left: 1.5rem;
  padding-top: 0.8rem;
  position: relative;
  right: 1.9rem;
  
  input {
    border: 3px solid $color-secondary-dark;
    width: calc(100% + 1.5rem);
  }
  
  label {
    margin-top: 0;
  }
}

.usa-input-error-label {
  display: block;
  font-size: $base-font-size;
  font-weight: $font-bold;
}

.usa-input-error-message {
  color: $color-secondary-dark;
  display: block;
  font-size: $base-font-size;
  font-weight: $font-bold;
  padding-bottom: 3px;
  padding-top: 3px;
}

label {
  display: block;
  margin-top: 3rem;
  max-width: $input-max-width;
}

textarea {
  height: 16rem;
}

select {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  background-color: $color-white;
  background-image: url('../img/arrow-down.png');
  background-image: url('../img/arrow-down.svg');
  background-position: right 1.3rem center;
  background-repeat: no-repeat;
  background-size: 1.3rem;
}

legend {
  font-size: $h2-font-size;
  font-weight: $font-bold;
}

.usa-fieldset-inputs {
  label {
    margin-top: 0;
  }
}

// Hint text

.usa-form-hint {
  color: $color-gray-medium;
  font-family: $font-sans;
  margin-bottom: 0;
}

/**
 * Custom checkboxes
 */

input[type="checkbox"],
input[type="radio"] {
  @include sr-only();

  .lt-ie9 & {
    border: 0;
    float: left;
    margin: 0.4em 0.4em 0 0;
    position: static;
    width: auto;
  }
}

input[type="checkbox"] + label,
input[type="radio"] + label {
  cursor: pointer;
  font-weight: 400;
  margin-bottom: 0.5em;
}

input[type="checkbox"] + label::before,
input[type="radio"] + label::before {
  background: white;
  border-radius: $border-radius;
  box-shadow: 0 0 0 1px $color-gray-medium;
  content: '\a0';
  display: inline-block;
  height: 1.8rem;
  line-height: 0.8;
  margin-right: 0.6em;
  text-indent: 0.15em;
  vertical-align: 0.2em;
  width: 1.8rem;
}

input[type="radio"] + label::before {  
  box-shadow: 0 0 0 2px $color-white, 0 0 0 3px $color-gray-medium;
  height: 1.6rem;  
  width: 1.6rem;  
}

input[type="radio"] + label::before {
  border-radius: 100%;
}

input[type="checkbox"]:checked + label::before,
input[type="radio"]:checked + label::before {
  background-color: $color-primary;
  box-shadow: 0 0 0 1px $color-primary;
}

input[type="radio"]:checked + label::before {
  box-shadow: 0 0 0 2px $color-white, 0 0 0 4px $color-primary; 
}

input[type="radio"]:focus + label::before {
  box-shadow: 0 0 0 2px $color-white, 0 0 0 4px $color-primary, 0 0 3px 4px $color-focus, 0 0 7px 4px $color-focus;
}

input[type="checkbox"]:checked + label::before {
  background-image: url('../img/correct8.png');
  background-image: url('../img/correct8.svg');
  background-position: 50%;
  background-repeat: no-repeat;
}

input[type="checkbox"]:focus + label::before {
  box-shadow: 0 0 0 1px $color-white, 0 0 0 3px $color-primary;
}

input[type="checkbox"]:disabled + label {
  color: $color-gray;
}

input[type="checkbox"]:disabled + label::before,
input[type="radio"]:disabled + label::before {
  background: $color-gray-lighter;
  box-shadow: 0 0 0 1px $color-gray-light;
  cursor: not-allowed;
}

// Range inputs

input[type=range] {
  -webkit-appearance: none;
  border: none;
  padding-left: 0;
  width: 100%;
}

input[type=range]:focus {
  box-shadow: none;
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  background: $color-gray-light;
  border: 1px solid $color-gray-medium;
  cursor: pointer;
  height: 1.2rem;
  width: 100%;
}

input[type=range]::-moz-range-track {
  background: $color-primary;
  border: 1px solid $color-gray-medium;
  cursor: pointer;
  height: 1.2rem;
  width: 100%;
}

input[type=range]::-ms-track {
  background: transparent;
  color: transparent;
  cursor: pointer;
  height: 1.2rem;
  width: 100%;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: 1px solid $color-gray-medium;
  height: 2.2rem;
  border-radius: 1.5rem;
  background: $color-gray-lightest;
  cursor: pointer;
  margin-top: -.65rem;  
  width: 2.2rem;
}

input[type=range]::-moz-range-thumb {
  background: $color-gray-lightest;
  border: 1px solid $color-gray-medium;
  border-radius: 1.5rem;
  cursor: pointer;
  height: 2.2rem;
  width: 2.2rem;
}

input[type=range]::-ms-thumb {
  background: $color-gray-lightest;
  border: 1px solid $color-gray-medium;
  border-radius: 1.5rem;
  cursor: pointer;
  height: 2.2rem;
  width: 2.2rem;
}

input[type=range]::-ms-fill-lower {
  background: $color-gray-light;
  border: 1px solid $color-gray-medium;
  border-radius: 2rem;
}

input[type=range]::-ms-fill-upper {
  background: $color-gray-light;
  border: 1px solid $color-gray-medium;
  border-radius: 2rem;
}

input[type=range]:focus::-webkit-slider-thumb {
  border: 2px solid $color-focus;
}

input[type=range]:focus::-moz-range-thumb {
  border: 2px solid $color-focus;
}

input[type=range]:focus::-ms-thumb {
  border: 2px solid $color-focus;
}

// Memorable dates

.usa-date-of-birth {
  label {
    margin-top: 0;
  }

  input[type=number]::-webkit-inner-spin-button, 
  input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0; 
  }

  input[type=number] {
    -moz-appearance: textfield;
  }
}

.usa-form-group-day, 
.usa-form-group-month, 
.usa-form-group-year {
  clear: none;
  float: left;
  margin-right: 1.5rem;
  width: 5rem;
}

.usa-form-group-year {
  width: 7rem;
}