mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
refactor(all): updating to newest stencil apis (#18578)
* chore(): update ionicons * refactor(all): updating to newest stencil apis * fix lint issues * more changes * moreee * fix treeshaking * fix config * fix checkbox * fix stuff * chore(): update ionicons * fix linting errors
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Component, ComponentInterface, Listen, Prop, State, h } from '@stencil/core';
|
||||
import { Component, ComponentInterface, Host, Listen, Prop, State, h } from '@stencil/core';
|
||||
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
|
||||
@ -9,8 +9,6 @@ import { getIonMode } from '../../global/ionic-global';
|
||||
})
|
||||
export class MenuToggle implements ComponentInterface {
|
||||
|
||||
@Prop({ context: 'document' }) doc!: Document;
|
||||
|
||||
@State() visible = false;
|
||||
|
||||
/**
|
||||
@ -35,17 +33,6 @@ export class MenuToggle implements ComponentInterface {
|
||||
return this.updateVisibility();
|
||||
}
|
||||
|
||||
@Listen('click')
|
||||
async onClick() {
|
||||
const menuCtrl = await getMenuController(document);
|
||||
if (menuCtrl) {
|
||||
const menu = await menuCtrl.get(this.menu);
|
||||
if (menu) {
|
||||
menuCtrl.toggle(this.menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Listen('ionMenuChange', { target: 'body' })
|
||||
@Listen('ionSplitPaneVisible', { target: 'body' })
|
||||
async updateVisibility() {
|
||||
@ -60,20 +47,31 @@ export class MenuToggle implements ComponentInterface {
|
||||
this.visible = false;
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const mode = getIonMode(this);
|
||||
const hidden = this.autoHide && !this.visible;
|
||||
return {
|
||||
'aria-hidden': hidden ? 'true' : null,
|
||||
class: {
|
||||
[`${mode}`]: true,
|
||||
'menu-toggle-hidden': hidden,
|
||||
private onClick = async () => {
|
||||
const menuCtrl = await getMenuController(document);
|
||||
if (menuCtrl) {
|
||||
const menu = await menuCtrl.get(this.menu);
|
||||
if (menu) {
|
||||
menuCtrl.toggle(this.menu);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <slot></slot>;
|
||||
const mode = getIonMode(this);
|
||||
const hidden = this.autoHide && !this.visible;
|
||||
|
||||
return (
|
||||
<Host
|
||||
onClick={this.onClick}
|
||||
aria-hidden={hidden ? 'true' : null}
|
||||
class={{
|
||||
[mode]: true,
|
||||
'menu-toggle-hidden': hidden,
|
||||
}}
|
||||
>
|
||||
<slot></slot>
|
||||
</Host>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user