+ {{!-- empty div allows for animation --}}
+ {{#if (and currentUser.experimental_sidebar_enabled showSidebar)}}
+
+ {{/if}}
+
-
-
-
+
+
+ {{/if}}
diff --git a/app/assets/javascripts/discourse/app/widgets/sidebar-toggle.js b/app/assets/javascripts/discourse/app/widgets/sidebar-toggle.js
index b39163c0f32..35033fd4170 100644
--- a/app/assets/javascripts/discourse/app/widgets/sidebar-toggle.js
+++ b/app/assets/javascripts/discourse/app/widgets/sidebar-toggle.js
@@ -9,7 +9,7 @@ export default createWidget("sidebar-toggle", {
title: "",
icon: "bars",
action: "toggleSidebar",
- className: "btn btn-flat",
+ className: "btn btn-flat btn-sidebar-toggle",
}),
];
},
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js
new file mode 100644
index 00000000000..8c06a9e7d27
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js
@@ -0,0 +1,64 @@
+import { test } from "qunit";
+
+import { click, visit } from "@ember/test-helpers";
+import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("Sidebar - Mobile - User with sidebar enabled", function (needs) {
+ needs.user({ experimental_sidebar_enabled: true });
+ needs.mobileView();
+
+ test("hidden by default", async function (assert) {
+ await visit("/");
+
+ assert.ok(!exists(".sidebar-container"), "sidebar is not displayed");
+ });
+
+ test("clicking outside sidebar collapses it", async function (assert) {
+ await visit("/");
+
+ await click(".btn-sidebar-toggle");
+
+ assert.ok(exists(".sidebar-container"), "sidebar is displayed");
+
+ await click("#main-outlet");
+
+ assert.ok(!exists(".sidebar-container"), "sidebar is collapsed");
+ });
+
+ test("clicking on a link or button in sidebar collapses it", async function (assert) {
+ await visit("/");
+
+ await click(".btn-sidebar-toggle");
+ await click(".sidebar-section-link-tracked");
+
+ assert.ok(
+ !exists(".sidebar-container"),
+ "sidebar is collapsed when a button in sidebar is clicked"
+ );
+
+ await click(".btn-sidebar-toggle");
+ await click(".sidebar-section-header-link");
+
+ assert.ok(
+ !exists(".sidebar-container"),
+ "sidebar is collapsed when a link in sidebar is clicked"
+ );
+ });
+
+ test("collpasing sidebar sections does not collapse sidebar", async function (assert) {
+ await visit("/");
+
+ await click(".btn-sidebar-toggle");
+ await click(".sidebar-section-header-caret");
+
+ assert.ok(
+ !exists(".sidebar-section-topics .sidebar-section-content"),
+ "topics section is collapsed"
+ );
+
+ assert.ok(
+ exists(".sidebar-container"),
+ "sidebar is not collapsed when clicking on caret to collapse a section in sidebar"
+ );
+ });
+});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js
index eb05d0b5749..7f74dc66738 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js
@@ -14,7 +14,7 @@ acceptance("Sidebar - Anon User", function () {
"does not add sidebar utility class to body"
);
- assert.ok(!exists(".sidebar-wrapper"));
+ assert.ok(!exists(".sidebar-container"));
});
});
@@ -30,7 +30,7 @@ acceptance("Sidebar - User with sidebar disabled", function (needs) {
"does not add sidebar utility class to body"
);
- assert.ok(!exists(".sidebar-wrapper"));
+ assert.ok(!exists(".sidebar-container"));
});
});
@@ -46,7 +46,7 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
"adds sidebar utility class to body"
);
- assert.ok(exists(".sidebar-wrapper"), "displays the sidebar by default");
+ assert.ok(exists(".sidebar-container"), "displays the sidebar by default");
await click(".header-sidebar-toggle .btn");
@@ -56,10 +56,10 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
"removes sidebar utility class to body"
);
- assert.ok(!exists(".sidebar-wrapper"), "hides the sidebar");
+ assert.ok(!exists(".sidebar-container"), "hides the sidebar");
await click(".header-sidebar-toggle .btn");
- assert.ok(exists(".sidebar-wrapper"), "displays the sidebar");
+ assert.ok(exists(".sidebar-container"), "displays the sidebar");
});
});
diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss
index ea87cccb869..1fce19d92a6 100644
--- a/app/assets/stylesheets/common/base/discourse.scss
+++ b/app/assets/stylesheets/common/base/discourse.scss
@@ -671,6 +671,22 @@ table {
// Special elements
+#main-outlet-wrapper {
+ box-sizing: border-box;
+ width: 100%;
+ display: grid;
+ // we can CSS transition the sidebar grid width change
+ // as long as we keep the column count consistent
+ // grid transitions are only supported in Firefox at the moment, but coming summer 2022 to Chrome
+ grid-template-areas: "sidebar content";
+ grid-template-columns: min-content minmax(0, 1fr);
+ gap: 0;
+
+ #main-outlet {
+ grid-area: content;
+ }
+}
+
#main-outlet {
padding-top: 2.5em;
}
diff --git a/app/assets/stylesheets/common/base/sidebar.scss b/app/assets/stylesheets/common/base/sidebar.scss
index 576a899a54f..a20d45f3339 100644
--- a/app/assets/stylesheets/common/base/sidebar.scss
+++ b/app/assets/stylesheets/common/base/sidebar.scss
@@ -131,7 +131,7 @@
.sidebar-section-link {
display: flex;
align-items: center;
- padding: 0.25em 0.5em;
+ padding: 0.35em 0.5em;
color: var(--primary-high);
font-size: var(--font-down-1);
diff --git a/app/assets/stylesheets/desktop/discourse.scss b/app/assets/stylesheets/desktop/discourse.scss
index bd43ce1c403..cfb1224be52 100644
--- a/app/assets/stylesheets/desktop/discourse.scss
+++ b/app/assets/stylesheets/desktop/discourse.scss
@@ -187,22 +187,6 @@ input {
}
}
-#main-outlet-wrapper {
- box-sizing: border-box;
- width: 100%;
- display: grid;
- // we can CSS transition the sidebar grid width change
- // as long as we keep the column count consistent
- // grid transitions are only supported in Firefox at the moment, but coming summer 2022 to Chrome
- grid-template-areas: "sidebar content";
- grid-template-columns: 0 minmax(0, 1fr);
- gap: 0;
-
- #main-outlet {
- grid-area: content;
- }
-}
-
body.has-sidebar-page {
.wrap {
// increase page max-width to accommodate sidebar width
diff --git a/app/assets/stylesheets/mobile/discourse.scss b/app/assets/stylesheets/mobile/discourse.scss
index 9d8e1dd0384..8d01ca96b3b 100644
--- a/app/assets/stylesheets/mobile/discourse.scss
+++ b/app/assets/stylesheets/mobile/discourse.scss
@@ -134,3 +134,57 @@ blockquote {
#simple-container {
width: 90%;
}
+
+#main-outlet-wrapper {
+ width: 100%;
+
+ #main-outlet {
+ &.main-outlet-animate {
+ width: 95vw; // prevents content width shift during animation
+ }
+ }
+}
+
+.sidebar-wrapper {
+ width: 0;
+ transition: width 0.25s ease-in-out;
+}
+
+body.has-sidebar-page {
+ position: fixed;
+ height: calc(100vh - var(--header-offset));
+
+ #main {
+ overflow: hidden;
+ }
+
+ .sidebar-wrapper {
+ width: var(--d-sidebar-width);
+ }
+
+ #main-outlet {
+ position: relative;
+ width: 95vw; // prevents content width shift during animation
+ &:after {
+ content: "";
+ background: rgba(0, 0, 0, 0.5);
+ position: absolute;
+ top: 0;
+ left: -2em; // compensate for gap
+ right: 0;
+ bottom: 0;
+ z-index: z("dropdown");
+ }
+ }
+
+ #main-outlet-wrapper {
+ grid-template-columns: min-content minmax(0, 100vw);
+ gap: 0 2em;
+ padding-left: 0;
+
+ .sidebar-container {
+ padding-bottom: 6.6em;
+ transition: width 0.25s;
+ }
+ }
+}
+
+
- {{#if this.siteSettings.tagging_enabled}}
-
- {{/if}}
+ {{#if this.siteSettings.tagging_enabled}}
+
+ {{/if}}
- {{#if this.siteSettings.enable_personal_messages}}
-
- {{/if}}
-
+ {{#if this.siteSettings.enable_personal_messages}}
+