feat: add eva-icons (#1912)

This commit is contained in:
Denis Strigo 2018-11-19 17:53:56 +02:00 committed by GitHub
parent 3f1f4c558b
commit b3d7b7bd08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 7 deletions

11
package-lock.json generated
View file

@ -6886,6 +6886,11 @@
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=",
"dev": true "dev": true
}, },
"eva-icons": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eva-icons/-/eva-icons-1.1.0.tgz",
"integrity": "sha512-Tural3pSMSL7PoKz8zNXTwy6/0YzJqtNieYs0jTUmaVCXs7XwqFDBFfeWaPUVrKS3C5j2MsZniGOnTi3tb8b6g=="
},
"event-stream": { "event-stream": {
"version": "3.3.4", "version": "3.3.4",
"resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz",
@ -12101,9 +12106,9 @@
} }
}, },
"nebular-icons": { "nebular-icons": {
"version": "1.0.9", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/nebular-icons/-/nebular-icons-1.0.9.tgz", "resolved": "https://registry.npmjs.org/nebular-icons/-/nebular-icons-1.1.0.tgz",
"integrity": "sha512-zz//MW0tXGI3ArzRTqxV5ySpsRKFd5O/gy0tHYgBsjvLXe9k0UF9tS1i7cro4CB2VrrKGbZAcIo7hIPX63HCmw==" "integrity": "sha512-4TkJgDrjXw8qsOsc2NN6OBlRJYAJJpvqtjV+gpv+NV6amPgMPQNNuEvbenYXAMFmjs3uShgKOvmpnCX8Ua1oWQ=="
}, },
"negotiator": { "negotiator": {
"version": "0.6.1", "version": "0.6.1",

View file

@ -61,6 +61,7 @@
"classlist.js": "1.1.20150312", "classlist.js": "1.1.20150312",
"core-js": "2.5.1", "core-js": "2.5.1",
"echarts": "^4.0.2", "echarts": "^4.0.2",
"eva-icons": "^1.1.0",
"intl": "1.2.5", "intl": "1.2.5",
"ionicons": "2.0.1", "ionicons": "2.0.1",
"leaflet": "1.2.0", "leaflet": "1.2.0",

View 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,
}));
}
}

View file

@ -3,3 +3,4 @@ export * from './plural.pipe';
export * from './round.pipe'; export * from './round.pipe';
export * from './timing.pipe'; export * from './timing.pipe';
export * from './number-with-commas.pipe'; export * from './number-with-commas.pipe';
export * from './eva-icons.pipe';

View file

@ -57,6 +57,7 @@ import {
RoundPipe, RoundPipe,
TimingPipe, TimingPipe,
NumberWithCommasPipe, NumberWithCommasPipe,
EvaIconsPipe,
} from './pipes'; } from './pipes';
import { import {
OneColumnLayoutComponent, OneColumnLayoutComponent,
@ -132,6 +133,7 @@ const PIPES = [
RoundPipe, RoundPipe,
TimingPipe, TimingPipe,
NumberWithCommasPipe, NumberWithCommasPipe,
EvaIconsPipe,
]; ];
const NB_THEME_PROVIDERS = [ const NB_THEME_PROVIDERS = [

View file

@ -1,4 +1,22 @@
<div class="row"> <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"> <div class="col-md-12 col-lg-6">
<nb-card class="nb-icons"> <nb-card class="nb-icons">
<nb-card-header> <nb-card-header>
@ -28,9 +46,7 @@
</a> </a>
</nb-card-footer> </nb-card-footer>
</nb-card> </nb-card>
</div>
<div class="col-md-12 col-lg-6">
<nb-card> <nb-card>
<nb-card-header> <nb-card-header>
Ionicons Ionicons
@ -41,8 +57,9 @@
</div> </div>
</nb-card-body> </nb-card-body>
<nb-card-footer> <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-footer>
</nb-card> </nb-card>
</div> </div>
</div> </div>

View file

@ -1,12 +1,20 @@
import { Component } from '@angular/core'; import { ChangeDetectionStrategy, Component } from '@angular/core';
import { icons } from 'eva-icons';
@Component({ @Component({
selector: 'ngx-icons', selector: 'ngx-icons',
styleUrls: ['./icons.component.scss'], styleUrls: ['./icons.component.scss'],
templateUrl: './icons.component.html', templateUrl: './icons.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class IconsComponent { export class IconsComponent {
evaIcons = [];
constructor() {
this.evaIcons = Object.keys(icons).filter(icon => icon.indexOf('outline') === -1);
}
icons = { icons = {
nebular: ['nb-alert', 'nb-angle-double-left', 'nb-angle-double-right', nebular: ['nb-alert', 'nb-angle-double-left', 'nb-angle-double-right',