Skip to content

Commit 79a7f2f

Browse files
committed
docs(menu/toolbar): update documentation for buttons/menuToggle in a toolbar
closes ionic-team/ionic-site#590
1 parent 9b2f084 commit 79a7f2f

File tree

2 files changed

+102
-29
lines changed

2 files changed

+102
-29
lines changed

src/components/menu/menu-toggle.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,60 @@ import {MenuController} from './menu-controller';
2121
* <button menuToggle>Toggle Menu</button>
2222
* ```
2323
*
24-
* To toggle a certain menu by its id or side, give the `menuToggle`
24+
* To toggle a specific menu by its id or side, give the `menuToggle`
2525
* directive a value.
2626
*
2727
* ```html
2828
* <button menuToggle="right">Toggle Right Menu</button>
2929
* ```
3030
*
31+
* If placing the `menuToggle` in a navbar or toolbar, it should be
32+
* placed as a child of the `<ion-navbar>` or `<ion-toolbar>`, and not in
33+
* the `<ion-buttons>` element:
34+
*
35+
* ```html
36+
* <ion-navbar *navbar>
37+
* <ion-buttons start>
38+
* <button>
39+
* <ion-icon name="contact"></ion-icon>
40+
* </button>
41+
* </ion-buttons>
42+
* <button menuToggle>
43+
* <ion-icon name="menu"></ion-icon>
44+
* </button>
45+
* <ion-title>
46+
* Title
47+
* </ion-title>
48+
* <ion-buttons end>
49+
* <button (click)="doClick()">
50+
* <ion-icon name="more"></ion-icon>
51+
* </button>
52+
* </ion-buttons>
53+
* </ion-navbar>
54+
* ```
55+
*
56+
* Similar to `<ion-buttons>`, the `menuToggle` can be positioned using
57+
* `start`, `end`, `left`, or `right`:
58+
*
59+
* ```html
60+
* <ion-toolbar>
61+
* <button menuToggle right>
62+
* <ion-icon name="menu"></ion-icon>
63+
* </button>
64+
* <ion-title>
65+
* Title
66+
* </ion-title>
67+
* <ion-buttons end>
68+
* <button (click)="doClick()">
69+
* <ion-icon name="more"></ion-icon>
70+
* </button>
71+
* </ion-buttons>
72+
* </ion-toolbar>
73+
* ```
74+
*
75+
* See the [Toolbar API docs](../../toolbar/Toolbar) for more information
76+
* on the different positions.
77+
*
3178
* @demo /docs/v2/demos/menu/
3279
* @see {@link /docs/v2/components#menus Menu Component Docs}
3380
* @see {@link ../../menu/Menu Menu API Docs}

src/components/toolbar/toolbar.ts

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,70 @@ export class ToolbarBase extends Ion {
6464
/**
6565
* @name Toolbar
6666
* @description
67-
* The toolbar is generic bar that sits above or below content.
68-
* Unlike an `Navbar`, `Toolbar` can be used for a subheader as well.
69-
* Since it's based on flexbox, you can place the toolbar where you
70-
* need it and flexbox will handle everything else. Toolbars will automatically
71-
* assume they should be placed before an `ion-content`, so to specify that you want it
72-
* below, you can add the property `position="bottom"`. This will change the flex order
67+
* A Toolbar is a generic bar that is positioned above or below content.
68+
* Unlike a [Navbar](../../nav/Navbar), a toolbar can be used as a subheader.
69+
* Toolbars are positioned automatically at the `top`, but they can be
70+
* positioned at the bottom by setting `position="bottom"` on the component.
71+
*
72+
*
73+
* ### Buttons in a Toolbar
74+
* Buttons placed in a toolbar should be placed inside of the `<ion-buttons>`
75+
* element. An exception to this is a [menuToggle](../../menu/MenuToggle) button.
76+
* It should not be placed inside of the `<ion-buttons>` element. Both the
77+
* `<ion-buttons>` element and the `menuToggle` can be positioned inside of the
78+
* toolbar using different properties. The below chart has a description of each
7379
* property.
7480
*
81+
* | Property | Description |
82+
* |-------------|-----------------------------------------------------------------------------------------------------------------------|
83+
* | `start` | Positions element to the left of the content in `ios` mode, and directly to the right in `md` and `wp` mode. |
84+
* | `end` | Positions element to the right of the content in `ios` mode, and to the far right in `md` and `wp` mode. |
85+
* | `left` | Positions element to the left of all other elements. |
86+
* | `right` | Positions element to the right of all other elements. |
87+
*
88+
* See [usage](#usage) below for some examples.
89+
*
90+
*
7591
* @usage
7692
* ```html
7793
* <ion-toolbar>
94+
* <ion-buttons start>
95+
* <button>
96+
* <ion-icon name="contact"></ion-icon>
97+
* </button>
98+
* <button>
99+
* <ion-icon name="search"></ion-icon>
100+
* </button>
101+
* </ion-buttons>
78102
* <ion-title>My Toolbar Title</ion-title>
79103
* </ion-toolbar>
80104
*
81105
* <ion-toolbar>
82106
* <ion-title>I'm a subheader</ion-title>
83107
* </ion-toolbar>
84108
*
85-
* <ion-content></ion-content>
109+
* <ion-content></ion-content>
86110
*
87111
* <ion-toolbar position="bottom">
88112
* <ion-title>I'm a subfooter</ion-title>
113+
* <ion-buttons right>
114+
* <button>
115+
* <ion-icon name="menu"></ion-icon>
116+
* </button>
117+
* </ion-buttons>
89118
* </ion-toolbar>
90119
*
91120
* <ion-toolbar position="bottom">
92121
* <ion-title>I'm a footer</ion-title>
122+
* <ion-buttons end>
123+
* <button>
124+
* <ion-icon name="more"></ion-icon>
125+
* </button>
126+
* <button>
127+
* <ion-icon name="options"></ion-icon>
128+
* </button>
129+
* </ion-buttons>
93130
* </ion-toolbar>
94-
*
95131
* ```
96132
*
97133
* @property {any} [position] - set position of the toolbar, `top` or `bottom`.
@@ -134,20 +170,27 @@ export class Toolbar extends ToolbarBase {
134170
* @name Title
135171
* @description
136172
* `ion-title` is a component that sets the title of the `Toolbar` or `Navbar`
173+
*
137174
* @usage
175+
*
138176
* ```html
139177
* <ion-navbar *navbar>
140178
* <ion-title>Tab 1</ion-title>
141179
* </ion-navbar>
180+
* ```
142181
*
143-
*<!-- or if you wanted to create a subheader title-->
182+
* Or to create a navbar with a toolbar as a subheader:
183+
*
184+
* ```html
144185
* <ion-navbar *navbar>
145186
* <ion-title>Tab 1</ion-title>
146187
* </ion-navbar>
188+
*
147189
* <ion-toolbar>
148-
* <ion-title>SubHeader</ion-title>
190+
* <ion-title>Subheader</ion-title>
149191
* </ion-toolbar>
150-
* ```
192+
* ```
193+
*
151194
* @demo /docs/v2/demos/title/
152195
*/
153196
@Component({
@@ -195,23 +238,6 @@ export class ToolbarItem {
195238
toolbar && toolbar.addItemRef(elementRef);
196239
navbar && navbar.addItemRef(elementRef);
197240
this.inToolbar = !!(toolbar || navbar);
198-
199-
// Deprecation warning
200-
if (elementRef.nativeElement.tagName === 'ION-NAV-ITEMS') {
201-
202-
if (elementRef.nativeElement.hasAttribute('primary')) {
203-
console.warn('<ion-nav-items primary> has been renamed to <ion-buttons start>, please update your HTML');
204-
elementRef.nativeElement.setAttribute('start', '');
205-
206-
} else if (elementRef.nativeElement.hasAttribute('secondary')) {
207-
console.warn('<ion-nav-items secondary> has been renamed to <ion-buttons end>, please update your HTML');
208-
elementRef.nativeElement.setAttribute('end', '');
209-
210-
} else {
211-
console.warn('<ion-nav-items> has been renamed to <ion-buttons>, please update your HTML');
212-
}
213-
}
214-
215241
}
216242

217243
@ContentChildren(Button)

0 commit comments

Comments
 (0)