2423 - Hide left menu
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-07-16 12:10:44 +02:00
parent d46c9bbfa7
commit eb1bf5bf58
4 changed files with 36 additions and 14 deletions

View File

@ -3,7 +3,7 @@
icon="menu" icon="menu"
class="show-menu" class="show-menu"
ng-if="$ctrl.leftMenu" ng-if="$ctrl.leftMenu"
ng-click="$ctrl.leftMenu.show()"> ng-click="$ctrl.leftMenu.toggle()">
</vn-icon-button> </vn-icon-button>
<div class="side start"> <div class="side start">
<a class="logo" ui-sref="home" title="{{'Home' | translate}}"> <a class="logo" ui-sref="home" title="{{'Home' | translate}}">

View File

@ -46,7 +46,7 @@ vn-layout {
justify-content: flex-end; justify-content: flex-end;
} }
.show-menu { .show-menu {
display: none; margin-right: 5px
} }
.vn-button { .vn-button {
color: inherit; color: inherit;
@ -68,7 +68,7 @@ vn-layout {
& > vn-topbar > .start { & > vn-topbar > .start {
width: 80px + $menu-width; width: 80px + $menu-width;
} }
& > .main-view { &.shown > .main-view {
padding-left: $menu-width; padding-left: $menu-width;
} }
} }
@ -85,6 +85,8 @@ vn-layout {
} }
& > .main-view { & > .main-view {
padding-top: $topbar-height; padding-top: $topbar-height;
transition: padding-left 200ms ease-out;
} }
ui-view { ui-view {
& > * { & > * {
@ -134,7 +136,8 @@ vn-layout {
& > vn-topbar { & > vn-topbar {
left: 0; left: 0;
} }
& > .main-view { & > .main-view,
&.shown > .main-view {
padding-left: 0; padding-left: 0;
} }
} }

View File

@ -26,6 +26,11 @@ export default class SideMenu extends Component {
this.layout.leftMenu = this; this.layout.leftMenu = this;
this.layout.element.classList.add('left-menu'); this.layout.element.classList.add('left-menu');
} }
const stateParts = this.$state.current.name.split('.');
if (stateParts[1] === 'card') this.show();
this.stateHandler = this.$transitions.onStart({}, t => this.onTransition(t));
} }
$onDestroy() { $onDestroy() {
@ -48,8 +53,19 @@ export default class SideMenu extends Component {
} }
onTransition(transition) { onTransition(transition) {
if (transition.from().name !== transition.to().name) const stateParts = transition.to().name.split('.');
this.hide();
if (transition.from().name !== transition.to().name) {
if (stateParts[1] === 'card')
this.show();
else
this.hide();
}
}
toggle() {
if (this.shown) this.hide();
else this.show();
} }
show() { show() {
@ -58,6 +74,7 @@ export default class SideMenu extends Component {
this.handler = e => this.onEscape(e); this.handler = e => this.onEscape(e);
this.$window.addEventListener('keydown', this.handler); this.$window.addEventListener('keydown', this.handler);
this.stateHandler = this.$transitions.onStart({}, t => this.onTransition(t)); this.stateHandler = this.$transitions.onStart({}, t => this.onTransition(t));
this.layout.element.classList.add('shown');
} }
hide() { hide() {
@ -65,6 +82,7 @@ export default class SideMenu extends Component {
this.$window.removeEventListener('keydown', this.handler); this.$window.removeEventListener('keydown', this.handler);
this.stateHandler(); this.stateHandler();
this.shown = false; this.shown = false;
this.layout.element.classList.remove('shown');
} }
} }

View File

@ -14,28 +14,29 @@ vn-side-menu > .menu {
box-shadow: 0 1px 3px $color-shadow; box-shadow: 0 1px 3px $color-shadow;
overflow: auto; overflow: auto;
top: $topbar-height; top: $topbar-height;
transition: transform 200ms ease-out;
&.left { &.left {
left: 0; transform: translateZ(0) translateX(-$menu-width);
} }
&.right { &.right {
right: 0; transform: translateZ(0) translateX($menu-width);
}
&.shown {
transform: translateZ(0) translateX(0);
} }
@media screen and (max-width: $mobile-width) { @media screen and (max-width: $mobile-width) {
transition: transform 200ms ease-out;
z-index: 15; z-index: 15;
top: 0; top: 0;
&.left { &.left {
transform: translateZ(0) translateX(-$menu-width); transform: 0;
} }
&.right { &.right {
top: 0; top: 0;
transform: translateZ(0) translateX($menu-width); transform: 0;
}
&.shown {
transform: translateZ(0) translateX(0);
} }
} }
} }