mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-22 02:10:12 +01:00
feat: add eva-icons (#1912)
This commit is contained in:
parent
3f1f4c558b
commit
b3d7b7bd08
7 changed files with 91 additions and 7 deletions
50
src/app/@theme/pipes/eva-icons.pipe.ts
Normal file
50
src/app/@theme/pipes/eva-icons.pipe.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Akveo. All Rights Reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*/
|
||||
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { icons } from 'eva-icons';
|
||||
|
||||
@Pipe({ name: 'eva' })
|
||||
export class EvaIconsPipe implements PipeTransform {
|
||||
|
||||
private defaultOptions = {
|
||||
height: 24,
|
||||
width: 24,
|
||||
fill: 'inherit',
|
||||
animationHover: true,
|
||||
animationInfinity: false,
|
||||
};
|
||||
|
||||
constructor(private sanitizer: DomSanitizer) {}
|
||||
|
||||
transform(icon: string,
|
||||
options: {
|
||||
height: number;
|
||||
width: number;
|
||||
fill: string;
|
||||
animationType?: string;
|
||||
animationHover?: boolean;
|
||||
animationInfinity?: boolean;
|
||||
},
|
||||
) {
|
||||
const mergedOptions = {
|
||||
...this.defaultOptions,
|
||||
...options,
|
||||
};
|
||||
const { width, height, fill, animationType, animationHover, animationInfinity } = mergedOptions;
|
||||
const animation = animationType ?
|
||||
{ type: animationType, hover: animationHover, infinite: animationInfinity } :
|
||||
null;
|
||||
|
||||
return this.sanitizer.bypassSecurityTrustHtml(icons[icon].toSvg({
|
||||
width,
|
||||
height,
|
||||
fill,
|
||||
animation,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,3 +3,4 @@ export * from './plural.pipe';
|
|||
export * from './round.pipe';
|
||||
export * from './timing.pipe';
|
||||
export * from './number-with-commas.pipe';
|
||||
export * from './eva-icons.pipe';
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import {
|
|||
RoundPipe,
|
||||
TimingPipe,
|
||||
NumberWithCommasPipe,
|
||||
EvaIconsPipe,
|
||||
} from './pipes';
|
||||
import {
|
||||
OneColumnLayoutComponent,
|
||||
|
|
@ -132,6 +133,7 @@ const PIPES = [
|
|||
RoundPipe,
|
||||
TimingPipe,
|
||||
NumberWithCommasPipe,
|
||||
EvaIconsPipe,
|
||||
];
|
||||
|
||||
const NB_THEME_PROVIDERS = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue