mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
refactor(reorder): using fallback slot
This commit is contained in:
@ -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>
|
||||
);
|
||||
|
Reference in New Issue
Block a user