feature(menu-button): initial implementation of menu-button, needs better css support and better dom structure

This commit is contained in:
Dan Bucholtz
2018-02-23 14:36:04 -06:00
parent 2cbec55bb6
commit 282e4e3e79
8 changed files with 171 additions and 3 deletions

View File

@ -4,8 +4,6 @@
* and imports for stencil collections that might be configured in your stencil.config.js file * and imports for stencil collections that might be configured in your stencil.config.js file
*/ */
import 'ionicons';
import { import {
AnimationBuilder, AnimationBuilder,
FrameworkDelegate, FrameworkDelegate,
@ -1686,6 +1684,38 @@ declare global {
} }
import {
MenuButton as IonMenuButton
} from './components/menu-button/menu-button';
declare global {
interface HTMLIonMenuButtonElement extends IonMenuButton, HTMLStencilElement {
}
var HTMLIonMenuButtonElement: {
prototype: HTMLIonMenuButtonElement;
new (): HTMLIonMenuButtonElement;
};
interface HTMLElementTagNameMap {
"ion-menu-button": HTMLIonMenuButtonElement;
}
interface ElementTagNameMap {
"ion-menu-button": HTMLIonMenuButtonElement;
}
namespace JSX {
interface IntrinsicElements {
"ion-menu-button": JSXElements.IonMenuButtonAttributes;
}
}
namespace JSXElements {
export interface IonMenuButtonAttributes extends HTMLAttributes {
autoHide?: boolean;
menu?: string;
mode?: 'ios' | 'md';
}
}
}
import { import {
MenuController as IonMenuController MenuController as IonMenuController
} from './components/menu-controller/menu-controller'; } from './components/menu-controller/menu-controller';

View File

@ -0,0 +1,64 @@
import { Component, Element, Prop, State } from '@stencil/core';
import { Config } from '../../index';
@Component({
tag: 'ion-menu-button',
styleUrls: {
ios: 'menu-button.ios.scss',
md: 'menu-button.md.scss'
},
host: {
theme: 'menu-button'
}
})
export class MenuButton {
@State() custom: boolean;
/**
* The mode determines which platform styles to use.
* Possible values are: `"ios"` or `"md"`.
* For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
*/
@Prop() mode: 'ios' | 'md';
/**
* 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;
@Prop({ context: 'config' }) config: Config;
@Element() el: HTMLElement;
componentWillLoad() {
this.custom = this.el.childElementCount > 0;
}
render() {
const menuIcon = this.config.get('menuIcon', 'menu');
if (this.custom) {
return (
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
<slot />
</ion-menu-toggle>
);
} else {
return (
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
<ion-button>
<ion-icon slot="icon-only" name={menuIcon}></ion-icon>
</ion-button>
</ion-menu-toggle>
);
}
}
}

View File

@ -0,0 +1,63 @@
# ion-menu-button
<!-- 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
#### mode
The mode determines which platform styles to use.
Possible values are: `"ios"` or `"md"`.
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
## 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
#### mode
The mode determines which platform styles to use.
Possible values are: `"ios"` or `"md"`.
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
----------------------------------------------
*Built with [StencilJS](https://stenciljs.com/)*

View File

@ -7,11 +7,16 @@ import { Component, Listen, Prop, State } from '@stencil/core';
export class MenuToggle { export class MenuToggle {
@State() visible = false; @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 * 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; @Prop() menu: string;
/**
* Automatically hides the content when the corresponding menu is not
* active
*/
@Prop() autoHide = true; @Prop() autoHide = true;
componentDidLoad() { componentDidLoad() {

View File

@ -11,6 +11,9 @@
boolean boolean
Automatically hides the content when the corresponding menu is not
active
#### menu #### menu
@ -25,6 +28,9 @@ Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `ri
boolean boolean
Automatically hides the content when the corresponding menu is not
active
#### menu #### menu

View File

@ -27,7 +27,7 @@ exports.config = {
{ components: ['ion-infinite-scroll', 'ion-infinite-scroll-content'] }, { components: ['ion-infinite-scroll', 'ion-infinite-scroll-content'] },
{ components: ['ion-input', 'ion-textarea'] }, { components: ['ion-input', 'ion-textarea'] },
{ components: ['ion-loading', 'ion-loading-controller'] }, { components: ['ion-loading', 'ion-loading-controller'] },
{ components: ['ion-menu', 'ion-menu-controller'] }, { components: ['ion-menu', 'ion-menu-controller', 'ion-menu-toggle', 'ion-menu-button'] },
{ components: ['ion-modal', 'ion-modal-controller'] }, { components: ['ion-modal', 'ion-modal-controller'] },
{ components: ['ion-nav', 'ion-page', 'ion-back-button'] }, { components: ['ion-nav', 'ion-page', 'ion-back-button'] },
{ components: ['ion-popover', 'ion-popover-controller'] }, { components: ['ion-popover', 'ion-popover-controller'] },