This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Theme { | |
primary: string; | |
accent: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Theme { | |
primary: string; | |
accent: string; | |
} | |
@Component({ | |
selector: 'app-root', | |
template: `<app-card></app-card>`, | |
}) | |
export class AppComponent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
template: ` | |
<app-card [style]="style"></app-card> | |
`, | |
}) | |
export class AppComponent { | |
get style() { | |
return this.sanitizer.bypassSecurityTrustStyle( | |
`--primary: lightblue; --accent: crimson` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
template: ` | |
<app-card></app-card> | |
`, | |
styles: [` | |
app-card { | |
--primary: lightblue; | |
--accent: crimson; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
template: ` | |
<app-card style="--primary: lightblue; --accent: crimson"></app-card> | |
`, | |
}) | |
export class AppComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-card', | |
template: ` | |
<header></header> | |
<main> | |
<section class="top"></section> | |
<button class="fab">+</button> | |
<section class="bottom"></section> | |
</main> | |
`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-card', | |
template: ` | |
<header></header> | |
<main> | |
<section class="top"></section> | |
<button class="fab">+</button> | |
<section class="bottom"></section> | |
</main> | |
`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: 'img[appLazyLoad]' | |
}) | |
export class LazyLoadDirective implements AfterViewInit { | |
// ... | |
constructor(private el: ElementRef) {} | |
private lazyLoadImage() { | |
const obs = new IntersectionObserver(entries => { | |
entries.forEach(({ isIntersecting }) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: 'img[appLazyLoad]' | |
}) | |
export class LazyLoadDirective implements AfterViewInit { | |
@HostBinding('attr.src') srcAttr = null; | |
@Input() src: string; | |
ngAfterViewInit() { | |
this.canLazyLoad() ? this.lazyLoadImage() : this.loadImage(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: 'img[appLazyLoad]' | |
}) | |
export class LazyLoadDirective implements AfterViewInit { | |
@HostBinding('attr.src') srcAttr = null; | |
@Input() src: string; | |
private loadImage() { | |
this.srcAttr = this.src; | |
} |