Skip to content

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

UX: Dock the design wizard as a right sidebar on wide screens (#45526)

Jordan Vidrinec2de05582b76
diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scss
index 81e5cc54697..22593142e73 100644
--- a/app/assets/stylesheets/common/base/compose.scss
+++ b/app/assets/stylesheets/common/base/compose.scss
@@ -47,11 +47,13 @@ html.composer-open:not(.has-full-page-chat) {
display: flex;
flex-direction: column;
bottom: 0;
- right: 0;
+ right: var(--d-page-inset-inline-end, 0);
left: 0;
margin-inline: auto;
max-width: $reply-area-max-width;
- width: 100%;
+
+ // a 100% width would over-constrain the box and drop the right inset
+ width: auto;
height: 0;
min-height: 0;
z-index: z("composer", "content");
@@ -1132,7 +1134,7 @@ html.composer-open:not(.has-full-page-chat) {
--topic-width: calc(
var(--topic-body-width) + (var(--topic-body-width-padding) * 2)
);
- width: 100%;
+ width: auto;
max-width: calc(var(--topic-width) + var(--topic-avatar-width));
}
diff --git a/app/assets/stylesheets/common/components/design-wizard.scss b/app/assets/stylesheets/common/components/design-wizard.scss
index c7ed9864dab..b998bc81ddc 100644
--- a/app/assets/stylesheets/common/components/design-wizard.scss
+++ b/app/assets/stylesheets/common/components/design-wizard.scss
@@ -19,6 +19,23 @@ $dw-primary-high: #646464;
$dw-primary-very-high: #434343;
$dw-button-default-border: #d3d3d3;
+// px, so the reserved space matches the panel, whose font size is pinned
+$dw-docked-width: 360px;
+$dw-rail-width: 56px;
+
+// fixed-position UI pinned to the inline end reads this to stay uncovered
+html.design-wizard-docked {
+ --d-page-inset-inline-end: #{$dw-docked-width};
+
+ &.design-wizard-collapsed {
+ --d-page-inset-inline-end: #{$dw-rail-width};
+ }
+
+ body {
+ padding-inline-end: var(--d-page-inset-inline-end);
+ }
+}
+
.design-wizard,
.design-wizard__restore,
.design-wizard__font-select-content {
@@ -107,6 +124,9 @@ $dw-button-default-border: #d3d3d3;
}
.design-wizard {
+ // regions pad themselves so their dividers can run edge to edge
+ --design-wizard-gutter: var(--space-5);
+
// also read by the panel component, for its closing animation
--design-wizard-slide-out: translateX(100%);
--design-wizard-category-1: #25aae2;
@@ -148,6 +168,30 @@ $dw-button-default-border: #d3d3d3;
}
}
+ &.--docked {
+ inset-block: 0;
+ width: var(--d-page-inset-inline-end);
+ border-block: none;
+ border-inline-end: none;
+ border-radius: 0;
+ box-shadow: none;
+ }
+
+ // controls stay laid out at full width so their scroll position survives
+ &.--collapsed {
+ overflow: hidden;
+
+ .design-wizard__panel-actions,
+ .design-wizard__content {
+ visibility: hidden;
+ }
+
+ .design-wizard__content {
+ flex: none;
+ width: $dw-docked-width;
+ }
+ }
+
&.--no-entrance {
animation: none;
}
@@ -180,6 +224,43 @@ $dw-button-default-border: #d3d3d3;
display: flex;
}
+ &__expand {
+ position: absolute;
+ inset: 0;
+ flex-direction: column;
+ justify-content: flex-start;
+ gap: var(--space-4);
+ padding: var(--space-4) 0;
+ border-radius: 0;
+ }
+
+ &__expand-label {
+ display: flex;
+ gap: var(--space-3);
+ font-size: var(--font-down-2);
+ font-weight: 600;
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+ writing-mode: vertical-rl;
+ }
+
+ &__expand-progress,
+ &__step-progress {
+ color: var(--primary-medium);
+ }
+
+ &__step-progress {
+ font-size: var(--font-down-2);
+ font-weight: 600;
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+ }
+
+ html[dir="rtl"] &.--docked .design-wizard__minimize .d-icon,
+ html[dir="rtl"] & .design-wizard__expand .d-icon {
+ transform: scaleX(-1);
+ }
+
&__restore {
position: fixed;
z-index: z("design-wizard");
@@ -219,30 +300,25 @@ $dw-button-default-border: #d3d3d3;
&__content {
display: flex;
flex-direction: column;
- gap: var(--space-5);
height: 100%;
// so the sections scroll rather than pushing the footer actions out
min-height: 0;
- padding: var(--space-5);
}
&__header {
display: flex;
flex-direction: column;
gap: var(--space-1);
- padding-inline-end: 4em;
+ padding-block: var(--design-wizard-gutter) var(--space-4);
+ padding-inline: var(--design-wizard-gutter) 4em;
+ border-block-end: 1px solid var(--content-border-color);
h2 {
margin: 0;
}
}
- &__subtitle {
- font-size: var(--font-down-1);
- color: var(--primary-medium);
- }
-
&__intro {
display: flex;
flex: 1 1 auto;
@@ -250,6 +326,7 @@ $dw-button-default-border: #d3d3d3;
gap: var(--space-4);
align-items: flex-start;
min-height: 0;
+ padding: var(--design-wizard-gutter);
overflow-y: auto;
}
@@ -274,10 +351,7 @@ $dw-button-default-border: #d3d3d3;
flex-direction: column;
gap: var(--space-6);
min-height: 0;
-
- // so a selected control's box-shadow isn't clipped by the scroll container
- padding: 2px;
- margin: -2px;
+ padding: var(--design-wizard-gutter);
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
@@ -915,7 +989,8 @@ $dw-button-default-border: #d3d3d3;
align-items: center;
justify-content: flex-end;
gap: var(--space-2);
- padding-block-start: var(--space-4);
+ padding-block: var(--space-4) var(--design-wizard-gutter);
+ padding-inline: var(--design-wizard-gutter);
border-block-start: 1px solid var(--content-border-color);
}
diff --git a/app/assets/stylesheets/common/float-kit/d-toasts.scss b/app/assets/stylesheets/common/float-kit/d-toasts.scss
index 75a4b436c4a..9bdc51be8e3 100644
--- a/app/assets/stylesheets/common/float-kit/d-toasts.scss
+++ b/app/assets/stylesheets/common/float-kit/d-toasts.scss
@@ -8,7 +8,7 @@
--transform-y: 0;
position: fixed;
top: calc(var(--header-offset) + 0.33rem);
- right: 5px;
+ right: calc(5px + var(--d-page-inset-inline-end, 0px));
z-index: z("max");
display: flex;
flex-direction: column;
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f9ff454bed0..487b5870869 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -661,11 +661,12 @@ en:
design_wizard:
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"
+ collapse: "Collapse design wizard"
+ expand: "Expand 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.gjs
index adbb28c3d7c..1b599ba96c5 100644
--- a/frontend/discourse/app/components/design-wizard-panel.gjs
+++ b/frontend/discourse/app/components/design-wizard-panel.gjs
@@ -6,6 +6,7 @@ import { service } from "@ember/service";
import DesignWizardControls, {
STEPS,
} from "discourse/components/design-wizard/controls";
+import htmlClass from "discourse/helpers/html-class";
import { isTesting } from "discourse/lib/environment";
import { prefersReducedMotion } from "discourse/lib/utilities";
import DButton from "discourse/ui-kit/d-button";
@@ -20,6 +21,15 @@ export default class DesignWizardPanel extends Component {
element;
+ get collapsed() {
+ return this.designWizard.docked && this.designWizard.minimized;
+ }
+
+ // docked, the minimized panel stays on screen as a rail instead
+ get hidden() {
+ return this.designWizard.minimized && !this.designWizard.docked;
+ }
+
get stepProgress() {
return i18n("design_wizard.step_progress", {
current: this.designWizard.stepIndex + 1,
@@ -110,27 +120,59 @@ export default class DesignWizardPanel extends Component {
<template>
{{#if this.designWizard.active}}
+ {{#if this.designWizard.docked}}
+ {{htmlClass
+ "design-wizard-docked"
+ (if this.collapsed "design-wizard-collapsed")
+ }}
+ {{/if}}
<aside
- aria-hidden={{if this.designWizard.minimized "true"}}
+ aria-hidden={{if this.hidden "true"}}
aria-labelledby="design-wizard-title"
class={{dConcatClass
"design-wizard"
(unless this.designWizard.animateEntrance "--no-entrance")
(if this.designWizard.applyingTheme "--busy")
- (if this.designWizard.minimized "--minimized")
+ (if this.designWizard.docked "--docked")
+ (if this.collapsed "--collapsed")
+ (if this.hidden "--minimized")
}}
id="design-wizard-panel"
- inert={{this.designWizard.minimized}}
+ inert={{this.hidden}}
...attributes
{{didInsert this.registerElement}}
>
+ {{#if this.collapsed}}
+ <DButton
+ aria-controls="design-wizard-panel"
+ class="btn-transparent design-wizard__expand"
+ @action={{this.restore}}
+ @ariaExpanded={{false}}
+ @title="design_wizard.expand"
+ {{dAutoFocus}}
+ >
+ {{dIcon "angles-left"}}
+ <span class="design-wizard__expand-label">
+ <span>{{i18n "design_wizard.title"}}</span>
+ {{#unless this.designWizard.showIntro}}
+ <span class="design-wizard__expand-progress">
+ {{this.stepProgress}}
+ </span>
+ {{/unless}}
+ </span>
+ </DButton>
+ {{/if}}
<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"
+ @icon={{if this.designWizard.docked "angles-right" "minus"}}
+ @title={{if
+ this.designWizard.docked
+ "design_wizard.collapse"
+ "design_wizard.minimize"
+ }}
/>
<DButton
class="btn-transparent design-wizard__close"
@@ -141,7 +183,7 @@ export default class DesignWizardPanel extends Component {
</div>
<DesignWizardControls />
</aside>
- {{#if this.designWizard.minimized}}
+ {{#if this.hidden}}
<DButton
aria-controls="design-wizard-panel"
class="btn-default design-wizard__restore"
diff --git a/frontend/discourse/app/components/design-wizard/controls.gjs b/frontend/discourse/app/components/design-wizard/controls.gjs
index d58e3f91b32..393a8cbaa8b 100644
--- a/frontend/discourse/app/components/design-wizard/controls.gjs
+++ b/frontend/discourse/app/components/design-wizard/controls.gjs
@@ -43,6 +43,13 @@ export default class DesignWizardControls extends Component {
return this.designWizard.applyingTheme;
}
+ get stepProgress() {
+ return i18n("design_wizard.step_progress", {
+ current: this.designWizard.stepIndex + 1,
+ total: STEPS.length,
+ });
+ }
+
goToStepLabel(index) {
return i18n("design_wizard.step_label", { index: index + 1 });
}
@@ -157,12 +164,16 @@ export default class DesignWizardControls extends Component {
<template>
<div class="design-wizard__content">
<header class="design-wizard__header">
+ {{#if this.designWizard.docked}}
+ {{#unless this.designWizard.showIntro}}
+ <span class="design-wizard__step-progress">
+ {{this.stepProgress}}
+ </span>
+ {{/unless}}
+ {{/if}}
<h2 id="design-wizard-title">
{{i18n "design_wizard.title"}}
</h2>
- <span class="design-wizard__subtitle">
- {{i18n "design_wizard.subtitle"}}
- </span>
</header>
{{#if this.designWizard.showIntro}}
diff --git a/frontend/discourse/app/services/design-wizard.js b/frontend/discourse/app/services/design-wizard.js
index 688d7c014fc..330b3014e1b 100644
--- a/frontend/discourse/app/services/design-wizard.js
+++ b/frontend/discourse/app/services/design-wizard.js
@@ -47,6 +47,7 @@ const STEP_COMPLETED_KEY = `onboarding_step_${SELECT_THEME_STEP}`;
* preview reloads required by a different asset build.
*/
export default class DesignWizardService extends Service {
+ @service capabilities;
@service keyValueStore;
@service router;
@service siteSettings;
@@ -88,6 +89,11 @@ export default class DesignWizardService extends Service {
#originalColorSchemeLinks;
#prefetched = false;
+ // with room for both, the page reflows beside the panel instead of under it
+ get docked() {
+ return this.active && this.capabilities.viewport.xl;
+ }
+
get selectedTheme() {
return this.data?.themes.find((theme) => theme.id === this.themeId);
}
diff --git a/frontend/discourse/tests/acceptance/design-wizard-test.gjs b/frontend/discourse/tests/acceptance/design-wizard-test.gjs
index 831e20a453b..a6ae62a75cf 100644
--- a/frontend/discourse/tests/acceptance/design-wizard-test.gjs
+++ b/frontend/discourse/tests/acceptance/design-wizard-test.gjs
@@ -14,6 +14,7 @@ import {
} from "discourse/admin/lib/color-scheme-manager";
import { AUTO_GROUPS } from "discourse/lib/constants";
import DiscourseURL from "discourse/lib/url";
+import DesignWizardService from "discourse/services/design-wizard";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const APPEARANCE_LAUNCH_BUTTON =
@@ -60,6 +61,7 @@ acceptance("Design wizard - admin launch", function (needs) {
let wizardData;
let importRequests;
let importFails;
+ let docked;
needs.user({
admin: true,
@@ -73,6 +75,12 @@ acceptance("Design wizard - admin launch", function (needs) {
importRequests = [];
importFails = false;
this.originalSchemeLinks = captureColorSchemeLinks();
+
+ // docking follows the viewport, which the test runner doesn't control
+ docked = false;
+ sinon.stub(DesignWizardService.prototype, "docked").get(function () {
+ return this.active && docked;
+ });
});
// A wizard preview swaps the test page's real color-scheme links, and an
@@ -241,6 +249,80 @@ acceptance("Design wizard - admin launch", function (needs) {
await click(".design-wizard__close");
});
+ test("docks beside the page and collapses to a rail on wide screens", async function (assert) {
+ docked = true;
+
+ await visit("/admin");
+ await click(APPEARANCE_LAUNCH_BUTTON);
+
+ assert
+ .dom(document.documentElement)
+ .hasClass("design-wizard-docked", "reserves space beside the page");
+ assert.dom(".design-wizard").hasClass("--docked");
+ assert
+ .dom(".design-wizard__step-progress")
+ .doesNotExist("does not show step progress before the wizard starts");
+
+ await click(".design-wizard__intro-start");
+ await click(".design-wizard__next");
+
+ assert
+ .dom(".design-wizard__step-progress")
+ .hasText("Step 2/3", "shows the current step as text");
+
+ const sections = find(".design-wizard__sections");
+ await click(".design-wizard__minimize");
+
+ assert
+ .dom(document.documentElement)
+ .hasClass("design-wizard-collapsed", "narrows the reserved space");
+ assert
+ .dom(".design-wizard")
+ .doesNotHaveAttribute("inert", "keeps the rail reachable by keyboard");
+ assert
+ .dom(".design-wizard")
+ .doesNotHaveAttribute("aria-hidden", "keeps the rail announced");
+ assert
+ .dom(".design-wizard__restore")
+ .doesNotExist("uses the rail instead of the restore bar");
+ assert
+ .dom(".design-wizard__expand")
+ .isFocused("moves focus to the expand button");
+ assert
+ .dom(".design-wizard__expand")
+ .includesText("Step 2/3", "names the current step");
+ assert
+ .dom(".design-wizard__expand")
+ .hasAria("expanded", "false", "exposes the collapsed state");
+
+ await visit("/categories");
+
+ assert
+ .dom(".design-wizard__expand")
+ .exists("stays collapsed while browsing");
+
+ await click(".design-wizard__expand");
+
+ assert
+ .dom(document.documentElement)
+ .doesNotHaveClass("design-wizard-collapsed", "widens the reserved space");
+ assert
+ .dom(".design-wizard__minimize")
+ .isFocused("returns focus to the panel");
+ assert.strictEqual(
+ find(".design-wizard__sections"),
+ sections,
+ "keeps the controls mounted to retain their scroll position"
+ );
+
+ await click(".design-wizard__close");
+ await click(".dialog-footer .btn-primary");
+
+ assert
+ .dom(document.documentElement)
+ .doesNotHaveClass("design-wizard-docked", "gives the space back");
+ });
+
test("saves a dark-only palette for both system color modes", async function (assert) {
wizardData.themes[0].palette_pairs.push({
key: "dracula",
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.gjs
index 8b518957d8c..53140317aac 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.gjs
@@ -28,6 +28,8 @@ export default class ChatDrawer extends Component {
loading = false;
sizeTimer = null;
rafTimer = null;
+ bodyResizeObserver = null;
+ bodyInlineSize = null;
hasUnreadMessages = false;
drawerStyle = null;
@@ -54,6 +56,7 @@ export default class ChatDrawer extends Component {
this.appEvents.on("composer:resized", this, "_checkSize");
this.appEvents.on("composer:div-resizing", this, "_dynamicCheckSize");
window.addEventListener("resize", this._dynamicCheckSize);
+ this._observeBodyInlineSize();
this.appEvents.on(
"composer:resize-started",
this,
@@ -72,6 +75,8 @@ export default class ChatDrawer extends Component {
}
window.removeEventListener("resize", this._dynamicCheckSize);
+ this.bodyResizeObserver?.disconnect();
+ this.bodyResizeObserver = null;
if (this.appEvents) {
this.appEvents.off("chat:open-url", this, "openURL");
@@ -192,6 +197,20 @@ export default class ChatDrawer extends Component {
this._checkSize();
}
+ // a page inset pads the body without resizing the window, and moves the
+ // composer with it
+ _observeBodyInlineSize() {
+ this.bodyResizeObserver = new ResizeObserver(([entry]) => {
+ const inlineSize = entry.contentBoxSize[0].inlineSize;
+
+ if (inlineSize !== this.bodyInlineSize) {
+ this.bodyInlineSize = inlineSize;
+ this._dynamicCheckSize();
+ }
+ });
+ this.bodyResizeObserver.observe(document.body);
+ }
+
@bind
_checkSize() {
this.sizeTimer = throttle(this, this._performCheckSize, 150);
@@ -211,7 +230,15 @@ export default class ChatDrawer extends Component {
const composer = document.getElementById("reply-control");
const composerIsClosed = composer.classList.contains("closed");
- const minRightMargin = 15;
+
+ // space reserved at the page's inline end by fixed UI the drawer must not cover
+ const pageInset =
+ parseFloat(
+ getComputedStyle(document.documentElement).getPropertyValue(
+ "--d-page-inset-inline-end"
+ )
+ ) || 0;
+ const minRightMargin = pageInset + 15;
const isPeekMode = document.body.classList.contains("peek-mode-active");
@@ -231,7 +258,7 @@ export default class ChatDrawer extends Component {
composer.offsetLeft -
composer.offsetWidth;
const drawerWidth = this.chatDrawerSize.size.width || 400;
- const aboveComposer = spaceToEnd < drawerWidth;
+ const aboveComposer = spaceToEnd - pageInset < drawerWidth;
drawerContainer.style.setProperty(
"--composer-right",