Skip to content

A platform for community discussion. Free, open, simple.

6.3 KB
Raw Blame
@use "lib/viewport";

@keyframes code-login-form-dice-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }

  50% {
    transform: rotate(180deg) scale(1.2);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes code-login-form-step-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.code-login-form {
  display: flex;
  flex-direction: column;
  gap: 1em;

  // No waving-hand icon here, so drop the welcome header's icon grid.
  .login-welcome-header {
    display: block;

    // Keep a trailing emoji/short word from orphaning onto its own line.
    .login-title {
      text-wrap: pretty;
    }
  }

  &__email-step {
    display: flex;
    flex-direction: column;
    gap: 1em;
  }

  &__code-step,
  &__second-factor-step,
  &__account-details-step,
  &__user-fields-step,
  &__signup-details-step,
  &__pending-approval-step {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1em;

    // Ease each step in so advancing through the flow doesn't snap abruptly.
    @media (prefers-reduced-motion: no-preference) {
      animation: code-login-form-step-in 0.25s ease;
    }
  }

  &__account-details-step,
  &__user-fields-step {
    .user-fields {
      align-self: stretch;
      margin-top: 0.5em;
    }
  }

  &__account-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-self: stretch;
    gap: 1em 0.5em;

    &.--with-username-generator {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .code-login-form__username-field {
      display: grid;
      grid-template-columns: subgrid;
      grid-column: 1 / -1;
      gap: 0.25em 0.5em;

      > label,
      > .code-login-form__field-instructions,
      > .code-login-form__error {
        grid-column: 1 / -1;
      }
    }

    .code-login-form__username-input {
      display: contents;
    }

    .code-login-form__name-field {
      grid-column: 1 / -1;
    }

    .code-login-form__password-field,
    .code-login-form__create-password {
      grid-column: 1;
    }

    .code-login-form__password-field input {
      width: 100%;
      min-width: 0;
    }
  }

  &__name-field {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    gap: 0.25em;
  }

  // Outweigh the base input[type="text"] margin-bottom so the name field's
  // instructions sit as close to the input as the username field's do.
  &__name[type="text"] {
    width: 100%;
    margin: 0;
  }

  &__password-field {
    align-self: stretch;
    width: 100%;
    margin: 0;
  }

  &__new-account {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: stretch;
    gap: 1em;
    padding: 1em 0;
  }

  &__avatar {
    position: relative;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 0;

    .avatar {
      display: block;
    }
  }

  &__avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 144px;
    height: 144px;
    border-radius: 50%;
    background: var(--primary-low);
    color: var(--primary-medium);

    .d-icon {
      width: 50%;
      height: 50%;
    }
  }

  &__avatar-edit {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    border-radius: 50%;
    background: var(--tertiary);
    color: var(--secondary);

    .d-icon {
      margin: 0;
    }
  }

  &__username-field {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    gap: 0.25em;
  }

  &__username-input {
    // The regenerate button sits beside the input rather than inside it, so it
    // doesn't compete with password managers for the field's trailing edge.
    display: flex;
    align-self: stretch;
    gap: 0.5em;

    // Outweigh the base input[type="text"] margin-bottom so the input and the
    // regenerate button beside it stay the same height.
    input[type="text"] {
      flex: 1 1 auto;
      min-width: 0;
      width: auto;
      margin: 0;
    }
  }

  &__new-account-username {
    width: 100%;

    // Crossfade the text while a regenerated username is on its way, so the
    // new name fades in rather than snapping into place.
    @media (prefers-reduced-motion: no-preference) {
      transition: color 0.2s ease;

      &.--swapping {
        color: transparent;
      }
    }
  }

  &__username-regen {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;

    // The dice glyph is wider than it is tall, so at the default 1em it
    // renders visually smaller than square icons.
    .d-icon {
      font-size: var(--font-up-2);
    }

    // One cycle matches the minimum rolling duration the component holds, so
    // the spin completes cleanly on fast responses and keeps going on slow
    // ones instead of freezing mid-roll.
    @media (prefers-reduced-motion: no-preference) {
      &.--rolling .d-icon {
        animation: code-login-form-dice-roll 0.4s ease infinite;
      }
    }
  }

  &__continue-to-site {
    align-self: stretch;
  }

  &__title {
    margin: 0;
  }

  &__instructions {
    margin: 0;
    color: var(--primary-high);
  }

  &__field-instructions {
    font-size: var(--font-down-1);
    color: var(--primary-medium);
    overflow-wrap: anywhere;
  }

  &__error {
    color: var(--danger);

    &:empty {
      display: none;
    }
  }

  &__notice {
    margin: 0;
    color: var(--success);
  }

  &__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
  }

  &__email-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em;
  }
}

// Keep the disclaimer from hugging the continue button it follows.
.code-login-form + .signup-page-cta__disclaimer {
  margin-top: 1.5em;
}

// Scoped to the passwordless signup flow so login and regular signup are untouched.
@include viewport.until(md) {
  .signup-page .signup-body.passwordless-signup {
    padding: 1.5rem;

    // Drop the heading's own padding so it lines up with the form below it.
    .login-welcome-header {
      padding: 0;
      margin-bottom: 1rem;
    }

    .code-login-form__email-actions {
      align-self: stretch;
    }

    .code-login-form__continue,
    .code-login-form__verify {
      width: 100%;
    }
  }
}