Skip to content

Commit 0eec546

Browse files
committed
feat: add material themes
1 parent cabe4bd commit 0eec546

File tree

70 files changed

+2622
-896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2622
-896
lines changed

package-lock.json

Lines changed: 208 additions & 646 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@angular/core": "^12.1.0",
3939
"@angular/forms": "^12.1.0",
4040
"@angular/google-maps": "^12.1.0",
41+
"@angular/material": "^12.1.0",
4142
"@angular/platform-browser": "^12.1.0",
4243
"@angular/platform-browser-dynamic": "^12.1.0",
4344
"@angular/router": "^12.1.0",
@@ -62,7 +63,6 @@
6263
"ng2-ckeditor": "^1.2.9",
6364
"ng2-smart-table": "^1.6.0",
6465
"ngx-echarts": "^4.2.2",
65-
"node-sass": "^4.12.0",
6666
"normalize.css": "6.0.0",
6767
"pace-js": "1.0.2",
6868
"roboto-fontface": "0.8.0",

src/app/@core/core.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3+
import { MAT_RIPPLE_GLOBAL_OPTIONS } from '@angular/material/core';
34
import { NbAuthModule, NbDummyAuthStrategy } from '@nebular/auth';
45
import { NbSecurityModule, NbRoleProvider } from '@nebular/security';
56
import { of as observableOf } from 'rxjs';
@@ -51,6 +52,7 @@ import { CountryOrderService } from './mock/country-order.service';
5152
import { StatsProgressBarService } from './mock/stats-progress-bar.service';
5253
import { VisitorsAnalyticsService } from './mock/visitors-analytics.service';
5354
import { SecurityCamerasService } from './mock/security-cameras.service';
55+
import { RippleService } from './utils/ripple.service';
5456
import { MockDataModule } from './mock/mock-data.module';
5557

5658
const socialLinks = [
@@ -91,6 +93,7 @@ const DATA_SERVICES = [
9193
{ provide: StatsProgressBarData, useClass: StatsProgressBarService },
9294
{ provide: VisitorsAnalyticsData, useClass: VisitorsAnalyticsService },
9395
{ provide: SecurityCamerasData, useClass: SecurityCamerasService },
96+
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useExisting: RippleService},
9497
];
9598

9699
export class NbSimpleRoleProvider extends NbRoleProvider {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Injectable } from '@angular/core';
2+
import { RippleGlobalOptions } from '@angular/material/core';
3+
4+
@Injectable({providedIn: 'root'})
5+
export class RippleService implements RippleGlobalOptions {
6+
public disabled: boolean = false;
7+
8+
public toggle(enabled: boolean): void {
9+
this.disabled = !enabled;
10+
}
11+
}

src/app/@theme/components/header/header.component.html

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,61 @@
11
<div class="header-container">
22
<div class="logo-container">
3-
<a (click)="toggleSidebar()" href="#" class="sidebar-toggle">
4-
<nb-icon icon="menu-2-outline"></nb-icon>
3+
<a
4+
href="#"
5+
class="sidebar-toggle"
6+
matRipple
7+
[matRippleUnbounded]="true"
8+
[matRippleCentered]="true"
9+
(click)="toggleSidebar()"
10+
>
11+
<nb-icon [icon]="(materialTheme$ | async) ? 'menu-outline' : 'menu-2-outline'"></nb-icon>
512
</a>
613
<a class="logo" href="#" (click)="navigateHome()">ngx-<span>admin</span></a>
714
</div>
8-
<nb-select [selected]="currentTheme" (selectedChange)="changeTheme($event)" status="primary">
9-
<nb-option *ngFor="let theme of themes" [value]="theme.value"> {{ theme.name }}</nb-option>
15+
<nb-select
16+
status="primary"
17+
matRipple
18+
[selected]="currentTheme"
19+
(selectedChange)="changeTheme($event)"
20+
>
21+
<nb-option
22+
*ngFor="let theme of themes"
23+
[value]="theme.value"
24+
matRipple
25+
>{{ theme.name }}</nb-option>
1026
</nb-select>
1127
</div>
1228

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

