aurelia-materialize-bridge
Version:
Aurelia interface to http://materializecss.com/
59 lines (48 loc) • 2.25 kB
text/typescript
import * as au from "../aurelia";
.customElement("md-colors")
export class MdColors {
constructor(private cs: au.MdColorsService, private bindingEngine: au.BindingEngine) { }
.bindable
primaryColor: string = this.cs.primaryColor;
primaryColorChanged() {
this.cs.primaryColor = this.primaryColor;
this.cs.updatePrimaryShades();
}
primaryColorLight: string = this.cs.primaryColorLight;
primaryColorDark: string = this.cs.primaryColorDark;
.bindable
secondaryColor: string = this.cs.secondaryColor;
secondaryColorChanged() {
this.cs.secondaryColor = this.secondaryColor;
}
.bindable
errorColor: string = this.cs.errorColor;
errorColorChanged() {
this.cs.errorColor = this.errorColor;
}
.bindable
successColor: string = this.cs.successColor;
successColorChanged() {
this.cs.successColor = this.successColor;
}
.bindable
linkColor: string = this.cs.linkColor;
linkColorChanged() {
this.cs.linkColor = this.linkColor;
}
subscriptions: au.Disposable[] = [];
attached() {
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "primaryColor").subscribe(() => this.primaryColor = this.cs.primaryColor));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "primaryColorLight").subscribe(() => this.primaryColorLight = this.cs.primaryColorLight));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "primaryColorDark").subscribe(() => this.primaryColorDark = this.cs.primaryColorDark));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "secondaryColor").subscribe(() => this.secondaryColor = this.cs.secondaryColor));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "errorColor").subscribe(() => this.errorColor = this.cs.errorColor));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "successColor").subscribe(() => this.successColor = this.cs.successColor));
this.subscriptions.push(this.bindingEngine.propertyObserver(this.cs, "linkColor").subscribe(() => this.linkColor = this.cs.linkColor));
this.primaryColorLight = this.cs.primaryColorLight;
this.primaryColorDark = this.cs.primaryColorDark;
}
detached() {
this.subscriptions.forEach(x => x.dispose());
}
}