mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-20 17:30:14 +01:00
theme run classes
This commit is contained in:
parent
e7595af72c
commit
9d0fef1dd3
7 changed files with 55 additions and 20 deletions
|
|
@ -4,6 +4,7 @@ import {RouteConfig} from '@angular/router-deprecated';
|
||||||
import {Pages} from './pages';
|
import {Pages} from './pages';
|
||||||
import {AppState} from './app.state';
|
import {AppState} from './app.state';
|
||||||
import {BaThemeConfigProvider, BaThemeConfig} from './theme';
|
import {BaThemeConfigProvider, BaThemeConfig} from './theme';
|
||||||
|
import {BaThemeRun} from './theme/directives';
|
||||||
import './app.loader.ts';
|
import './app.loader.ts';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -13,11 +14,12 @@ import './app.loader.ts';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app',
|
selector: 'app',
|
||||||
pipes: [],
|
pipes: [],
|
||||||
|
directives: [BaThemeRun],
|
||||||
providers: [BaThemeConfigProvider, BaThemeConfig],
|
providers: [BaThemeConfigProvider, BaThemeConfig],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
styles: [require('normalize.css'), require('./app.scss')],
|
styles: [require('normalize.css'), require('./app.scss')],
|
||||||
template: `
|
template: `
|
||||||
<main [ngClass]="{'menu-collapsed': isMenuCollapsed}">
|
<main [ngClass]="{'menu-collapsed': isMenuCollapsed}" baThemeRun>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
`
|
`
|
||||||
|
|
|
||||||
29
src/app/theme/directives/baThemeRun/baThemeRun.directive.ts
Normal file
29
src/app/theme/directives/baThemeRun/baThemeRun.directive.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import {Directive, HostBinding} from '@angular/core';
|
||||||
|
|
||||||
|
import {BaThemeConfigProvider, isMobile} from '../../../theme';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[baThemeRun]'
|
||||||
|
})
|
||||||
|
export class BaThemeRun {
|
||||||
|
|
||||||
|
@HostBinding('class.blur-theme') isBlur:boolean = false;
|
||||||
|
@HostBinding('class.mobile') isMobile:boolean = false;
|
||||||
|
|
||||||
|
constructor(private _baConfig:BaThemeConfigProvider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this._assignBlur();
|
||||||
|
this._assingMobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: assign any theme class, not only hardcoded blur
|
||||||
|
private _assignBlur() {
|
||||||
|
this.isBlur = this._baConfig.get().theme.blur;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _assingMobile() {
|
||||||
|
this.isMobile = isMobile();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/app/theme/directives/baThemeRun/index.ts
Normal file
1
src/app/theme/directives/baThemeRun/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './baThemeRun.directive.ts';
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
export * from './scrollPosition';
|
export * from './scrollPosition';
|
||||||
|
export * from './baThemeRun';
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,16 @@ body {
|
||||||
font: 14px/16px $font-family;
|
font: 14px/16px $font-family;
|
||||||
color: $default-text;
|
color: $default-text;
|
||||||
background-color: $body-bg;
|
background-color: $body-bg;
|
||||||
&.blur-theme {
|
}
|
||||||
|
|
||||||
|
.blur-theme {
|
||||||
|
@at-root body {
|
||||||
@include main-background();
|
@include main-background();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body.mobile{
|
.mobile {
|
||||||
|
@at-root body {
|
||||||
background: none;
|
background: none;
|
||||||
.body-bg {
|
.body-bg {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
@ -33,8 +37,6 @@ body.mobile{
|
||||||
background-attachment: inherit;
|
background-attachment: inherit;
|
||||||
background-color: $body-bg;
|
background-color: $body-bg;
|
||||||
}
|
}
|
||||||
&.blur-theme {
|
|
||||||
@include main-background();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,3 +51,5 @@ export class colorHelper {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isMobile = () => (/android|webos|iphone|ipad|ipod|blackberry|windows phone/).test(navigator.userAgent.toLowerCase());
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,10 @@
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="blur-theme">
|
<body>
|
||||||
|
|
||||||
<app>
|
<app>
|
||||||
<div id="preloader">
|
Loading...
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
</app>
|
</app>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue