refactor(reorder): using fallback slot

This commit is contained in:
Manu Mtz.-Almeida
2018-04-23 23:29:16 +02:00
parent b3a9c7f819
commit d06409a2bd
3 changed files with 14 additions and 39 deletions

View File

@ -1,4 +1,4 @@
import { Component, Element, Prop } from '@stencil/core';
import { Component, Prop } from '@stencil/core';
import { Config } from '../../index';
@Component({
@ -13,8 +13,6 @@ import { Config } from '../../index';
})
export class MenuButton {
private custom = true;
@Prop({ context: 'config' }) config!: Config;
/**
@ -27,20 +25,14 @@ export class MenuButton {
*/
@Prop() autoHide = true;
@Element() el!: HTMLElement;
componentWillLoad() {
this.custom = this.el.childElementCount > 0;
}
render() {
const menuIcon = this.config.get('menuIcon', 'menu');
return (
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
<ion-button>
{this.custom
? <slot/>
: <ion-icon slot="icon-only" name={menuIcon}/>}
<slot>
<ion-icon slot="icon-only" name={menuIcon}/>
</slot>
</ion-button>
</ion-menu-toggle>
);