Skip to content

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

UX: Use a single step-aware heading for email code signup (#41300)

Keegan Georgebbf18bff6a4b
diff --git a/app/assets/stylesheets/common/login/code-login-form.scss b/app/assets/stylesheets/common/login/code-login-form.scss
index c0735d0ae14..c23f000104f 100644
--- a/app/assets/stylesheets/common/login/code-login-form.scss
+++ b/app/assets/stylesheets/common/login/code-login-form.scss
@@ -17,6 +17,16 @@
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;
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 3487abc6eee..bc881431927 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2942,7 +2942,7 @@ en:
use_different_email: "Use a different email address"
use_password_instead: "Log in with your password instead"
email_me_code: "Email me a one-time login code"
- signup_title: "Join this community"
+ signup_title: "Create your account"
signup_instructions: "Enter your email address to join this community. We'll send you a code to confirm it and you'll be on your way!"
user_fields_title: "Almost done"
user_fields_instructions: "Just a few more details to finish creating your account."
diff --git a/frontend/discourse/app/components/code-login-form.gjs b/frontend/discourse/app/components/code-login-form.gjs
index 06713a8ac48..385503a1a97 100644
--- a/frontend/discourse/app/components/code-login-form.gjs
+++ b/frontend/discourse/app/components/code-login-form.gjs
@@ -8,9 +8,12 @@ import { service } from "@ember/service";
import { trustHTML } from "@ember/template";
import Form from "discourse/components/form";
import AvatarSelectorModal from "discourse/components/modal/avatar-selector";
+import PluginOutlet from "discourse/components/plugin-outlet";
import SecondFactorForm from "discourse/components/second-factor-form";
import SecurityKeyForm from "discourse/components/security-key-form";
import UserField from "discourse/components/user-field";
+import WelcomeHeader from "discourse/components/welcome-header";
+import lazyHash from "discourse/helpers/lazy-hash";
import valueEntered from "discourse/helpers/value-entered";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -115,6 +118,37 @@ export default class CodeLoginForm extends Component {
return this.step === "complete";
}
+ // Login has its own page heading; only signup needs a per-step one here.
+ get heading() {
+ if (!this.isSignup) {
+ return null;
+ }
+
+ switch (this.step) {
+ case "code":
+ return {
+ title: i18n("code_login.check_your_email"),
+ subtitle: this.codeInstructions,
+ };
+ case "user-fields":
+ return {
+ title: i18n("code_login.user_fields_title"),
+ subtitle: i18n("code_login.user_fields_instructions"),
+ };
+ case "complete":
+ return {
+ title: i18n("code_login.account_ready_title"),
+ subtitle: this.usernameEditable
+ ? i18n("code_login.account_ready_edit")
+ : null,
+ };
+ case "second-factor":
+ return { title: i18n("login.second_factor_title"), subtitle: null };
+ default:
+ return { title: i18n("code_login.signup_title"), subtitle: null };
+ }
+ }
+
get continueDisabled() {
if (this.verifying) {
return true;
@@ -515,6 +549,28 @@ export default class CodeLoginForm extends Component {
<template>
<div class="code-login-form">
+ {{#if this.heading}}
+ {{! Plugins can replace this via the signup-heading outlet. }}
+ <PluginOutlet
+ @name="signup-heading"
+ @outletArgs={{lazyHash
+ step=this.step
+ context=@context
+ title=this.heading.title
+ subtitle=this.heading.subtitle
+ }}
+ >
+ <WelcomeHeader
+ id="create-account-title"
+ @header={{this.heading.title}}
+ >
+ {{#if this.heading.subtitle}}
+ <p class="login-subheader">{{this.heading.subtitle}}</p>
+ {{/if}}
+ </WelcomeHeader>
+ </PluginOutlet>
+ {{/if}}
+
{{#if this.isEmailStep}}
{{#if this.isSignup}}
<p class="code-login-form__instructions">
@@ -560,12 +616,14 @@ export default class CodeLoginForm extends Component {
</Form>
{{else if this.isCodeStep}}
<div class="code-login-form__code-step">
- <h2 class="code-login-form__title">
- {{i18n "code_login.check_your_email"}}
- </h2>
- <p class="code-login-form__instructions">
- {{this.codeInstructions}}
- </p>
+ {{#unless this.isSignup}}
+ <h2 class="code-login-form__title">
+ {{i18n "code_login.check_your_email"}}
+ </h2>
+ <p class="code-login-form__instructions">
+ {{this.codeInstructions}}
+ </p>
+ {{/unless}}
{{#each this.otpGenerationArray as |generation|}}
<DOtp
@@ -609,14 +667,16 @@ export default class CodeLoginForm extends Component {
</div>
{{else if this.isCompleteStep}}
<div class="code-login-form__complete-step">
- <h2 class="code-login-form__title">
- {{i18n "code_login.account_ready_title"}}
- </h2>
- {{#if this.usernameEditable}}
- <p class="code-login-form__instructions">
- {{i18n "code_login.account_ready_edit"}}
- </p>
- {{/if}}
+ {{#unless this.isSignup}}
+ <h2 class="code-login-form__title">
+ {{i18n "code_login.account_ready_title"}}
+ </h2>
+ {{#if this.usernameEditable}}
+ <p class="code-login-form__instructions">
+ {{i18n "code_login.account_ready_edit"}}
+ </p>
+ {{/if}}
+ {{/unless}}
<div class="code-login-form__new-account">
<button
@@ -672,12 +732,14 @@ export default class CodeLoginForm extends Component {
</div>
{{else if this.isUserFieldsStep}}
<div class="code-login-form__user-fields-step">
- <h2 class="code-login-form__title">
- {{i18n "code_login.user_fields_title"}}
- </h2>
- <p class="code-login-form__instructions">
- {{i18n "code_login.user_fields_instructions"}}
- </p>
+ {{#unless this.isSignup}}
+ <h2 class="code-login-form__title">
+ {{i18n "code_login.user_fields_title"}}
+ </h2>
+ <p class="code-login-form__instructions">
+ {{i18n "code_login.user_fields_instructions"}}
+ </p>
+ {{/unless}}
<div class="user-fields">
{{#each this.userFields as |f|}}
diff --git a/frontend/discourse/app/templates/signup.gjs b/frontend/discourse/app/templates/signup.gjs
index 350640ad5c7..96eb22c1c8f 100644
--- a/frontend/discourse/app/templates/signup.gjs
+++ b/frontend/discourse/app/templates/signup.gjs
@@ -50,22 +50,28 @@ export default <template>
}}
>
{{#unless @controller.skipConfirmation}}
+ {{! Code signup renders its own heading inside CodeLoginForm. }}
{{#unless @controller.showCodeSignupForm}}
<SignupProgressBar @step={{@controller.progressBarStep}} />
- {{/unless}}
- <WelcomeHeader
- id="create-account-title"
- @header={{if
- @controller.showCodeSignupForm
- (i18n "code_login.signup_title")
- (i18n "create_account.header_title")
- }}
- >
<PluginOutlet
- @name="create-account-header-bottom"
- @outletArgs={{lazyHash showLogin=(routeAction "showLogin")}}
- />
- </WelcomeHeader>
+ @name="signup-heading"
+ @outletArgs={{lazyHash
+ step="form"
+ context="signup"
+ title=(i18n "create_account.header_title")
+ }}
+ >
+ <WelcomeHeader
+ id="create-account-title"
+ @header={{i18n "create_account.header_title"}}
+ >
+ <PluginOutlet
+ @name="create-account-header-bottom"
+ @outletArgs={{lazyHash showLogin=(routeAction "showLogin")}}
+ />
+ </WelcomeHeader>
+ </PluginOutlet>
+ {{/unless}}
{{/unless}}
{{#if @controller.showCodeSignupForm}}
<CodeLoginForm
diff --git a/frontend/discourse/tests/integration/components/code-login-form-test.gjs b/frontend/discourse/tests/integration/components/code-login-form-test.gjs
index 3e8f6d78669..9539d4c0ca4 100644
--- a/frontend/discourse/tests/integration/components/code-login-form-test.gjs
+++ b/frontend/discourse/tests/integration/components/code-login-form-test.gjs
@@ -99,4 +99,41 @@ module("Integration | Component | CodeLoginForm", function (hooks) {
assert.dom(".code-login-form__email-step").exists();
assert.form().field("email").hasValue("[email protected]");
});
+
+ test("signup context shows a single step-aware heading that is replaced, not stacked", async function (assert) {
+ stubCodeRequest();
+
+ await render(<template><CodeLoginForm @context="signup" /></template>);
+
+ assert.dom(".login-welcome-header").exists({ count: 1 });
+ assert.dom(".login-title").hasText(i18n("code_login.signup_title"));
+ assert.dom(".login-subheader").doesNotExist();
+ assert.dom(".code-login-form__title").doesNotExist();
+ assert
+ .dom(".code-login-form__instructions")
+ .hasText(i18n("code_login.signup_instructions"));
+
+ await fillIn(
+ ".code-login-form__email-step .form-kit__control-input",
+ );
+ await formKit().submit();
+
+ assert.dom(".code-login-form__code-step").exists();
+ assert.dom(".login-welcome-header").exists({ count: 1 });
+ assert.dom(".login-title").hasText(i18n("code_login.check_your_email"));
+ assert.dom(".login-subheader").includesText("[email protected]");
+ assert.dom(".code-login-form__title").doesNotExist();
+ });
+
+ test("login context keeps the inline step heading and adds no page header", async function (assert) {
+ stubCodeRequest();
+
+ await goToCodeStep();
+
+ assert.dom(".login-welcome-header").doesNotExist();
+ assert
+ .dom(".code-login-form__title")
+ .hasText(i18n("code_login.check_your_email"));
+ });
});
diff --git a/spec/system/code_signup_spec.rb b/spec/system/code_signup_spec.rb
index 5e07eb04e95..9355525e694 100644
--- a/spec/system/code_signup_spec.rb
+++ b/spec/system/code_signup_spec.rb
@@ -59,6 +59,34 @@ describe "Sign up via email code" do
expect(user.user_password).to be_nil
end
+ it "shows a single heading that is replaced as the flow advances" do
+ visit("/signup")
+
+ expect(page).to have_css(".code-login-form__email-step")
+ expect(page).to have_css(".login-welcome-header", count: 1)
+ expect(page).to have_css(".login-title", text: I18n.t("js.code_login.signup_title"))
+ expect(page).to have_no_css(".login-subheader")
+ expect(page).to have_no_css(".code-login-form__title")
+ expect(page).to have_css(
+ ".code-login-form__instructions",
+ text: I18n.t("js.code_login.signup_instructions"),
+ )
+
+ submit_email("[email protected]")
+
+ expect(page).to have_css(".code-login-form__code-step")
+ expect(page).to have_css(".login-welcome-header", count: 1)
+ expect(page).to have_css(".login-title", text: I18n.t("js.code_login.check_your_email"))
+ expect(page).to have_no_css(".code-login-form__title")
+
+ fill_code(latest_emailed_code("[email protected]"))
+
+ expect(page).to have_css(".code-login-form__complete-step")
+ expect(page).to have_css(".login-welcome-header", count: 1)
+ expect(page).to have_css(".login-title", text: I18n.t("js.code_login.account_ready_title"))
+ expect(page).to have_no_css(".code-login-form__title")
+ end
+
it "blocks continuing while the picked username is taken" do
Fabricate(:user, username: "takenname")