Created
August 7, 2017 15:30
-
-
Save benjamincharity/5bfbd2274c5b61e483f385454cee2621 to your computer and use it in GitHub Desktop.
Create a base class that will set a theme class on the component.
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
import { | |
Component, | |
Input, | |
ElementRef, | |
} from '@angular/core'; | |
import { TsStyleThemeTypes } from './../types/style-theme.types'; | |
/** | |
* A base class to set a class theme on a component | |
*/ | |
@Component({ | |
selector: 'ts-theme-base', | |
}) | |
export class TsThemeBaseComponent { | |
/** | |
* Define the button style | |
*/ | |
@Input() set theme(theme: TsStyleThemeTypes) { | |
if (!theme) { | |
return; | |
} | |
this.element.nativeElement.classList.add(`u-theme--${theme}`); | |
}; | |
constructor( | |
protected element: ElementRef, | |
) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment