Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/material theme #5804

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"output": "/assets/img/markers"
}
],
"stylePreprocessorOptions": {
"includePaths": [
"node_modules"
]
},
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.css",
"node_modules/typeface-exo/index.css",
Expand Down
11,021 changes: 5,222 additions & 5,799 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@angular/platform-browser": "^15.2.10",
"@angular/platform-browser-dynamic": "^15.2.10",
"@angular/router": "^15.2.10",
"@angular/material": "^15.2.9",
"@asymmetrik/ngx-leaflet": "3.0.1",
"@nebular/auth": "11.0.1",
"@nebular/eva-icons": "11.0.1",
Expand All @@ -62,7 +63,6 @@
"ng2-completer": "^9.0.1",
"ng2-smart-table": "^1.6.0",
"ngx-echarts": "^4.2.2",
"node-sass": "^4.14.1",
"normalize.css": "6.0.0",
"pace-js": "1.0.2",
"roboto-fontface": "0.8.0",
Expand Down
3 changes: 3 additions & 0 deletions src/app/@core/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MAT_RIPPLE_GLOBAL_OPTIONS } from '@angular/material/core';
import { NbAuthModule, NbDummyAuthStrategy } from '@nebular/auth';
import { NbSecurityModule, NbRoleProvider } from '@nebular/security';
import { of as observableOf } from 'rxjs';
Expand Down Expand Up @@ -51,6 +52,7 @@ import { CountryOrderService } from './mock/country-order.service';
import { StatsProgressBarService } from './mock/stats-progress-bar.service';
import { VisitorsAnalyticsService } from './mock/visitors-analytics.service';
import { SecurityCamerasService } from './mock/security-cameras.service';
import { RippleService } from './utils/ripple.service';
import { MockDataModule } from './mock/mock-data.module';

const socialLinks = [
Expand Down Expand Up @@ -91,6 +93,7 @@ const DATA_SERVICES = [
{ provide: StatsProgressBarData, useClass: StatsProgressBarService },
{ provide: VisitorsAnalyticsData, useClass: VisitorsAnalyticsService },
{ provide: SecurityCamerasData, useClass: SecurityCamerasService },
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useExisting: RippleService},
];

