Skip to content

Commit

Permalink
fix(icon): update styles
Browse files Browse the repository at this point in the history
  • Loading branch information
alyleui committed Aug 29, 2018
1 parent 0602a02 commit 5ec2ef1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
24 changes: 11 additions & 13 deletions src/lib/icon/icon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { HttpClient } from '@angular/common/http';
import { DOCUMENT } from '@angular/common';
import { Observable } from 'rxjs';
import { map, share } from 'rxjs/operators';
import { CoreTheme } from '@alyle/ui';
import { LyTheme2 } from '@alyle/ui';

const styles = {
svg: {
width: 'inherit',
height: 'inherit',
fill: 'currentColor',
}
};

export interface SvgIcon {
obs: Observable<SVGElement>;
Expand All @@ -15,21 +23,11 @@ export interface SvgIcon {
})
export class LyIconService {
private svgMap = new Map<string, SvgIcon>();
classes = {
svg: this.coreTheme.setUpStyle(
'_svg', {
'': () => (
`width:inherit;` +
`height:inherit;` +
`fill:currentColor;`
)
}
)
};
classes = this.theme.addStyleSheet(styles, 'lyIcon');
constructor(
private http: HttpClient,
@Optional() @Inject(DOCUMENT) private document: any,
private coreTheme: CoreTheme
private theme: LyTheme2
) { }

setSvg(key: string, url: string) {
Expand Down
26 changes: 8 additions & 18 deletions src/lib/icon/icon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, Input, Renderer2, ElementRef, OnChanges, SimpleChanges, OnInit } from '@angular/core';
import { Directive, Input, Renderer2, ElementRef, OnChanges, OnInit } from '@angular/core';
import { LyIconService, SvgIcon } from './icon.service';
import { take } from 'rxjs/operators';
import { Platform, LyTheme2 } from '@alyle/ui';
Expand All @@ -10,20 +10,6 @@ export class Icon implements OnChanges, OnInit {
private _defaultClass = 'material-icons';
private _src: string;
private _icon: string;
get classes() {
return {
root: this.theme.setUpStyle(
'root', {
'': () => (
`font-size:${this.theme.config.icon.fontSize};` +
`width:1em;` +
`height:1em;` +
`display:inline-flex;`
)
}
)
};
}
@Input()
set src(val: string) {
this._src = val;
Expand Down Expand Up @@ -91,11 +77,15 @@ export class Icon implements OnChanges, OnInit {
}

ngOnInit() {
this.renderer.addClass(this.elementRef.nativeElement, this.classes.root);
this._updateClass();
this.theme.addStyle('lyIconRoot', theme => (
`font-size:${theme.icon.fontSize};` +
`width:1em;` +
`height:1em;` +
`display:inline-flex;`
), this.elementRef.nativeElement);
}

ngOnChanges(changes: SimpleChanges) {
ngOnChanges() {
this._updateClass();
}

Expand Down

0 comments on commit 5ec2ef1

Please sign in to comment.