Skip to content

Commit

Permalink
feat: add eva-icons (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
denStrigo committed Nov 19, 2018
1 parent 3f1f4c5 commit b3d7b7b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 7 deletions.
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"classlist.js": "1.1.20150312",
"core-js": "2.5.1",
"echarts": "^4.0.2",
"eva-icons": "^1.1.0",
"intl": "1.2.5",
"ionicons": "2.0.1",
"leaflet": "1.2.0",
Expand Down
50 changes: 50 additions & 0 deletions src/app/@theme/pipes/eva-icons.pipe.ts
Original file line number Diff line number Diff line change
@@ -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,
}));
}
}
1 change: 1 addition & 0 deletions src/app/@theme/pipes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 2 additions & 0 deletions src/app/@theme/theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
RoundPipe,
TimingPipe,
NumberWithCommasPipe,
EvaIconsPipe,
} from './pipes';
import {
OneColumnLayoutComponent,
Expand Down Expand Up @@ -132,6 +133,7 @@ const PIPES = [
RoundPipe,
TimingPipe,
NumberWithCommasPipe,
EvaIconsPipe,
];

const NB_THEME_PROVIDERS = [
Expand Down
23 changes: 20 additions & 3 deletions src/app/pages/ui-features/icons/icons.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<div class="row">
<div class="col-md-12 col-lg-6">
<nb-card>
<nb-card-header>
Eva Icons
</nb-card-header>
<nb-card-body>
<div class="icon" *ngFor="let icon of evaIcons">
<i [nbPopover]="icon">
<i [innerHTML]="icon | eva: { fill: '#d1d1ff', animationType: 'pulse' }"></i>
</i>
</div>
</nb-card-body>
<nb-card-footer>
<a href="https://akveo.github.io/eva-icons/" target="_blank">See all eva-icons</a>
</nb-card-footer>
</nb-card>
</div>

<div class="col-md-12 col-lg-6">
<nb-card class="nb-icons">
<nb-card-header>
Expand Down Expand Up @@ -28,9 +46,7 @@
</a>
</nb-card-footer>
</nb-card>
</div>

<div class="col-md-12 col-lg-6">
<nb-card>
<nb-card-header>
Ionicons
Expand All @@ -41,8 +57,9 @@
</div>
</nb-card-body>
<nb-card-footer>
<a href="http://ionicons.com/" target="_blank">See all ionicons icons</a>
<a href="http://ionicons.com/" target="_blank">See all ionicons</a>
</nb-card-footer>
</nb-card>

</div>
</div>
10 changes: 9 additions & 1 deletion src/app/pages/ui-features/icons/icons.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Component } from '@angular/core';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { icons } from 'eva-icons';

@Component({
selector: 'ngx-icons',
styleUrls: ['./icons.component.scss'],
templateUrl: './icons.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconsComponent {

evaIcons = [];

constructor() {
this.evaIcons = Object.keys(icons).filter(icon => icon.indexOf('outline') === -1);
}

icons = {

nebular: ['nb-alert', 'nb-angle-double-left', 'nb-angle-double-right',
Expand Down

0 comments on commit b3d7b7b

Please sign in to comment.