Last active
November 29, 2018 11:49
-
-
Save phroggyy/ba7f9cc6e336cd6e498bb3874dfa2c5f to your computer and use it in GitHub Desktop.
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: '[hsThemed]', | |
}) | |
export class ThemedDirective implements OnInit { | |
@Input() lightClass = ''; | |
@Input() darkClass = ''; | |
constructor(private el: ElementRef, private themingService: ThemingService) { | |
} | |
ngOnInit() { | |
if (this.themingService.isDarkTheme() && this.darkClass && this.darkClass.length) { | |
(this.el.nativeElement as HTMLElement).classList.add(...this.darkClass.split(' ')); | |
} | |
if (this.themingService.isLightTheme() && this.lightClass && this.lightClass.length) { | |
(this.el.nativeElement as HTMLElement).classList.add(...this.lightClass.split(' ')); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment