OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#52670] rework main menu resizer
Eric Schubert9d9430f2e984
diff --git a/frontend/src/app/shared/components/grids/grid/grid.component.html b/frontend/src/app/shared/components/grids/grid/grid.component.htmlindex 059697732fa..b6ae6f2af04 100644--- a/frontend/src/app/shared/components/grids/grid/grid.component.html+++ b/frontend/src/app/shared/components/grids/grid/grid.component.html@@ -35,17 +35,17 @@[ndcDynamicOutputs]="widgetComponentOutput(area)"></ndc-dynamic></div>- <resizer *ngIf="resize.isResizable"+ <op-resizer *ngIf="resize.isResizable"[customHandler]="true"- (end)="resize.end(area)"- (start)="resize.start(area)"+ (resizeFinished)="resize.end(area)"+ (resizeStarted)="resize.start(area)"(move)="resize.moving()"><div class="grid--resizer"><i class="icon-resizer-bottom-right hidden-for-mobile"aria-hidden="true"></i></div>- </resizer>+ </op-resizer></div><!-- One grid area per cell (row x columns) -->diff --git a/frontend/src/app/shared/components/resizer/resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer.component.tsindex 7d6dbd3384e..5383a9f50af 100644--- a/frontend/src/app/shared/components/resizer/resizer.component.ts+++ b/frontend/src/app/shared/components/resizer/resizer.component.ts@@ -1,10 +1,45 @@+// -- copyright+// OpenProject is an open source project management software.+// Copyright (C) 2012-2024 the OpenProject GmbH+//+// This program is free software; you can redistribute it and/or+// modify it under the terms of the GNU General Public License version 3.+//+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+// Copyright (C) 2006-2013 Jean-Philippe Lang+// Copyright (C) 2010-2013 the ChiliProject Team+//+// This program is free software; you can redistribute it and/or+// modify it under the terms of the GNU General Public License+// as published by the Free Software Foundation; either version 2+// of the License, or (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+//+// See COPYRIGHT and LICENSE files for more details.+//+++import {- Component, EventEmitter, HostListener, Input, OnDestroy, Output,+ ChangeDetectionStrategy,+ Component,+ EventEmitter,+ HostListener,+ Input,+ OnDestroy,+ Output,} from '@angular/core';+import { setBodyCursor } from 'core-app/shared/helpers/dom/set-window-cursor.helper';export interface ResizeDelta {- origin:any;+ origin:UIEvent;// Absolute difference from startabsolute:{@@ -20,8 +55,9 @@ export interface ResizeDelta {}@Component({- selector: 'resizer',+ selector: 'op-resizer',templateUrl: './resizer.component.html',+ changeDetection: ChangeDetectionStrategy.OnPush,})export class ResizerComponent implements OnDestroy {private startX:number;@@ -40,13 +76,11 @@ export class ResizerComponent implements OnDestroy {private mouseUpHandler:EventListener;- private resizing = false;+ @Output() resizeFinished:EventEmitter<ResizeDelta> = new EventEmitter<ResizeDelta>();- @Output() end:EventEmitter<ResizeDelta> = new EventEmitter();+ @Output() resizeStarted:EventEmitter<ResizeDelta> = new EventEmitter<ResizeDelta>();- @Output() start:EventEmitter<ResizeDelta> = new EventEmitter();-- @Output() move:EventEmitter<ResizeDelta> = new EventEmitter();+ @Output() move:EventEmitter<ResizeDelta> = new EventEmitter<ResizeDelta>();@Input() customHandler = false;@@ -60,50 +94,64 @@ export class ResizerComponent implements OnDestroy {@HostListener('mousedown', ['$event'])@HostListener('touchstart', ['$event'])- public startResize(event:any) {+ // public startResize(event:any) {+ public startResize(event:MouseEvent|TouchEvent) {event.preventDefault();event.stopPropagation();- // Only on left mouse click the resizing is started- if (event.buttons === 1 || event.which === 1 || event.which === 0) {- // Getting starting position- this.oldX = this.startX = event.clientX || event.pageX || event.touches[0].clientX;- this.oldY = this.startY = event.clientY || event.pageY || event.touches[0].clientY;+ if (this.isMouseEvent(event) && event.button !== 0) {+ // Only handle primary mouse button clicks+ return;+ }- this.newX = event.clientX || event.pageX || event.touches[0].clientX;- this.newY = event.clientY || event.pageY || event.touches[0].clientY;+ const { x, y } = this.position(event);+ this.oldX = x;+ this.startX = x;+ this.newX = x;+ this.oldY = y;+ this.startY = y;+ this.newY = y;++ this.setResizeCursor();+ this.bindEventListener();+ this.resizeStarted.emit(this.buildDelta(event));+ }- this.resizing = true;+ private position(event:MouseEvent|TouchEvent):{ x:number, y:number } {+ if (this.isMouseEvent(event)) {+ return { x: event.clientX, y: event.clientY };+ }- this.setResizeCursor();- this.bindEventListener(event);+ return { x: event.touches[0].clientX, y: event.touches[0].clientY };+ }- this.start.emit(this.buildDelta(event));- }+ private isMouseEvent(event:MouseEvent|TouchEvent):event is MouseEvent {+ return event instanceof MouseEvent;}- private onMouseUp(event:any) {+ private onMouseUp(event:MouseEvent|TouchEvent) {this.setAutoCursor();this.removeEventListener();- this.end.emit(this.buildDelta(event));+ this.resizeFinished.emit(this.buildDelta(event));}- private onMouseMove(event:any) {+ private onMouseMove(event:MouseEvent|TouchEvent) {event.preventDefault();event.stopPropagation();this.oldX = this.newX;this.oldY = this.newY;- this.newX = event.clientX || event.pageX || event.touches[0].clientX;- this.newY = event.clientY || event.pageY || event.touches[0].clientX;+ const { x, y } = this.position(event);+ this.newX = x;+ this.newY = y;this.move.emit(this.buildDelta(event));}// Necessary to encapsulate this to be able to remove the event listener later- private bindEventListener(event:any) {+ private bindEventListener() {this.mouseMoveHandler = this.onMouseMove.bind(this);this.mouseUpHandler = this.onMouseUp.bind(this);@@ -128,7 +176,7 @@ export class ResizerComponent implements OnDestroy {setBodyCursor('auto');}- private buildDelta(event:any):ResizeDelta {+ private buildDelta(event:MouseEvent|TouchEvent):ResizeDelta {return {origin: event,absolute: {@@ -137,7 +185,7 @@ export class ResizerComponent implements OnDestroy {},relative: {x: this.newX - this.oldX,- y: this.newY - this.oldX,+ y: this.newY - this.oldY,},};}diff --git a/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.tsindex 0fd310b08de..51a1ec5d791 100644--- a/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts+++ b/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts@@ -27,9 +27,14 @@//++import {- ChangeDetectorRef, Component, ElementRef, OnInit,+ ChangeDetectionStrategy,+ ChangeDetectorRef,+ Component,+ ElementRef,+ OnInit,} from '@angular/core';import { distinctUntilChanged } from 'rxjs/operators';+import { ResizeDelta } from 'core-app/shared/components/resizer/resizer.component';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { MainMenuToggleService } from 'core-app/core/main-menu/main-menu-toggle.service';@@ -38,23 +43,28 @@ export const mainMenuResizerSelector = 'main-menu-resizer';@Component({selector: mainMenuResizerSelector,+ changeDetection: ChangeDetectionStrategy.OnPush,template: `- <resizer class="main-menu--resizer"- [customHandler]="true"- [cursorClass]="'col-resize'"- (end)="resizeEnd()"- (start)="resizeStart()"- (move)="resizeMove($event)">- <div class="resizer-toggle-container">- <button- class="spot-link main-menu--navigation-toggler"- [attr.title]="toggleTitle"- [class.open]="toggleService.showNavigation"- (click)="toggleService.toggleNavigation($event)">- <op-icon icon-classes="icon-resizer-vertical-lines"></op-icon>- </button>- </div>- </resizer>+ <op-resizer class="main-menu--resizer"+ [customHandler]="true"+ [cursorClass]="'col-resize'"+ (resizeFinished)="resizeEnd()"+ (resizeStarted)="resizeStart()"+ (move)="resizeMove($event)">+ <!-- <div class="resizer-toggle-container">-->+ <button+ class="spot-link main-menu--navigation-toggler"+ [attr.title]="toggleTitle"+ [class.open]="toggleService.showNavigation"+ (click)="toggleService.toggleNavigation($event)"+ >+ <span class="spot-icon spot-icon_1"></span>+<!-- <span class="spot-icon spot-icon_1 spot-icon_resizer-vertical-lines"></span>-->+<!-- <span class="collapse-menu spot-icon spot-icon_1 spot-icon_arrow-left2"></span>-->+<!-- <span class="open-menu spot-icon spot-icon_1 spot-icon_arrow-right2"></span>-->+ </button>+ <!-- </div>-->+ </op-resizer>`,})@@ -71,9 +81,11 @@ export class MainMenuResizerComponent extends UntilDestroyedMixin implements OnIpublic moving = false;- constructor(readonly toggleService:MainMenuToggleService,+ constructor(+ readonly toggleService:MainMenuToggleService,readonly cdRef:ChangeDetectorRef,- readonly elementRef:ElementRef) {+ readonly elementRef:ElementRef,+ ) {super();}diff --git a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.tsindex 5b8a939ca20..eca03af8bea 100644--- a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts+++ b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts@@ -40,13 +40,13 @@ import { MainMenuToggleService } from 'core-app/core/main-menu/main-menu-toggle.@Component({selector: 'wp-resizer',template: `- <resizer [customHandler]="false"+ <op-resizer [customHandler]="false"[resizerClass]="resizerClass"cursorClass="col-resize"- (end)="resizeEnd()"- (start)="resizeStart()"+ (resizeFinished)="resizeEnd()"+ (resizeStarted)="resizeStart()"(move)="resizeMove($event)">- </resizer>+ </op-resizer>`,changeDetection: ChangeDetectionStrategy.OnPush,})diff --git a/frontend/src/global_styles/layout/_main_menu.sass b/frontend/src/global_styles/layout/_main_menu.sassindex 698ae8e68c3..e07790f563b 100644--- a/frontend/src/global_styles/layout/_main_menu.sass+++ b/frontend/src/global_styles/layout/_main_menu.sass@@ -26,6 +26,8 @@// See COPYRIGHT and LICENSE files for more details.//+++@import "app/spot/styles/sass/common/icon"+$menu-item-line-height: 30px$arrow-left-width: 40px@@ -64,7 +66,8 @@ $arrow-left-width: 40pxheight: 100%.main-menu--children- height: calc(100% - (var(--main-menu-item-height) + 10px)) // 10px spacing+ height: calc(100% - (var(--main-menu-item-height) + 10px))+ // 10px spacingoverflow: auto@include styled-scroll-bar@@ -97,9 +100,11 @@ $arrow-left-width: 40px// work around due to dom manipulation on document: ready:// this isn't scoped to .main-item-wrapper to avoid flickeringpadding-left: 12px+&.toggler// explicitly reset to zero to avoid selector precedence problemspadding-left: 0+.main-menu--children li a// children have no icon so we need to push them right.padding-left: 24px@@ -115,6 +120,7 @@ $arrow-left-width: 40pxfont-size: var(--main-menu-font-size)font-style: normalpadding: 0 12px+&:hovertext-decoration: none@@ -139,16 +145,17 @@ $arrow-left-width: 40pxaborder: 1px solid transparent+&.selected, &.selected + a@include main-menu-selected&:hover@include main-menu-hover- &:hover, &:focus , &:active+ &:hover, &:focus, &:active@include main-menu-hover- &~ .toggler+ & ~ .toggler@include main-menu-hovera:not(.toggler)@@ -163,8 +170,10 @@ $arrow-left-width: 40pxdisplay: nonepadding: 10px 0width: 100%+&.unattachedborder-top: 1px solid #ddd+li&:hover// simultaneously hover all menu item anchor tags@@ -174,7 +183,8 @@ $arrow-left-width: 40px> a&.selected, &.selected@include main-menu-selected- &:hover, &:focus , &:active++ &:hover, &:focus, &:active@include main-menu-hover.main-menu--children-menu-header@@ -189,6 +199,7 @@ $arrow-left-width: 40pxpadding-left: 14pxpadding-right: 14pxborder: 1px solid transparent+&:hover, &:focus, &:active@include main-menu-hover@@ -203,6 +214,7 @@ a.main-menu--parent-nodeline-height: var(--main-menu-item-height)border-radius: 3pxcolor: var(--main-menu-font-color)+&:hover, &:focus, &:active@include main-menu-hover@@ -212,6 +224,7 @@ a.main-menu--parent-node&.closedlidisplay: none+> li.opendisplay: list-item@@ -226,11 +239,14 @@ a.main-menu--parent-node.main-menu--childrendisplay: block+lidisplay: list-item+&.open> lidisplay: list-item+.main-menu--children-menu-headerdisplay: none@@ -238,6 +254,7 @@ a.main-menu--parent-node.main-menuwidth: var(--main-menu-folded-width)min-width: var(--main-menu-folded-width)+ul&.menu_root> li@@ -249,6 +266,7 @@ a.main-menu--parent-nodetext-overflow: clip-o-text-overflow: clip-ms-text-overflow: clip+.togglerdisplay: none@@ -285,8 +303,10 @@ a.main-menu--parent-nodeulborder: noneoverflow-x: hidden+liborder: none+li apadding: 0@@ -299,13 +319,17 @@ a.main-menu--parent-node#main-menu ul ul.main-menu--children ul.pages-hierarchy.tree-menu--hierarchy-indicatorcolor: var(--main-menu-font-color)+.tree-menu--item&.-selectedbackground: var(--main-menu-bg-selected-background)+.tree-menu--titlecolor: var(--main-menu-selected-font-color)+&:hoverbackground: var(--main-menu-bg-hover-background)+.tree-menu--titlecolor: var(--main-menu-hover-font-color)text-decoration: none@@ -313,50 +337,36 @@ a.main-menu--parent-node// Resizer & toggle styles.main-menu--resizerbackground: none- height: 100vh- width: 18px+ height: 100%+ width: 1remposition: fixed- top: 0- border-left-width: 2px- border-left-style: solid- border-left-color: transparent- left: calc(var(--main-menu-width) - 2px)- vertical-align: middle+ display: flex+ align-items: center+ left: calc(var(--main-menu-width) - 1rem)z-index: 1cursor: col-resize- &:hover- border-left-color: var(--main-menu-resizer-color)- i:before- color: var(--main-menu-resizer-color)- &.show- left: var(--main-menu-folded-width)--.resizer-toggle-container- margin-top: 50vh- margin-left: -12px- display: inline-block+.main-menu--navigation-toggler+ position: relativecursor: pointer- &:before- @include icon-common- font-size: 11px- font-weight: 400- &:not(.open):before- @include icon-mixin-arrow-right2- position: absolute- right: 0- &:hover- color: var(--main-menu-resizer-color)- .main-menu--navigation-toggler- background-color: var(--main-menu-bg-color)- &.open:before- @include icon-mixin-arrow-left2- i- display: inline-block- width: 12px- &:before- vertical-align: middle- color: var(--light-gray)+ color: var(--main-menu-font-color)++ > .spot-icon:before+ @include spot-icon_resizer-vertical-lines++ &:hover+ > .spot-icon:before+ @include spot-icon_arrow-left2++ &:not(.open)+ left: 1rem+ color: var(--accent-color)++ > .spot-icon:before+ @include spot-icon_arrow-right2++ &:hover .main-menu--navigation-toggler+ color: var(--accent-color)// Badges for menu items such as "EXPERIMENTAL" or "BETA"$badge_offset: 4px