A platform for community discussion. Free, open, simple.
UX: Allow minimizing the design wizard (#45400)
Penar Musarajfd0cbcc7ce8a
diff --git a/app/assets/stylesheets/common/components/design-wizard.scss b/app/assets/stylesheets/common/components/design-wizard.scssindex 8ce45c11be1..c1f45deb111 100644--- a/app/assets/stylesheets/common/components/design-wizard.scss+++ b/app/assets/stylesheets/common/components/design-wizard.scss@@ -20,6 +20,7 @@ $dw-primary-very-high: #434343;$dw-button-default-border: #d3d3d3;.design-wizard,+.design-wizard__restore,.design-wizard__font-select-content {--primary: #{$dw-primary};--secondary: #{$dw-secondary};@@ -151,16 +152,68 @@ $dw-button-default-border: #d3d3d3;animation: none;}+ @media (prefers-reduced-motion: no-preference) {+ transition: transform 0.25s ease;++ &.--minimized {+ transition:+ transform 0.25s ease,+ visibility 0s 0.25s;+ }+ }++ &.--minimized {+ transform: translateY(100%);+ visibility: hidden;+ }+// a theme preview replaces the page; the panel is waiting for that to land&.--busy .design-wizard__sections {opacity: 0.6;pointer-events: none;}- &__close {+ &__panel-actions {position: absolute;inset-block-start: var(--space-2);inset-inline-end: var(--space-2);+ display: flex;+ }++ &__restore {+ position: fixed;+ z-index: z("design-wizard");+ inset-block-end: var(--space-4);+ inset-inline-end: var(--space-4);+ display: flex;+ gap: var(--space-3);+ max-width: calc(100vw - var(--space-4) * 2);+ padding: var(--space-3) var(--space-4);+ border-radius: var(--d-border-radius-large);+ box-shadow: var(--shadow-card);++ @include viewport.until(sm) {+ inset-block-end: 0;+ inset-inline: 0;+ width: 100%;+ max-width: none;+ padding-block-end: max(var(--space-3), env(safe-area-inset-bottom));+ border-end-start-radius: 0;+ border-end-end-radius: 0;+ }+ }++ &__restore-title {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ &__restore-progress {+ flex-shrink: 0;+ font-size: var(--font-down-1);+ color: var(--primary-high);}&__content {@@ -178,6 +231,7 @@ $dw-button-default-border: #d3d3d3;display: flex;flex-direction: column;gap: var(--space-1);+ padding-inline-end: 4em;h2 {margin: 0;diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex e1841444223..22ac8e3d4e2 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -660,6 +660,9 @@ en:title: "Customize your site"subtitle: "Choose colors, fonts, and how your site is laid out."step_label: "Go to step %{index}"+ step_progress: "Step %{current}/%{total}"+ minimize: "Minimize design wizard"+ restore: "Restore design wizard"save: "Save and finish"back: "Back"next: "Next"diff --git a/frontend/discourse/app/components/design-wizard-panel.gjs b/frontend/discourse/app/components/design-wizard-panel.gjsindex 9cad477833f..adbb28c3d7c 100644--- a/frontend/discourse/app/components/design-wizard-panel.gjs+++ b/frontend/discourse/app/components/design-wizard-panel.gjs@@ -1,11 +1,17 @@import Component from "@glimmer/component";import { action } from "@ember/object";import didInsert from "@ember/render-modifiers/modifiers/did-insert";+import { schedule } from "@ember/runloop";import { service } from "@ember/service";-import DesignWizardControls from "discourse/components/design-wizard/controls";+import DesignWizardControls, {+ STEPS,+} from "discourse/components/design-wizard/controls";import { isTesting } from "discourse/lib/environment";import { prefersReducedMotion } from "discourse/lib/utilities";import DButton from "discourse/ui-kit/d-button";+import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";+import dIcon from "discourse/ui-kit/helpers/d-icon";+import dAutoFocus from "discourse/ui-kit/modifiers/d-auto-focus";import { i18n } from "discourse-i18n";export default class DesignWizardPanel extends Component {@@ -14,6 +20,28 @@ export default class DesignWizardPanel extends Component {element;+ get stepProgress() {+ return i18n("design_wizard.step_progress", {+ current: this.designWizard.stepIndex + 1,+ total: STEPS.length,+ });+ }++ @action+ minimize() {+ this.designWizard.setMinimized(true);+ }++ @action+ restore() {+ this.designWizard.setMinimized(false);+ schedule("afterRender", () => {+ this.element+ ?.querySelector(".design-wizard__minimize")+ ?.focus({ preventScroll: true });+ });+ }+@actionregisterElement(element) {this.element = element;@@ -83,21 +111,56 @@ export default class DesignWizardPanel extends Component {<template>{{#if this.designWizard.active}}<aside+ aria-hidden={{if this.designWizard.minimized "true"}}aria-labelledby="design-wizard-title"- class="design-wizard- {{unless this.designWizard.animateEntrance '--no-entrance'}}- {{if this.designWizard.applyingTheme '--busy'}}"+ class={{dConcatClass+ "design-wizard"+ (unless this.designWizard.animateEntrance "--no-entrance")+ (if this.designWizard.applyingTheme "--busy")+ (if this.designWizard.minimized "--minimized")+ }}+ id="design-wizard-panel"+ inert={{this.designWizard.minimized}}...attributes{{didInsert this.registerElement}}>- <DButton- class="btn-transparent design-wizard__close"- @action={{this.close}}- @icon="xmark"- @title="modal.close"- />+ <div class="design-wizard__panel-actions">+ <DButton+ class="btn-transparent design-wizard__minimize"+ @action={{this.minimize}}+ @disabled={{this.designWizard.applyingTheme}}+ @icon="minus"+ @title="design_wizard.minimize"+ />+ <DButton+ class="btn-transparent design-wizard__close"+ @action={{this.close}}+ @icon="xmark"+ @title="modal.close"+ />+ </div><DesignWizardControls /></aside>+ {{#if this.designWizard.minimized}}+ <DButton+ aria-controls="design-wizard-panel"+ class="btn-default design-wizard__restore"+ @action={{this.restore}}+ @ariaExpanded={{false}}+ @title="design_wizard.restore"+ {{dAutoFocus}}+ >+ <span class="design-wizard__restore-title">+ {{i18n "design_wizard.title"}}+ </span>+ {{#unless this.designWizard.showIntro}}+ <span class="design-wizard__restore-progress">+ {{this.stepProgress}}+ </span>+ {{/unless}}+ {{dIcon "chevron-up"}}+ </DButton>+ {{/if}}{{/if}}</template>}diff --git a/frontend/discourse/app/components/design-wizard/controls.gjs b/frontend/discourse/app/components/design-wizard/controls.gjsindex 4ced8c6b34b..d58e3f91b32 100644--- a/frontend/discourse/app/components/design-wizard/controls.gjs+++ b/frontend/discourse/app/components/design-wizard/controls.gjs@@ -14,7 +14,7 @@ import WelcomeBannerSection from "discourse/components/design-wizard/welcome-banimport DButton from "discourse/ui-kit/d-button";import { i18n } from "discourse-i18n";-const STEPS = ["theme", "colors", "homepage"];+export const STEPS = ["theme", "colors", "homepage"];export default class DesignWizardControls extends Component {@service designWizard;diff --git a/frontend/discourse/app/services/design-wizard.js b/frontend/discourse/app/services/design-wizard.jsindex 2c17adf3cd0..688d7c014fc 100644--- a/frontend/discourse/app/services/design-wizard.js+++ b/frontend/discourse/app/services/design-wizard.js@@ -52,6 +52,7 @@ export default class DesignWizardService extends Service {@service siteSettings;@tracked active = false;+ @tracked minimized = false;@tracked data;@tracked themeId;@tracked colorMode = "light";@@ -376,6 +377,12 @@ export default class DesignWizardService extends Service {this.#persistState();}+ setMinimized(minimized) {+ this.minimized = minimized;+ this.animateEntrance = false;+ this.#persistState();+ }+setStepIndex(stepIndex) {this.stepIndex = stepIndex;this.#persistState();@@ -581,6 +588,7 @@ export default class DesignWizardService extends Service {}#reset() {+ this.minimized = false;this.source = SOURCE_ONBOARDING;this.returnUrl = undefined;this.progressSaved = false;@@ -627,6 +635,7 @@ export default class DesignWizardService extends Service {}#initFromData() {+ this.minimized = false;// a custom default theme isn't offered by the wizard, so nothing is// preselected and the page keeps rendering it until a theme is chosenconst preselectedTheme =@@ -653,6 +662,7 @@ export default class DesignWizardService extends Service {}#restore(stored) {+ this.minimized = stored.minimized ?? false;this.source = stored.source ?? SOURCE_ONBOARDING;this.returnUrl = stored.returnUrl;this.progressSaved = stored.progressSaved ?? false;@@ -710,6 +720,7 @@ export default class DesignWizardService extends Service {this.keyValueStore.set({key: STATE_KEY,value: JSON.stringify({+ minimized: this.minimized,themeId: this.themeId,selectedPairKeys: [...this.selectedPairKeys.entries()],colorMode: this.colorMode,diff --git a/frontend/discourse/tests/acceptance/design-wizard-test.gjs b/frontend/discourse/tests/acceptance/design-wizard-test.gjsindex 7aeaa8ec99e..831e20a453b 100644--- a/frontend/discourse/tests/acceptance/design-wizard-test.gjs+++ b/frontend/discourse/tests/acceptance/design-wizard-test.gjs@@ -1,6 +1,7 @@import {click,currentURL,+ find,visit,waitFor,waitUntil,@@ -117,6 +118,129 @@ acceptance("Design wizard - admin launch", function (needs) {);});+ test("minimizing preserves the preview and selections while browsing", async function (assert) {+ sinon.stub(DiscourseURL, "redirectTo");++ await visit("/admin");+ await click(APPEARANCE_LAUNCH_BUTTON);+ await click(".design-wizard__intro-start");+ await click(".design-wizard__next");+ await click(".design-wizard__color-mode:last-child");+ await click(+ ".design-wizard__font-group:first-child .design-wizard__font-select"+ );+ await click("[data-identifier='design-wizard-base-font'] .body-font-arial");++ const previewLinks = captureColorSchemeLinks();+ const sections = find(".design-wizard__sections");+ const savedCount = savedPayloads.length;++ await click(".design-wizard__minimize");++ assert+ .dom(".design-wizard")+ .hasAttribute("inert", "", "hides controls from keyboard navigation");+ assert+ .dom(".design-wizard")+ .hasAria("hidden", "true", "hides controls from assistive technology");+ assert+ .dom(".design-wizard__restore")+ .isFocused("moves focus to the restore button");+ assert+ .dom(".design-wizard__restore")+ .hasAria("expanded", "false", "exposes the collapsed state");+ assert+ .dom(".design-wizard__restore")+ .includesText("Step 2/3", "shows the current step");+ assert+ .dom(".dialog-footer")+ .doesNotExist("minimizing does not ask about saved changes");+ assert.strictEqual(+ savedPayloads.length,+ savedCount,+ "minimizing does not save changes"+ );+ assert.deepEqual(+ captureColorSchemeLinks(),+ previewLinks,+ "keeps the palette preview applied"+ );++ await visit("/categories");++ assert+ .dom(".design-wizard__restore")+ .exists("keeps the restore button available on another page");+ await click(".design-wizard__restore");++ assert+ .dom(".design-wizard__restore")+ .doesNotExist("removes the restore bar when expanded");+ assert+ .dom(".design-wizard")+ .doesNotHaveAttribute("inert", "restores keyboard access");+ assert+ .dom(".design-wizard")+ .doesNotHaveAttribute(+ "aria-hidden",+ "restores access for assistive technology"+ );+ assert+ .dom(".design-wizard__minimize")+ .isFocused("returns focus to the panel");+ assert+ .dom(".design-wizard__color-mode:last-child")+ .hasAria("pressed", "true", "preserves the color mode selection");+ assert+ .dom(".design-wizard__font-group:first-child .design-wizard__font-select")+ .hasText("Arial", "preserves the unsaved font selection");+ assert.strictEqual(+ find(".design-wizard__sections"),+ sections,+ "keeps the controls mounted to retain their scroll position"+ );+ assert.strictEqual(+ savedPayloads.length,+ savedCount,+ "restoring does not save changes"+ );+ assert.deepEqual(+ captureColorSchemeLinks(),+ previewLinks,+ "restoring keeps the palette preview applied"+ );++ await click(".design-wizard__close");+ await click(".dialog-footer .btn-primary");+ });++ test("the intro can be minimized and a new run opens expanded", async function (assert) {+ await visit("/admin");+ await click(APPEARANCE_LAUNCH_BUTTON);+ await click(".design-wizard__minimize");++ assert+ .dom(".design-wizard__restore")+ .includesText("Customize your site", "labels the way back to the wizard");+ assert+ .dom(".design-wizard__restore-progress")+ .doesNotExist("does not show step progress before the wizard starts");++ await click(".design-wizard__restore");+ assert.dom(".design-wizard__intro").exists("restores the introduction");+ await click(".design-wizard__close");+ await visit("/admin");+ await click(APPEARANCE_LAUNCH_BUTTON);++ assert+ .dom(".design-wizard")+ .doesNotHaveAttribute("inert", "a fresh run is expanded");+ assert+ .dom(".design-wizard__restore")+ .doesNotExist("a fresh run has no minimized bar");+ await click(".design-wizard__close");+ });+test("saves a dark-only palette for both system color modes", async function (assert) {wizardData.themes[0].palette_pairs.push({key: "dracula",