mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 23:40:14 +01:00
fix(header): adopt for smaller screens
This commit is contained in:
parent
5d543a4eeb
commit
082f72b441
3 changed files with 47 additions and 17 deletions
|
|
@ -18,8 +18,12 @@
|
||||||
</nb-action>
|
</nb-action>
|
||||||
<nb-action class="control-item" icon="email-outline"></nb-action>
|
<nb-action class="control-item" icon="email-outline"></nb-action>
|
||||||
<nb-action class="control-item" icon="bell-outline"></nb-action>
|
<nb-action class="control-item" icon="bell-outline"></nb-action>
|
||||||
<nb-action *nbIsGranted="['view', 'user']" >
|
<nb-action class="user-action" *nbIsGranted="['view', 'user']" >
|
||||||
<nb-user [nbContextMenu]="userMenu" [name]="user?.name" [picture]="user?.picture"></nb-user>
|
<nb-user [nbContextMenu]="userMenu"
|
||||||
|
[onlyPicture]="userPictureOnly"
|
||||||
|
[name]="user?.name"
|
||||||
|
[picture]="user?.picture">
|
||||||
|
</nb-user>
|
||||||
</nb-action>
|
</nb-action>
|
||||||
</nb-actions>
|
</nb-actions>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import '~bootstrap/scss/mixins/breakpoints';
|
||||||
|
@import '~@nebular/theme/styles/global/breakpoints';
|
||||||
@import '../../styles/themes';
|
@import '../../styles/themes';
|
||||||
|
|
||||||
@include nb-install-component() {
|
@include nb-install-component() {
|
||||||
|
|
@ -5,17 +7,6 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.left {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
order: 0;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
.right {
|
|
||||||
order: 1;
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-container {
|
.logo-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -60,4 +51,20 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@include media-breakpoint-down(sm) {
|
||||||
|
.control-item {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.user-action {
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@include media-breakpoint-down(is) {
|
||||||
|
nb-select {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
|
import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
|
||||||
|
|
||||||
import { UserData } from '../../../@core/data/users';
|
import { UserData } from '../../../@core/data/users';
|
||||||
import { LayoutService } from '../../../@core/utils';
|
import { LayoutService } from '../../../@core/utils';
|
||||||
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
|
import { pipe, Subject } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-header',
|
selector: 'ngx-header',
|
||||||
styleUrls: ['./header.component.scss'],
|
styleUrls: ['./header.component.scss'],
|
||||||
templateUrl: './header.component.html',
|
templateUrl: './header.component.html',
|
||||||
})
|
})
|
||||||
export class HeaderComponent implements OnInit {
|
export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
private destroy$: Subject<void> = new Subject<void>();
|
||||||
|
userPictureOnly: boolean = false;
|
||||||
user: any;
|
user: any;
|
||||||
|
|
||||||
themes = [
|
themes = [
|
||||||
|
|
@ -40,12 +44,27 @@ export class HeaderComponent implements OnInit {
|
||||||
private menuService: NbMenuService,
|
private menuService: NbMenuService,
|
||||||
private themeService: NbThemeService,
|
private themeService: NbThemeService,
|
||||||
private userService: UserData,
|
private userService: UserData,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService,
|
||||||
|
private breakpointService: NbMediaBreakpointsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.userService.getUsers()
|
this.userService.getUsers()
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe((users: any) => this.user = users.nick);
|
.subscribe((users: any) => this.user = users.nick);
|
||||||
|
|
||||||
|
const { xl } = this.breakpointService.getBreakpointsMap();
|
||||||
|
this.themeService.onMediaQueryChange()
|
||||||
|
.pipe(
|
||||||
|
map(([, currentBreakpoint]) => currentBreakpoint.width < xl),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
.subscribe((isLessThanXl: boolean) => this.userPictureOnly = isLessThanXl);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleTheme() {
|
toggleTheme() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue