mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
chore(packages): move the packages to root
This commit is contained in:
4
core/src/components/menu-toggle/menu-toggle.scss
Normal file
4
core/src/components/menu-toggle/menu-toggle.scss
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
ion-menu-toggle.menu-toggle-hidden {
|
||||
display: none;
|
||||
}
|
71
core/src/components/menu-toggle/menu-toggle.tsx
Normal file
71
core/src/components/menu-toggle/menu-toggle.tsx
Normal file
@ -0,0 +1,71 @@
|
||||
import { Component, Listen, Prop, State } from '@stencil/core';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-menu-toggle',
|
||||
styleUrl: 'menu-toggle.scss'
|
||||
})
|
||||
export class MenuToggle {
|
||||
|
||||
@State() visible = false;
|
||||
|
||||
/**
|
||||
* Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
*/
|
||||
@Prop() menu: string;
|
||||
|
||||
/**
|
||||
* Automatically hides the content when the corresponding menu is not
|
||||
* active
|
||||
*/
|
||||
@Prop() autoHide = true;
|
||||
|
||||
componentDidLoad() {
|
||||
this.updateVisibility();
|
||||
}
|
||||
|
||||
@Listen('child:click')
|
||||
onClick() {
|
||||
getMenuController().then(menuCtrl => {
|
||||
if (menuCtrl) {
|
||||
const menu = menuCtrl.get(this.menu);
|
||||
if (menu && menu.isActive()) {
|
||||
return menuCtrl.toggle(this.menu);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Listen('body:ionMenuChange')
|
||||
@Listen('body:ionSplitPaneVisible')
|
||||
updateVisibility() {
|
||||
return getMenuController().then(menuCtrl => {
|
||||
if (menuCtrl) {
|
||||
const menu = menuCtrl.get(this.menu);
|
||||
if (menu && menu.isActive()) {
|
||||
this.visible = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.visible = false;
|
||||
});
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const hidden = this.autoHide && !this.visible;
|
||||
return {
|
||||
class: {
|
||||
'menu-toggle-hidden': hidden
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getMenuController(): Promise<HTMLIonMenuControllerElement> {
|
||||
const menuControllerElement = document.querySelector('ion-menu-controller');
|
||||
if (!menuControllerElement) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
return menuControllerElement.componentOnReady();
|
||||
}
|
45
core/src/components/menu-toggle/readme.md
Normal file
45
core/src/components/menu-toggle/readme.md
Normal file
@ -0,0 +1,45 @@
|
||||
# ion-menu-toggle
|
||||
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
#### autoHide
|
||||
|
||||
boolean
|
||||
|
||||
Automatically hides the content when the corresponding menu is not
|
||||
active
|
||||
|
||||
|
||||
#### menu
|
||||
|
||||
string
|
||||
|
||||
Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
|
||||
|
||||
## Attributes
|
||||
|
||||
#### auto-hide
|
||||
|
||||
boolean
|
||||
|
||||
Automatically hides the content when the corresponding menu is not
|
||||
active
|
||||
|
||||
|
||||
#### menu
|
||||
|
||||
string
|
||||
|
||||
Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
112
core/src/components/menu-toggle/test/basic/index.html
Normal file
112
core/src/components/menu-toggle/test/basic/index.html
Normal file
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Menu Toggle - Basic</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
<ion-menu side="left" class="e2eLeftMenu">
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Left Menu</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item>Open Right Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Footer</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
</ion-menu>
|
||||
|
||||
<ion-menu side="right">
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Hola</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
hola macho
|
||||
</ion-content>
|
||||
</ion-menu>
|
||||
|
||||
<div class="ion-page" main>
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-menu-toggle>
|
||||
<ion-button>
|
||||
<ion-icon slot="icon-only" name="menu"></ion-icon>
|
||||
</ion-button>
|
||||
</ion-menu-toggle>
|
||||
</ion-buttons>
|
||||
<ion-title>Menu Toggle - Basic</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
<div>
|
||||
<ion-button onclick="openDefault()">Menu Button Will Open Default</ion-button>
|
||||
</div>
|
||||
<div>
|
||||
<ion-button onclick="openLeft()">Menu Button Will Open Left</ion-button>
|
||||
</div>
|
||||
<div>
|
||||
<ion-button onclick="openRight()">Menu Button Will Open Right</ion-button>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
|
||||
</ion-app>
|
||||
<ion-menu-controller></ion-menu-controller>
|
||||
|
||||
<script>
|
||||
|
||||
async function openDefault() {
|
||||
const menuButton = document.querySelector('ion-menu-toggle');
|
||||
await menuButton.componentOnReady();
|
||||
menuButton.menu = null;
|
||||
}
|
||||
|
||||
async function openLeft() {
|
||||
const menuButton = document.querySelector('ion-menu-toggle');
|
||||
await menuButton.componentOnReady();
|
||||
menuButton.menu = 'left';
|
||||
}
|
||||
|
||||
async function openRight() {
|
||||
const menuButton = document.querySelector('ion-menu-toggle');
|
||||
await menuButton.componentOnReady();
|
||||
menuButton.menu = 'right';
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
65
core/src/components/menu-toggle/test/button/index.html
Normal file
65
core/src/components/menu-toggle/test/button/index.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Menu - Button</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
<ion-menu side="left" class="e2eLeftMenu">
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Left Menu</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item>Open Right Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
<ion-item>Close Menu</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Footer</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
</ion-menu>
|
||||
|
||||
<div class="ion-page" main>
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Menu Toggle - Button</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
<ion-menu-toggle>
|
||||
<ion-button>Toggle Menu</ion-button>
|
||||
</ion-menu-toggle>
|
||||
</ion-content>
|
||||
|
||||
</div>
|
||||
|
||||
</ion-app>
|
||||
<ion-menu-controller></ion-menu-controller>
|
||||
</body>
|
||||
</html>
|
240
core/src/components/menu-toggle/test/list/index.html
Normal file
240
core/src/components/menu-toggle/test/list/index.html
Normal file
@ -0,0 +1,240 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Menu - List</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<script src="/dist/ionic.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
<ion-menu side="left" class="e2eLeftMenu">
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Left Menu</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
Menu Content
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-toolbar color="secondary">
|
||||
<ion-title>Footer</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
</ion-menu>
|
||||
|
||||
<div class="ion-page" main>
|
||||
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Menu Toggle - List</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
<ion-list>
|
||||
|
||||
<!-- <ion-menu-toggle> -->
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
No Menu Toggle
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
<!-- </ion-menu-toggle> -->
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
|
||||
<ion-menu-toggle>
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
List Item
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
</ion-content>
|
||||
</div>
|
||||
</ion-app>
|
||||
<ion-menu-controller></ion-menu-controller>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user