1632
<nb-action class="control-item">
17-
<nb-search type="rotate-layout"></nb-search>
18-
</nb-action>
19-
<nb-action class="control-item" icon="email-outline"></nb-action>
20-
<nb-action class="control-item" icon="bell-outline"></nb-action>
21-
<nb-action class="user-action" *nbIsGranted="['view', 'user']" >
33+
<nb-search
34+
type="rotate-layout"
35+
matRipple
36+
[matRippleUnbounded]="true"
37+
[matRippleCentered]="true"
38+
></nb-search></nb-action>
39+
<nb-action
40+
class="control-item"
41+
icon="email-outline"
42+
matRipple
43+
[matRippleUnbounded]="true"
44+
[matRippleCentered]="true"
45+
></nb-action>
46+
<nb-action
47+
class="control-item"
48+
icon="bell-outline"
49+
matRipple
50+
[matRippleUnbounded]="true"
51+
[matRippleCentered]="true"
52+
></nb-action>
53+
<nb-action
54+
class="user-action"
55+
*nbIsGranted="['view', 'user']"
56+
matRipple
57+
[matRippleUnbounded]="true"
58+
[matRippleCentered]="true">
2259
<nb-user [nbContextMenu]="userMenu"
2360
[onlyPicture]="userPictureOnly"
2461
[name]="user?.name"

src/app/@theme/components/header/header.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
width: auto;
3434

3535
.sidebar-toggle {
36-
@include nb-ltr(padding-right, 1.25rem);
37-
@include nb-rtl(padding-left, 1.25rem);
36+
@include nb-ltr(margin-right, 1.25rem);
37+
@include nb-rtl(margin-left, 1.25rem);
3838
text-decoration: none;
3939
color: nb-theme(text-hint-color);
4040
nb-icon {

src/app/@theme/components/header/header.component.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeServ
44
import { UserData } from '../../../@core/data/users';
55
import { LayoutService } from '../../../@core/utils';
66
import { map, takeUntil } from 'rxjs/operators';
7-
import { Subject } from 'rxjs';
7+
import { Subject, Observable } from 'rxjs';
8+
import { RippleService } from '../../../@core/utils/ripple.service';
89

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

1617
private destroy$: Subject<void> = new Subject<void>();
18+
public readonly materialTheme$: Observable<boolean>;
1719
userPictureOnly: boolean = false;
1820
user: any;
1921

@@ -34,18 +36,34 @@ export class HeaderComponent implements OnInit, OnDestroy {
3436
value: 'corporate',
3537
name: 'Corporate',
3638
},
39+
{
40+
value: 'material-light',
41+
name: 'Material Light',
42+
},
43+
{
44+
value: 'material-dark',
45+
name: 'Material Dark',
46+
},
3747
];
3848

3949
currentTheme = 'default';
4050

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

43-
constructor(private sidebarService: NbSidebarService,
44-
private menuService: NbMenuService,
45-
private themeService: NbThemeService,
46-
private userService: UserData,
47-
private layoutService: LayoutService,
48-
private breakpointService: NbMediaBreakpointsService) {
53+
public constructor(
54+
private sidebarService: NbSidebarService,
55+
private menuService: NbMenuService,
56+
private themeService: NbThemeService,
57+
private userService: UserData,
58+
private layoutService: LayoutService,
59+
private breakpointService: NbMediaBreakpointsService,
60+
private rippleService: RippleService,
61+
) {
62+
this.materialTheme$ = this.themeService.onThemeChange()
63+
.pipe(map(theme => {
64+
const themeName: string = theme?.name || '';
65+
return themeName.startsWith('material');
66+
}));
4967
}
5068

5169
ngOnInit() {
@@ -68,7 +86,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
6886
map(({ name }) => name),
6987
takeUntil(this.destroy$),
7088
)
71-
.subscribe(themeName => this.currentTheme = themeName);
89+
.subscribe(themeName => {
90+
this.currentTheme = themeName;
91+
this.rippleService.toggle(themeName?.startsWith('material'));
92+
});
7293
}
7394

7495
ngOnDestroy() {

src/app/@theme/styles/_overrides.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88
right: 0.41rem !important;
99
}
1010
}
11+
12+
nb-card nb-list {
13+
@include nb-scrollbars(
14+
nb-theme(card-scrollbar-color),
15+
nb-theme(card-scrollbar-background-color),
16+
nb-theme(card-scrollbar-width));
17+
}
18+
19+
.table {
20+
color: nb-theme(text-basic-color) !important;
21+
}
1122
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@use '~@angular/material' as mat;
2+
3+
@mixin angular-material() {
4+
@include mat.core();
5+
6+
@include nb-for-theme(material-dark) {
7+
$custom-dark-theme: mat.define-dark-theme(
8+
mat.define-palette(mat.$pink-palette),
9+
mat.define-palette(mat.$blue-grey-palette));
10+
@include mat.all-component-themes($custom-dark-theme);
11+
}
12+
13+
@include nb-for-theme(material-light) {
14+
$custom-light-theme: mat.define-light-theme(
15+
mat.define-palette(mat.$indigo-palette),
16+
mat.define-palette(mat.$pink-palette));
17+
@include mat.all-component-themes($custom-light-theme);
18+
}
19+
}

0 commit comments

Comments
 (0)