$theme-and-color: (
'primary': $color__primary,
'accent': $color__accent,
'error': $color__error,
'warn': $color__warn,
'highlight': $color__highlight,
'pure': $color__pure--light,
'utility': $color__utility
);
/**
* Output conditional styles for the possible themes
*
* @mixin theme-color
* @section Functions
* @param $property
* The CSS property that should be colored. Default: 'background-color'
* @example
* @include theme-color;
* @include theme-color('color');
*/
@mixin theme-color($property: 'background-color') {
// Verify an allowed property was passed in
@if not(($property == background-color)) and not(($property == color)) {
@error 'The `theme__color` mixin only accepts `background-color` or `color`';
}
@each $key, $value in $theme-and-color {
::ng-deep .u-theme--#{$key} & {
#{$property}: $value;
@if ($property == 'background-color') and (not(($key == 'pure')) and not(($key == 'highlight'))) {
color: $color__pure--light;
}
@if ($property == 'background-color') and ($key == 'highlight') {
color: $color__pure--dark;
}
&[disabled] {
background-color: color(utility, light);
color: color(utility);
}
}
}
}
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,
) {}
}