fix(label): emit proper styles for item classes

This commit is contained in:
Brandy Carney
2017-07-28 17:41:03 -04:00
parent d06563e7a2
commit 7736045342

View File

@ -1,4 +1,4 @@
import { Component } from '@stencil/core'; import { Component, Event, EventEmitter, Prop } from '@stencil/core';
@Component({ @Component({
@ -13,6 +13,46 @@ import { Component } from '@stencil/core';
} }
}) })
export class Label { export class Label {
styleTmr: any;
/**
* @output {event} Emitted when the styles change.
*/
@Event() ionStyle: EventEmitter;
/**
* @output {event} If true, the label will sit alongside an input. Defaults to `false`.
*/
@Prop() fixed: boolean = false;
/**
* @output {event} If true, the label will float above an input when the value is empty or the input is focused. Defaults to `false`.
*/
@Prop() floating: boolean = false;
/**
* @output {event} If true, the label will be stacked above an input. Defaults to `false`.
*/
@Prop() stacked: boolean = false;
ionViewDidLoad() {
this.emitStyle();
}
emitStyle() {
clearTimeout(this.styleTmr);
let styles = {
'label-fixed': this.fixed,
'label-floating': this.floating,
'label-stacked': this.stacked
};
this.styleTmr = setTimeout(() => {
this.ionStyle.emit(styles);
});
}
render() { render() {
return <slot></slot>; return <slot></slot>;
} }