export class NbSimpleRoleProvider extends NbRoleProvider {
Expand Down
11 changes: 11 additions & 0 deletions src/app/@core/utils/ripple.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@angular/core';
import { RippleGlobalOptions } from '@angular/material/core';

@Injectable({providedIn: 'root'})
export class RippleService implements RippleGlobalOptions {
public disabled: boolean = false;

public toggle(enabled: boolean): void {
this.disabled = !enabled;
}
}
55 changes: 46 additions & 9 deletions src/app/@theme/components/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,61 @@
<div class="header-container">
<div class="logo-container">
<a (click)="toggleSidebar()" href="#" class="sidebar-toggle">
<nb-icon icon="menu-2-outline"></nb-icon>
<a
href="#"
class="sidebar-toggle"
matRipple
[matRippleUnbounded]="true"
[matRippleCentered]="true"
(click)="toggleSidebar()"
>
<nb-icon [icon]="(materialTheme$ | async) ? 'menu-outline' : 'menu-2-outline'"></nb-icon>
</a>
<a class="logo" href="#" (click)="navigateHome()">ngx-<span>admin</span></a>
</div>
<nb-select [selected]="currentTheme" (selectedChange)="changeTheme($event)" status="primary">
<nb-option *ngFor="let theme of themes" [value]="theme.value"> {{ theme.name }}</nb-option>
<nb-select
status="primary"
matRipple
[selected]="currentTheme"
(selectedChange)="changeTheme($event)"
>
<nb-option
*ngFor="let theme of themes"
[value]="theme.value"
matRipple
>{{ theme.name }}</nb-option>
</nb-select>
</div>

<div class="header-container">
<nb-actions size="small">

<nb-action class="control-item">
<nb-search type="rotate-layout"></nb-search>
</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="user-action" *nbIsGranted="['view', 'user']" >
<nb-search
type="rotate-layout"
matRipple
[matRippleUnbounded]="true"
[matRippleCentered]="true"
></nb-search></nb-action>
<nb-action
class="control-item"
icon="email-outline"
matRipple
[matRippleUnbounded]="true"
[matRippleCentered]="true"
></nb-action>
<nb-action
class="control-item"
icon="bell-outline"
matRipple
[matRippleUnbounded]="true"
[matRippleCentered]="true"
></nb-action>
<nb-action
class="user-action"
*nbIsGranted="['view', 'user']"
matRipple
[matRippleUnbounded]="true"
[matRippleCentered]="true">
<nb-user [nbContextMenu]="userMenu"
[onlyPicture]="userPictureOnly"
[name]="user?.name"
Expand Down
4 changes: 2 additions & 2 deletions src/app/@theme/components/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
width: auto;

.sidebar-toggle {
@include nb-ltr(padding-right, 1.25rem);
@include nb-rtl(padding-left, 1.25rem);
@include nb-ltr(margin-right, 1.25rem);
@include nb-rtl(margin-left, 1.25rem);
text-decoration: none;
color: nb-theme(text-hint-color);
nb-icon {
Expand Down
37 changes: 29 additions & 8 deletions src/app/@theme/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeServ
import { UserData } from '../../../@core/data/users';
import { LayoutService } from '../../../@core/utils';
import { map, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { Subject, Observable } from 'rxjs';
import { RippleService } from '../../../@core/utils/ripple.service';

@Component({
selector: 'ngx-header',
Expand All @@ -14,6 +15,7 @@ import { Subject } from 'rxjs';
export class HeaderComponent implements OnInit, OnDestroy {

private destroy$: Subject<void> = new Subject<void>();
public readonly materialTheme$: Observable<boolean>;
userPictureOnly: boolean = false;
user: any;

Expand All @@ -34,18 +36,34 @@ export class HeaderComponent implements OnInit, OnDestroy {
value: 'corporate',
name: 'Corporate',
},
{
value: 'material-light',
name: 'Material Light',
},
{
value: 'material-dark',
name: 'Material Dark',
},
];

currentTheme = 'default';

userMenu = [ { title: 'Profile' }, { title: 'Log out' } ];

constructor(private sidebarService: NbSidebarService,
private menuService: NbMenuService,
private themeService: NbThemeService,
private userService: UserData,
private layoutService: LayoutService,
private breakpointService: NbMediaBreakpointsService) {
public constructor(
private sidebarService: NbSidebarService,
private menuService: NbMenuService,
private themeService: NbThemeService,
private userService: UserData,
private layoutService: LayoutService,
private breakpointService: NbMediaBreakpointsService,
private rippleService: RippleService,
) {
this.materialTheme$ = this.themeService.onThemeChange()
.pipe(map(theme => {
const themeName: string = theme?.name || '';
return themeName.startsWith('material');
}));
}

ngOnInit() {
Expand All @@ -68,7 +86,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
map(({ name }) => name),
takeUntil(this.destroy$),
)
.subscribe(themeName => this.currentTheme = themeName);
.subscribe(themeName => {
this.currentTheme = themeName;
this.rippleService.toggle(themeName?.startsWith('material'));
});
}

ngOnDestroy() {
Expand Down
11 changes: 11 additions & 0 deletions src/app/@theme/styles/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@
right: 0.41rem !important;
}
}

nb-card nb-list {
@include nb-scrollbars(
nb-theme(card-scrollbar-color),
nb-theme(card-scrollbar-background-color),
nb-theme(card-scrollbar-width));
}

.table {
color: nb-theme(text-basic-color) !important;
}
}
19 changes: 19 additions & 0 deletions src/app/@theme/styles/material/_angular-material.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@use '@angular/material' as mat;

@mixin angular-material() {
@include mat.core();

@include nb-for-theme(material-dark) {
$custom-dark-theme: mat.define-dark-theme(
mat.define-palette(mat.$pink-palette),
mat.define-palette(mat.$blue-grey-palette));
@include mat.all-component-themes($custom-dark-theme);
}

@include nb-for-theme(material-light) {
$custom-light-theme: mat.define-light-theme(
mat.define-palette(mat.$indigo-palette),
mat.define-palette(mat.$pink-palette));
@include mat.all-component-themes($custom-light-theme);
}
}
Loading