src/components/Form/Field/Field.scss

Summary

Maintainability
Test Coverage
.field {
  border-left: 0.75rem solid transparent;
  margin-left: -0.75rem;
  margin-bottom: 8rem;
  max-width: 64rem;

  &.with-comments {
    border-left: 0.75rem solid $eapp-grey-light;
    padding-left: 2rem;
    margin-left: -2.7rem;
  }

  > .anchor {
    display: block;
    margin-top: -3rem;
    padding-top: 3rem;
  }

  > .title {
    display: inline;
    max-width: 64rem;
    line-height: 1.5;
    font-family: $eapp-serif;
    font-weight: 700;

    &.label {
      font-family: inherit;
      font-weight: normal;
      line-height: 1.6;
      margin-top: 0;
    }

    &.h2 {
      font-size: 2.5rem;
    }

    &.h3 {
      font-size: 2rem;
      margin-top: 1.5rem;
    }

    &.h4 {
      font-size: 1.7rem;
    }

    &.h5 {
      font-size: 1.3rem;
    }

    &.h6 {
      font-size: 1rem;
    }
  }

  > .icon {
    display: inline-block;
    margin-left: 1rem;

    > .toggle {
      display: inline;
      line-height: 1.3;

      &.label {
        line-height: 1.6;
      }

      &.h2 {
        font-size: 2.3rem;
        line-height: 1.6;
      }

      &.h3 {
        font-size: 1.85rem;
        line-height: 1.7;
      }

      &.h4 {
        font-size: 1.7rem;
        line-height: 1.7;
      }

      &.h5 {
        font-size: 1.6rem;
        line-height: 1.6;
      }

      &.h6 {
        font-size: 1.5rem;
        line-height: 1.7;
      }

      svg {
        display: inline-block;
        position: relative;
        top: -0.3rem;
        height: 1.6rem;
        width: 1.6rem;
        overflow: visible;
        vertical-align: middle;

        .eapp-help-icon {
          transition: fill 0.3s;
        }

        .eapp-help-icon {
          fill: $eapp-blue-light;
        }
      }

      &:hover,
      &.active {
        svg {
          transform: scaleX(1.2) scaleY(1.2);
          transition: transform 0.3s;
        }
      }
    }
  }

  > .table {
    display: table;
    width: 100%;
    margin-top: 0.25rem;

    &.expand {
      width: 100%;
    }

    > .content {
      display: table-row;

      > .component {
        display: table-cell;
        width: 100%;
        max-width: 64rem;

        > div {
          max-width: 64rem;
        }

        > label {
          display: block;
          position: initial;
          line-height: 1.6;

          // If `no-toggle` is applied to the component then the `z-index` is reset.
          // see Form.scss.
          > input[type='radio'],
          > input[type='checkbox'] {
            max-width: 0;
            z-index: -1;
          }
        }

        .flags {
          text-align: right;
          clear: both;

          .block > label {
            margin-right: 0;
            padding-right: 0;
          }
        }

        > .comments {
          padding-bottom: 1rem;
        }

        > .comments-button {
          // This cannot be inline-block because it will wrap on larger screens.
          display: block;

          i {
            margin-left: 1rem;

            &.fa-times-circle {
              color: $eapp-red;
            }
          }
        }
      }
    }

    > .messages {
      display: table-row;

      > .message {
        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
          margin-top: 0;
          font-family: $eapp-sans;
          padding: 0;
        }

        a,
        a:visited,
        a:active {
          padding: 1.5rem 0;
        }

        a:hover {
          color: #003960;
        }

        > i {
          display: block;
          position: relative;
          top: -1.3rem;
          left: -3.9rem;
          height: 1.6rem;
          width: 1.6rem;
          color: #fff;
          font-size: 1.3rem;
          line-height: 1.6rem;
          text-align: center;
          background: $eapp-blue-light;
          border-radius: 50%;
        }

        em {
          line-height: 1.6;
        }

        .close {
          display: block;
          margin-top: 1rem;
        }
      }
    }
  }
}

// Handle when multiplicity
.field {
  .field {
    margin-bottom: 0;

    > .table > .content > .component {
      width: 100%;
      max-width: auto !important;
    }

    > .messages > .message {
      width: 100%;
    }
  }
}

// Handle first of types
.field:first-of-type > .title {
  margin-top: 0;
}

.modal-open .field .icon {
  z-index: -1;
}

.no-margin-bottom {
  margin-bottom: 0 !important;
}

.field.usa-form-control,
.usa-form-control {
  margin-bottom: 1rem;
}

@media all and (max-width: 1200px) {
  .field > .table,
  .field > .table > .content,
  .field > .table > .content > .component {
    display: block;
  }
}