mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
fix(label): emit proper styles for item classes
This commit is contained in:
@ -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>;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user