From 7736045342cf23d3db1093177bf226998d27b38a Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Fri, 28 Jul 2017 17:41:03 -0400 Subject: [PATCH] fix(label): emit proper styles for item classes --- packages/core/src/components/label/label.tsx | 42 +++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/core/src/components/label/label.tsx b/packages/core/src/components/label/label.tsx index 2721704cf1..78d118e3ab 100644 --- a/packages/core/src/components/label/label.tsx +++ b/packages/core/src/components/label/label.tsx @@ -1,4 +1,4 @@ -import { Component } from '@stencil/core'; +import { Component, Event, EventEmitter, Prop } from '@stencil/core'; @Component({ @@ -13,6 +13,46 @@ import { Component } from '@stencil/core'; } }) 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() { return ; }