mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 16:30:13 +01:00
theme config provider
This commit is contained in:
parent
06d0dc1c99
commit
f107a3726a
7 changed files with 138 additions and 44 deletions
|
|
@ -2,7 +2,8 @@ import {Component, ViewEncapsulation} from '@angular/core';
|
||||||
import {RouteConfig} from '@angular/router-deprecated';
|
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} from './theme';
|
||||||
import './app.loader.ts';
|
import './app.loader.ts';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -12,7 +13,7 @@ import './app.loader.ts';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app',
|
selector: 'app',
|
||||||
pipes: [],
|
pipes: [],
|
||||||
providers: [],
|
providers: [BaThemeConfigProvider],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
styles: [require('normalize.css'), require('./app.scss')],
|
styles: [require('normalize.css'), require('./app.scss')],
|
||||||
template: `
|
template: `
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="card {{cardType}} card-blur {{baCardClass || ''}}" zoom-in baCardBlur>
|
<div baCardBlur class="card {{cardType}} {{baCardClass || ''}}" zoom-in>
|
||||||
<div *ngIf="title" class="card-header clearfix">
|
<div *ngIf="title" class="card-header clearfix">
|
||||||
<h3 class="card-title">{{title}}</h3>
|
<h3 class="card-title">{{title}}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {Directive, ElementRef, HostListener} from '@angular/core';
|
import {Directive, ElementRef, HostListener, HostBinding} from '@angular/core';
|
||||||
import {BaCardBlurHelper} from './baCardBlurHelper.service';
|
import {BaThemeConfigProvider} from '../../../theme';
|
||||||
|
|
||||||
|
import {BaCardBlurHelper} from './baCardBlurHelper.service';
|
||||||
import {BgMetrics} from './bgMetrics';
|
import {BgMetrics} from './bgMetrics';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
|
|
@ -8,18 +9,27 @@ import {BgMetrics} from './bgMetrics';
|
||||||
providers: [BaCardBlurHelper]
|
providers: [BaCardBlurHelper]
|
||||||
})
|
})
|
||||||
export class BaCardBlur {
|
export class BaCardBlur {
|
||||||
|
|
||||||
|
@HostBinding('class.card-blur') isEnabled:boolean = false;
|
||||||
|
|
||||||
private _bodyBgSize:BgMetrics;
|
private _bodyBgSize:BgMetrics;
|
||||||
|
|
||||||
constructor(private _baCardBlurHelper:BaCardBlurHelper, private _el:ElementRef) {
|
constructor(private _baThemeConfigProvider:BaThemeConfigProvider, private _baCardBlurHelper:BaCardBlurHelper, private _el:ElementRef) {
|
||||||
|
if (this._isEnabled()) {
|
||||||
this._getBodyImageSizesOnBgLoad();
|
this._getBodyImageSizesOnBgLoad();
|
||||||
this._recalculateCardStylesOnBgLoad();
|
this._recalculateCardStylesOnBgLoad();
|
||||||
|
|
||||||
|
this.isEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:resize')
|
@HostListener('window:resize')
|
||||||
_onWindowResize():void {
|
_onWindowResize():void {
|
||||||
|
if (this._isEnabled()) {
|
||||||
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
||||||
this._recalculateCardStyle();
|
this._recalculateCardStyle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _getBodyImageSizesOnBgLoad():void {
|
private _getBodyImageSizesOnBgLoad():void {
|
||||||
this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
|
this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
|
||||||
|
|
@ -40,4 +50,8 @@ export class BaCardBlur {
|
||||||
this._el.nativeElement.style.backgroundSize = Math.round(this._bodyBgSize.width) + 'px ' + Math.round(this._bodyBgSize.height) + 'px';
|
this._el.nativeElement.style.backgroundSize = Math.round(this._bodyBgSize.width) + 'px ' + Math.round(this._bodyBgSize.height) + 'px';
|
||||||
this._el.nativeElement.style.backgroundPosition = Math.floor(this._bodyBgSize.positionX) + 'px ' + Math.floor(this._bodyBgSize.positionY) + 'px';
|
this._el.nativeElement.style.backgroundPosition = Math.floor(this._bodyBgSize.positionX) + 'px ' + Math.floor(this._bodyBgSize.positionY) + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _isEnabled() {
|
||||||
|
return this._baThemeConfigProvider.get().theme.blur;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
export * from './theme.constants'
|
export * from './theme.constants'
|
||||||
|
export * from './theme.configProvider'
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ $card-header-font-size: 16px;
|
||||||
|
|
||||||
.card-title {
|
.card-title {
|
||||||
font-weight: $font-normal;
|
font-weight: $font-normal;
|
||||||
|
font-size: $card-header-font-size;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
73
src/app/theme/theme.configProvider.ts
Normal file
73
src/app/theme/theme.configProvider.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {colorHelper} from './theme.constants';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BaThemeConfigProvider {
|
||||||
|
|
||||||
|
basic = {
|
||||||
|
default: '#ffffff',
|
||||||
|
defaultText: '#666666',
|
||||||
|
border: '#dddddd',
|
||||||
|
borderDark: '#aaaaaa',
|
||||||
|
};
|
||||||
|
|
||||||
|
// main functional color scheme
|
||||||
|
colorScheme = {
|
||||||
|
primary: '#209e91',
|
||||||
|
info: '#2dacd1',
|
||||||
|
success: '#90b900',
|
||||||
|
warning: '#dfb81c',
|
||||||
|
danger: '#e85656',
|
||||||
|
};
|
||||||
|
|
||||||
|
// dashboard colors for charts
|
||||||
|
dashboardColors = {
|
||||||
|
blueStone: '#005562',
|
||||||
|
surfieGreen: '#0e8174',
|
||||||
|
silverTree: '#6eba8c',
|
||||||
|
gossip: '#b9f2a1',
|
||||||
|
white: '#10c4b5',
|
||||||
|
};
|
||||||
|
|
||||||
|
conf = {
|
||||||
|
theme: {
|
||||||
|
blur: false,
|
||||||
|
},
|
||||||
|
colors: {
|
||||||
|
default: this.basic.default,
|
||||||
|
defaultText: this.basic.defaultText,
|
||||||
|
border: this.basic.border,
|
||||||
|
borderDark: this.basic.borderDark,
|
||||||
|
|
||||||
|
primary: this.colorScheme.primary,
|
||||||
|
info: this.colorScheme.info,
|
||||||
|
success: this.colorScheme.success,
|
||||||
|
warning: this.colorScheme.warning,
|
||||||
|
danger: this.colorScheme.danger,
|
||||||
|
|
||||||
|
primaryLight: colorHelper.tint(this.colorScheme.primary, 30),
|
||||||
|
infoLight: colorHelper.tint(this.colorScheme.info, 30),
|
||||||
|
successLight: colorHelper.tint(this.colorScheme.success, 30),
|
||||||
|
warningLight: colorHelper.tint(this.colorScheme.warning, 30),
|
||||||
|
dangerLight: colorHelper.tint(this.colorScheme.danger, 30),
|
||||||
|
|
||||||
|
primaryDark: colorHelper.shade(this.colorScheme.primary, 15),
|
||||||
|
infoDark: colorHelper.shade(this.colorScheme.info, 15),
|
||||||
|
successDark: colorHelper.shade(this.colorScheme.success, 15),
|
||||||
|
warningDark: colorHelper.shade(this.colorScheme.warning, 15),
|
||||||
|
dangerDark: colorHelper.shade(this.colorScheme.danger, 15),
|
||||||
|
|
||||||
|
dashboard: {
|
||||||
|
blueStone: this.dashboardColors.blueStone,
|
||||||
|
surfieGreen: this.dashboardColors.surfieGreen,
|
||||||
|
silverTree: this.dashboardColors.silverTree,
|
||||||
|
gossip: this.dashboardColors.gossip,
|
||||||
|
white: this.dashboardColors.white,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
get() {
|
||||||
|
return this.conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
export const IMAGES_ROOT = 'assets/img/';
|
export const IMAGES_ROOT = 'assets/img/';
|
||||||
|
|
||||||
export let shade = (color, weight) => {
|
|
||||||
|
export class colorHelper {
|
||||||
|
static shade = (color, weight) => {
|
||||||
return mix('#000000', color, weight);
|
return mix('#000000', color, weight);
|
||||||
};
|
};
|
||||||
|
|
||||||
export let tint = (color, weight) => {
|
static tint = (color, weight) => {
|
||||||
return mix('#ffffff', color, weight);
|
return mix('#ffffff', color, weight);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//SASS mix function
|
//SASS mix function
|
||||||
export let mix = (color1, color2, weight) => {
|
export let mix = (color1, color2, weight) => {
|
||||||
|
|
@ -14,6 +17,7 @@ export let mix = (color1, color2, weight) => {
|
||||||
function d2h(d) {
|
function d2h(d) {
|
||||||
return d.toString(16);
|
return d.toString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert a hex value to decimal
|
// convert a hex value to decimal
|
||||||
function h2d(h) {
|
function h2d(h) {
|
||||||
return parseInt(h, 16);
|
return parseInt(h, 16);
|
||||||
|
|
@ -70,23 +74,23 @@ export const layoutColors = {
|
||||||
warning: colorScheme.warning,
|
warning: colorScheme.warning,
|
||||||
danger: colorScheme.danger,
|
danger: colorScheme.danger,
|
||||||
|
|
||||||
primaryLight: tint(colorScheme.primary, 30),
|
primaryLight: colorHelper.tint(colorScheme.primary, 30),
|
||||||
infoLight: tint(colorScheme.info, 30),
|
infoLight: colorHelper.tint(colorScheme.info, 30),
|
||||||
successLight: tint(colorScheme.success, 30),
|
successLight: colorHelper.tint(colorScheme.success, 30),
|
||||||
warningLight: tint(colorScheme.warning, 30),
|
warningLight: colorHelper.tint(colorScheme.warning, 30),
|
||||||
dangerLight: tint(colorScheme.danger, 30),
|
dangerLight: colorHelper.tint(colorScheme.danger, 30),
|
||||||
|
|
||||||
primaryDark: shade(colorScheme.primary, 15),
|
primaryDark: colorHelper.shade(colorScheme.primary, 15),
|
||||||
infoDark: shade(colorScheme.info, 15),
|
infoDark: colorHelper.shade(colorScheme.info, 15),
|
||||||
successDark: shade(colorScheme.success, 15),
|
successDark: colorHelper.shade(colorScheme.success, 15),
|
||||||
warningDark: shade(colorScheme.warning, 15),
|
warningDark: colorHelper.shade(colorScheme.warning, 15),
|
||||||
dangerDark: shade(colorScheme.danger, 15),
|
dangerDark: colorHelper.shade(colorScheme.danger, 15),
|
||||||
|
|
||||||
primaryBg: tint(colorScheme.primary, 20),
|
primaryBg: colorHelper.tint(colorScheme.primary, 20),
|
||||||
infoBg: tint(colorScheme.info, 20),
|
infoBg: colorHelper.tint(colorScheme.info, 20),
|
||||||
successBg: tint(colorScheme.success, 20),
|
successBg: colorHelper.tint(colorScheme.success, 20),
|
||||||
warningBg: tint(colorScheme.warning, 20),
|
warningBg: colorHelper.tint(colorScheme.warning, 20),
|
||||||
dangerBg: tint(colorScheme.danger, 20),
|
dangerBg: colorHelper.tint(colorScheme.danger, 20),
|
||||||
|
|
||||||
default: '#ffffff',
|
default: '#ffffff',
|
||||||
defaultText: '#666666',
|
defaultText: '#666666',
|
||||||
|
|
@ -99,11 +103,11 @@ export const layoutColors = {
|
||||||
gossip: bgColorPalette.gossip,
|
gossip: bgColorPalette.gossip,
|
||||||
white: bgColorPalette.white,
|
white: bgColorPalette.white,
|
||||||
|
|
||||||
blueStoneDark: shade(bgColorPalette.blueStone, 15),
|
blueStoneDark: colorHelper.shade(bgColorPalette.blueStone, 15),
|
||||||
surfieGreenDark: shade(bgColorPalette.surfieGreen, 15),
|
surfieGreenDark: colorHelper.shade(bgColorPalette.surfieGreen, 15),
|
||||||
silverTreeDark: shade(bgColorPalette.silverTree, 15),
|
silverTreeDark: colorHelper.shade(bgColorPalette.silverTree, 15),
|
||||||
gossipDark: shade(bgColorPalette.gossip, 15),
|
gossipDark: colorHelper.shade(bgColorPalette.gossip, 15),
|
||||||
whiteDark: shade(bgColorPalette.white, 5),
|
whiteDark: colorHelper.shade(bgColorPalette.white, 5),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue