Align the menu to the side on tablets
authorAlexander Ebert <ebert@woltlab.com>
Wed, 15 Dec 2021 15:58:00 +0000 (16:58 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 15 Dec 2021 15:58:00 +0000 (16:58 +0100)
ts/WoltLabSuite/Core/Ui/Page/Menu/Container.ts
ts/WoltLabSuite/Core/Ui/Page/Menu/Main.ts
ts/WoltLabSuite/Core/Ui/Page/Menu/User.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Container.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Main.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/User.js
wcfsetup/install/files/style/ui/dropdownInteractive.scss
wcfsetup/install/files/style/ui/pageMenu.scss

index 8e368cbd85a899e1ebeec80a5e25585aab92b612..9fd9c126a0948a7b3a01aa63f34df31448df78b4 100644 (file)
@@ -4,15 +4,21 @@ import { pageOverlayClose, pageOverlayOpen, scrollDisable, scrollEnable } from "
 import UiCloseOverlay from "../../CloseOverlay";
 import DomUtil from "../../../Dom/Util";
 
+export const enum Orientation {
+  Left = "left",
+  Right = "right",
+}
+
 export class PageMenuContainer {
   private readonly container = document.createElement("div");
   private readonly content = document.createElement("div");
   private focusTrap?: FocusTrap = undefined;
+  private readonly orientation: Orientation;
   private readonly provider: PageMenuProvider;
-  private skipCloseOverlay = false;
 
-  constructor(provider: PageMenuProvider) {
+  constructor(provider: PageMenuProvider, orientation: Orientation) {
     this.provider = provider;
+    this.orientation = orientation;
 
     const menuId = DomUtil.identify(this.provider.getMenuButton());
     UiCloseOverlay.add(`WoltLabSuite/Core/Ui/PageMenu/Container-${menuId}`, () => {
@@ -72,6 +78,7 @@ export class PageMenuContainer {
     }
 
     this.container.classList.add("pageMenuContainer");
+    this.container.dataset.orientation = this.orientation;
     this.container.hidden = true;
     this.container.addEventListener("click", (event) => {
       if (event.target === this.container) {
index 43c023c30de0c47e285420aa0200d5e291df8b2e..298b6d2e7053fbd1f4f11fb6ed97e87751f523e8 100644 (file)
@@ -7,7 +7,7 @@
  * @module WoltLabSuite/Core/Ui/Page/Menu/Main
  */
 
-import PageMenuContainer from "./Container";
+import PageMenuContainer, { Orientation } from "./Container";
 import { PageMenuProvider } from "./Provider";
 import * as Language from "../../../Language";
 import DomUtil from "../../../Dom/Util";
@@ -66,7 +66,7 @@ export class PageMenuMain implements PageMenuProvider {
   constructor() {
     this.mainMenu = document.querySelector(".mainMenu")!;
 
-    this.container = new PageMenuContainer(this);
+    this.container = new PageMenuContainer(this, Orientation.Left);
 
     this.callbackOpen = (event) => {
       event.preventDefault();
index a0618508cf71ec17edb8a590d5d356912ff97b51..c139893d7b57b84fc2bc66e81c8a580cdb41cceb 100644 (file)
@@ -7,7 +7,7 @@
  * @module WoltLabSuite/Core/Ui/Page/Menu/User
  */
 
-import PageMenuContainer from "./Container";
+import PageMenuContainer, { Orientation } from "./Container";
 import { PageMenuProvider } from "./Provider";
 import * as Language from "../../../Language";
 import { getUserMenuProviders } from "../../User/Menu/Manager";
@@ -51,7 +51,7 @@ export class PageMenuUser implements PageMenuProvider {
   constructor() {
     this.userMenu = document.querySelector(".userPanel")!;
 
-    this.container = new PageMenuContainer(this);
+    this.container = new PageMenuContainer(this, Orientation.Right);
 
     this.callbackOpen = (event) => {
       event.preventDefault();
index 2bd8ed3003aef3e31cdeecc5401c0e024df4b502..0df21e89a875487c4b47a858cbc60bfe63702661 100644 (file)
@@ -5,12 +5,12 @@ define(["require", "exports", "tslib", "focus-trap", "../../Screen", "../../Clos
     CloseOverlay_1 = (0, tslib_1.__importDefault)(CloseOverlay_1);
     Util_1 = (0, tslib_1.__importDefault)(Util_1);
     class PageMenuContainer {
-        constructor(provider) {
+        constructor(provider, orientation) {
             this.container = document.createElement("div");
             this.content = document.createElement("div");
             this.focusTrap = undefined;
-            this.skipCloseOverlay = false;
             this.provider = provider;
+            this.orientation = orientation;
             const menuId = Util_1.default.identify(this.provider.getMenuButton());
             CloseOverlay_1.default.add(`WoltLabSuite/Core/Ui/PageMenu/Container-${menuId}`, () => {
                 if (!this.container.hidden) {
@@ -55,6 +55,7 @@ define(["require", "exports", "tslib", "focus-trap", "../../Screen", "../../Clos
                 return;
             }
             this.container.classList.add("pageMenuContainer");
+            this.container.dataset.orientation = this.orientation;
             this.container.hidden = true;
             this.container.addEventListener("click", (event) => {
                 if (event.target === this.container) {
index cfbc2d9d9414a34c9ba1f01dbee0efffbf48df21..bfecc717d5fed828a2c305df3084e7d94bea9c97 100644 (file)
@@ -46,7 +46,7 @@ define(["require", "exports", "tslib", "./Container", "../../../Language", "../.
     class PageMenuMain {
         constructor() {
             this.mainMenu = document.querySelector(".mainMenu");
-            this.container = new Container_1.default(this);
+            this.container = new Container_1.default(this, "left" /* Left */);
             this.callbackOpen = (event) => {
                 event.preventDefault();
                 event.stopPropagation();
index c00c886f7dd79bce2b152d0406bba63abd6d3f82..edbfaf2f0389b7cd4b467882582d9595408483e5 100644 (file)
@@ -22,7 +22,7 @@ define(["require", "exports", "tslib", "./Container", "../../../Language", "../.
             this.tabPanels = new Map();
             this.tabs = [];
             this.userMenu = document.querySelector(".userPanel");
-            this.container = new Container_1.default(this);
+            this.container = new Container_1.default(this, "right" /* Right */);
             this.callbackOpen = (event) => {
                 event.preventDefault();
                 event.stopPropagation();
index e1b690e63cff43b70d550f13e4ae434520658a7d..79dae3d87f53253eb1d723048bcdf973cf8e5bda 100644 (file)
@@ -9,8 +9,6 @@
 /* styling for interactive dropdowns (currently only used in the user panel) */
 .interactiveDropdown {
        background-color: $wcfContentBackground;
-       border-radius: 2px;
-       box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
        color: $wcfContentText;
        pointer-events: all;
        position: absolute;
@@ -28,7 +26,7 @@
                display: flex;
                flex-direction: column;
                position: fixed;
-               width: 350px;
+               width: 400px;
 
                // override JS positioning
                bottom: 0 !important;
@@ -51,6 +49,8 @@
        }
 
        @include screen-lg {
+               border-radius: 2px;
+               box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
                position: fixed;
                top: 50px !important;
        }
index 05b55e27216cb35b93a91eaca1f74cb6e36010bd..204744143bc70e1f0e6ba66ce65c61b9467734a1 100644 (file)
 .pageMenuContainer {
-    background-color: rgba(0, 0, 0, 0.34);
-    bottom: 0;
-    display: grid;
-    grid-template-areas: "content";
-    grid-template-columns: auto;
-    left: 0;
-    overflow: hidden;
-    position: fixed;
-    right: 0;
-    top: 50px;
-    z-index: 300;
+       background-color: rgba(0, 0, 0, 0.34);
+       bottom: 0;
+       display: flex;
+       left: 0;
+       overflow: hidden;
+       position: fixed;
+       right: 0;
+       top: 50px;
+       z-index: 300;
+}
+
+@include screen-sm-md {
+       .pageMenuContainer[data-orientation="right"] .pageMenuContent {
+               margin-left: auto;
+       }
+
+       .pageMenuContent {
+               box-shadow: 0 0 20px rgba(0, 0, 0, 0.19), 0 0 6px rgb(0, 0, 0, 0.23);
+               width: 400px;
+       }
 }
 
 .pageMenuContent {
-    --background-color: #{$wcfUserMenuBackground};
-    --background-color-active: #{$wcfUserMenuBackgroundActive};
-    --border-color: #{$wcfUserMenuBorder};
-    --color: #{$wcfUserMenuText};
-    --color-dimmed: #{$wcfUserMenuTextDimmed};
-    --color-indicator: #{$wcfUserMenuIndicator};
+       --background-color: #{$wcfUserMenuBackground};
+       --background-color-active: #{$wcfUserMenuBackgroundActive};
+       --border-color: #{$wcfUserMenuBorder};
+       --color: #{$wcfUserMenuText};
+       --color-dimmed: #{$wcfUserMenuTextDimmed};
+       --color-indicator: #{$wcfUserMenuIndicator};
 
-    background-color: var(--background-color);
-    grid-area: content;
+       background-color: var(--background-color);
+       grid-area: content;
 }
 
 .pageMenuMainContainer {
-    display: flex;
-    flex-direction: column;
-    height: 100%;
+       display: flex;
+       flex-direction: column;
+       height: 100%;
 }
 
 .pageMenuMainNavigationFooter {
-    margin-top: auto;
+       margin-top: auto;
 }
 
 .pageMenuMainItem {
-    border-bottom: 1px solid var(--border-color);
-    position: relative;
+       border-bottom: 1px solid var(--border-color);
+       position: relative;
 }
 
 .pageMenuMainItemExpandable {
-    display: grid;
-    grid-template-areas:
-        "item button"
-        "list list";
-    grid-template-columns: auto 44px;
+       display: grid;
+       grid-template-areas:
+               "item button"
+               "list list";
+       grid-template-columns: auto 44px;
 }
 
 .pageMenuMainItemLink {
-    align-items: center;
-    color: inherit;
-    display: flex;
-    font-weight: 600;
-    grid-area: item;
-    min-height: 44px;
-    padding: 0 10px;
+       align-items: center;
+       color: inherit;
+       display: flex;
+       font-weight: 600;
+       grid-area: item;
+       min-height: 44px;
+       padding: 0 10px;
 }
 
 .pageMenuMainItemToggle {
-    align-items: center;
-    display: flex;
-    justify-content: center;
-    position: relative;
+       align-items: center;
+       display: flex;
+       justify-content: center;
+       position: relative;
 
-    &::before {
-        border-left: 1px solid var(--border-color);
-        bottom: 10px;
-        content: "";
-        left: 0;
-        position: absolute;
-        top: 10px;
-    }
+       &::before {
+               border-left: 1px solid var(--border-color);
+               bottom: 10px;
+               content: "";
+               left: 0;
+               position: absolute;
+               top: 10px;
+       }
 
-    .icon {
-        transform: rotate(0);
-    }
+       .icon {
+               transform: rotate(0);
+       }
 
-    &[aria-expanded="true"] .icon {
-        transform: rotate(180deg);
-    }
+       &[aria-expanded="true"] .icon {
+               transform: rotate(180deg);
+       }
 }
 
 .pageMenuMainItemList {
-    grid-area: list;
+       grid-area: list;
 }
 
 .pageMenuMainItem .pageMenuMainItemList {
-    padding: 10px 0 20px 0;
+       padding: 10px 0 20px 0;
 
-    .pageMenuMainItem {
-        border-bottom-width: 0;
-    }
+       .pageMenuMainItem {
+               border-bottom-width: 0;
+       }
 
-    .pageMenuMainItemLink {
-        font-weight: 400;
-        min-height: 34px;
-        padding-left: 20px;
-    }
+       .pageMenuMainItemLink {
+               font-weight: 400;
+               min-height: 34px;
+               padding-left: 20px;
+       }
 }
 
 .pageMenuMainNavigationFooter .pageMenuMainItem:last-child {
-    border-bottom-width: 0;
+       border-bottom-width: 0;
 }
 
 .pageMenuUserTabContainer {
-    display: flex;
-    flex-direction: column;
-    height: 100%;
+       display: flex;
+       flex-direction: column;
+       height: 100%;
 }
 
 .pageMenuUserTabList {
-    border-bottom: 1px solid var(--border-color);
-    display: grid;
-    grid-auto-columns: minmax(70px, 1fr);
-    grid-auto-flow: column;
-    overflow: auto;
+       border-bottom: 1px solid var(--border-color);
+       display: grid;
+       grid-auto-columns: minmax(70px, 1fr);
+       grid-auto-flow: column;
+       overflow: auto;
 }
 
 .pageMenuUserTab {
-    align-items: center;
-    display: flex;
-    justify-content: center;
-    height: 50px;
-    position: relative;
+       align-items: center;
+       display: flex;
+       justify-content: center;
+       height: 50px;
+       position: relative;
 
-    &:not(:last-child) {
-        border-right: 1px solid var(--border-color);
-    }
+       &:not(:last-child) {
+               border-right: 1px solid var(--border-color);
+       }
 
-    &[aria-selected="true"] {
-        background-color: var(--background-color-active);
-    }
+       &[aria-selected="true"] {
+               background-color: var(--background-color-active);
+       }
 }
 
 .pageMenuUserTabPanel {
-    flex: 1 auto;
+       flex: 1 auto;
 }
 
 @include screen-md-down {
-    .mainMenu[aria-expanded="true"]::before {
-        content: $fa-var-times;
-    }
-
-    .userPanel.userPanelLoggedIn[aria-expanded="true"] {
-        &::before {
-            content: $fa-var-times;
-            color: $wcfHeaderLink;
-            font-family: FontAwesome;
-            font-size: 28px;
-            line-height: 32px;
-            padding: 5px 5px;
-        }
-
-        .userPanelAvatar {
-            display: none;
-        }
-    }
+       .mainMenu[aria-expanded="true"]::before {
+               content: $fa-var-times;
+       }
+
+       .userPanel.userPanelLoggedIn[aria-expanded="true"] {
+               &::before {
+                       content: $fa-var-times;
+                       color: $wcfHeaderLink;
+                       font-family: FontAwesome;
+                       font-size: 28px;
+                       line-height: 32px;
+                       padding: 5px 5px;
+               }
+
+               .userPanelAvatar {
+                       display: none;
+               }
+       }
 }