Skip to content

Commit

Permalink
feat(toolbar): control toolbar borders on top/bottom
Browse files Browse the repository at this point in the history
 Toolbars can be stacked up vertically in `<ion-header>`,
`<ion-content>`, and `<ion-footer>` elements. However, toolbars also
come with borders on both the top and bottom of the toolbar. To give
developers full control of the design, Ionic also includes the
`no-border-bottom` and `no-border-top` attributes. For example,
sometimes two vertically stacked toolbars may have different background
colors, in this case it might be best to leave a border between them.
However, if they have the same background color, the app may look best
without a border between them. The main point here is, it's entirely up
to the app's design to decide when and when not to show borders between
toolbars, and to do so then each toolbar can individually set
`no-border-bottom` and `no-border-top` attributes.
  • Loading branch information
adamdbradley committed Jun 20, 2016
1 parent a1223da commit 3a7addf
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/animations/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Animation {
var i: number;

if (ele) {
if (Array.isArray(ele)) {
if (ele.length) {
for (i = 0; i < ele.length; i++) {
this._addEle(ele[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/test/cordova/page1.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</button>
</ion-navbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-title>I'm a toolbar</ion-title>
</ion-toolbar>

Expand Down
6 changes: 3 additions & 3 deletions src/components/app/test/cordova/page2.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-header>

<ion-navbar>
<ion-navbar no-border-bottom>
<ion-title>Page 2</ion-title>
<button menuToggle>
<ion-icon name="menu"></ion-icon>
Expand All @@ -15,8 +15,8 @@
</button>
</ion-navbar>

<ion-toolbar>
<ion-title>I'm a toolbar</ion-title>
<ion-toolbar no-border-top>
Hello, I am a sub header, with no border on top
</ion-toolbar>

</ion-header>
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $z-index-refresher: 0;
$z-index-page-container: 0;
$z-index-selected-tab: 1;
$z-index-toolbar: 10;
$z-index-toolbar-background: 0;
$z-index-toolbar-background: -1;

$z-index-backdrop: 2;
$z-index-overlay-wrapper: 10;
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ModalPassData {
<ion-title>Toolbar 1</ion-title>
</ion-toolbar>
<ion-toolbar>
<ion-toolbar no-border-top>
<ion-title>Toolbar 2</ion-title>
</ion-toolbar>
</ion-header>
Expand Down
25 changes: 23 additions & 2 deletions src/components/nav/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class FullPage {
<button>S1g</button>
</ion-buttons>
</ion-navbar>
<ion-toolbar no-border-top>
<ion-title>I'm a sub header!</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
Expand All @@ -227,8 +230,11 @@ class FullPage {
</ion-content>
<ion-footer>
<ion-toolbar>
Footer
<ion-toolbar no-border-bottom>
I'm a sub footer!
</ion-toolbar>
<ion-toolbar no-border-top>
<ion-title>Footer</ion-title>
</ion-toolbar>
</ion-footer>
`
Expand Down Expand Up @@ -281,6 +287,11 @@ class PrimaryHeaderPage {
</ion-header>
<ion-content>
<ion-toolbar no-border-top>
I'm a sub header in the content!
</ion-toolbar>
<ion-list>
<ion-item>
Expand All @@ -296,7 +307,17 @@ class PrimaryHeaderPage {
<button ion-item (click)="setRoot()">setRoot(FirstPage)</button>
<button ion-item (click)="toggleBackButton()">Toggle hideBackButton</button>
<button ion-item (click)="setBackButtonText()">Set Back Button Text</button>
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
</ion-list>
<ion-toolbar no-border-bottom>
I'm a sub footer in the content!
</ion-toolbar>
<ion-toolbar no-border-bottom no-border-top>
And I'm a sub footer in the content too!
</ion-toolbar>
</ion-content>
<ion-footer>
Expand Down
4 changes: 2 additions & 2 deletions src/components/searchbar/test/nav/search.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ion-header>

<ion-navbar>
<ion-navbar no-border-bottom>
<ion-title>Searchbar</ion-title>
</ion-navbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-searchbar primary (ionInput)="getItems($event)" placeholder="Filter Schedules">
</ion-searchbar>
</ion-toolbar>
Expand Down
8 changes: 4 additions & 4 deletions src/components/segment/test/basic/main.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-header>

<ion-toolbar>
<ion-toolbar no-border-bottom>
<ion-segment id="segment" [(ngModel)]="relationship" (ionChange)="onSegmentChanged($event)">
<ion-segment-button value="friends" (ionSelect)="onSegmentSelected($event)" class="e2eSegmentFriends">
Friends
Expand All @@ -11,7 +11,7 @@
</ion-segment>
</ion-toolbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-buttons end>
<button>
<ion-icon name="search"></ion-icon>
Expand Down Expand Up @@ -117,7 +117,7 @@ <h4>Model style: NgModel</h4>
</ion-segment>
</ion-toolbar>

<ion-toolbar>
<ion-toolbar no-border-top no-border-bottom>
<ion-segment [(ngModel)]="appType" danger>
<ion-segment-button value="paid">
Default
Expand All @@ -131,7 +131,7 @@ <h4>Model style: NgModel</h4>
</ion-segment>
</ion-toolbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-segment [(ngModel)]="appType" dark [disabled]="isDisabled">
<ion-segment-button value="paid">
Default
Expand Down
4 changes: 2 additions & 2 deletions src/components/segment/test/nav/main.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<ion-header>

<ion-navbar>
<ion-navbar no-border-bottom>
<ion-title>
Segment under Navbar
</ion-title>
</ion-navbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-segment [(ngModel)]="signInType">
<ion-segment-button value="new">
New
Expand Down
4 changes: 2 additions & 2 deletions src/components/segment/test/swipe/main.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<ion-header>

<ion-navbar>
<ion-navbar no-border-bottom>
<ion-title>
Segment Swipeable under Navbar
</ion-title>
</ion-navbar>

<ion-toolbar>
<ion-toolbar no-border-top>
<ion-segment [(ngModel)]="selectedSegment" (ionChange)="onSegmentChanged($event)">
<ion-segment-button value="first">
First
Expand Down
8 changes: 2 additions & 6 deletions src/components/select/test/single-value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ionicBootstrap} from '../../../../../src';
templateUrl: 'main.html'
})
class E2EPage {
musicAlertOpts;
musicAlertOpts: any;
gender: string;
gaming: string;
os: string;
Expand All @@ -30,17 +30,13 @@ class E2EPage {
title: '1994 Music',
subTitle: 'Select your favorite'
};

setTimeout(() => {
this.gender = 'm';
}, 1500);
}

gamingCancel() {
console.log('Gaming Select, Cancel');
}

gamingChange(selectedValue) {
gamingChange(selectedValue: any) {
console.log('Gaming Select, Change value:', selectedValue);
}

Expand Down
1 change: 1 addition & 0 deletions src/components/tabs/test/colors/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ ion-tabs ion-tabbar {
top: auto;
height: auto;
visibility: visible;
opacity: 1;
}
1 change: 1 addition & 0 deletions src/components/tabs/test/tab-bar-scenarios/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ ion-tabs ion-tabbar {
top: auto;
height: auto;
visibility: visible;
opacity: 1;
}
4 changes: 2 additions & 2 deletions src/components/toast/test/basic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<br />
<button block (click)="showDismissDurationToast()">Custom (1.5s) Duration</button>
<button block (click)="showToastWithCloseButton('bottom')" class="e2eOpenToast">With closeButtonText</button>
<button block (click)="showToastWithCloseButton('top')" class="e2eOpenToast">Top With closeButtonText</button>
<button block (click)="showToastWithCloseButton('middle')" class="e2eOpenToast">Middle With closeButtonText</button>
<button block (click)="showToastWithCloseButton('top')">Top With closeButtonText</button>
<button block (click)="showToastWithCloseButton('middle')">Middle With closeButtonText</button>

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lacinia purus ac turpis fermentum, nec accumsan nulla rutrum. Aenean lorem est, luctus id iaculis ac, ultricies quis odio. Aenean imperdiet imperdiet ex et vehicula. Suspendisse vulputate turpis quis ultricies porttitor. Proin malesuada tortor at libero laoreet, eu eleifend enim pulvinar. Nulla facilisi. Fusce sit amet mauris mauris. Mauris consequat libero sed egestas tincidunt.
Expand Down
34 changes: 14 additions & 20 deletions src/components/toolbar/toolbar.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,35 @@ $navbar-ios-height: $toolbar-ios-height !default;
}


// iOS Header Toolbar
// iOS Toolbar Background
// --------------------------------------------------

ion-header {
border: 0;
.toolbar-background {
border-top-width: 1px;
border-bottom-width: 1px;
border-style: solid;
border-color: $toolbar-ios-border-color;
background: $toolbar-ios-background;
}

&.hairlines ion-header {
&.hairlines .toolbar-background {
border-top-width: $hairlines-width;
border-bottom-width: $hairlines-width;
}


// iOS Footer Toolbar
// iOS Toolbar Borders
// --------------------------------------------------

ion-footer {
border: 0;
border-top-width: 1px;
border-style: solid;
border-color: $toolbar-ios-border-color;
ion-header .toolbar:first-child .toolbar-background,
ion-menu > .toolbar:first-child .toolbar-background,
.toolbar[no-border-top] .toolbar-background {
border-top-width: 0;
}

&.hairlines ion-footer {
border-top-width: $hairlines-width;
}


// iOS Toolbar Background
// --------------------------------------------------

.toolbar-background {
background: $toolbar-ios-background;
ion-footer .toolbar:last-child .toolbar-background,
.toolbar[no-border-bottom] .toolbar-background {
border-bottom-width: 0;
}


Expand Down
36 changes: 28 additions & 8 deletions src/components/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,25 @@ export class ToolbarBase extends Ion {
* | `left` | Positions element to the left of all other elements. |
* | `right` | Positions element to the right of all other elements. |
*
* See [usage](#usage) below for some examples.
*
* ### Multiple Toolbars
* Toolbars can be stacked up vertically in `<ion-header>`, `<ion-content>`, and
* `<ion-footer>` elements. However, toolbars also come with borders on both
* the top and bottom of the toolbar. To give developers full control of the
* design, Ionic also includes the `no-border-bottom` and `no-border-top` attributes.
* For example, sometimes two vertically stacked toolbars may have different
* background colors, in this case it might be best to leave a border between them.
* However, if they have the same background color, the app may look best without
* a border between them. The main point here is, it's entirely up to the app's design
* to decide when and when not to show borders between toolbars, and to do so then
* each toolbar can individually set `no-border-bottom` and `no-border-top` attributes.
*
*
* @usage
* ```html
* <ion-header>
*
* <ion-toolbar>
* <ion-toolbar no-border-bottom>
* <ion-buttons start>
* <button>
* <ion-icon name="contact"></ion-icon>
Expand All @@ -135,7 +146,7 @@ export class ToolbarBase extends Ion {
* <ion-title>My Toolbar Title</ion-title>
* </ion-toolbar>
*
* <ion-toolbar>
* <ion-toolbar no-border-top>
* <ion-title>I'm a subheader</ion-title>
* </ion-toolbar>
*
Expand All @@ -153,7 +164,7 @@ export class ToolbarBase extends Ion {
*
* <ion-footer>
*
* <ion-toolbar>
* <ion-toolbar no-border-bottom>
* <ion-title>I'm a subfooter</ion-title>
* <ion-buttons right>
* <button>
Expand All @@ -162,7 +173,7 @@ export class ToolbarBase extends Ion {
* </ion-buttons>
* </ion-toolbar>
*
* <ion-toolbar>
* <ion-toolbar no-border-top>
* <ion-title>I'm a footer</ion-title>
* <ion-buttons end>
* <button>
Expand Down Expand Up @@ -201,11 +212,20 @@ export class Toolbar extends ToolbarBase {

constructor(
@Optional() viewCtrl: ViewController,
elementRef: ElementRef,
config: Config
@Optional() header: Header,
@Optional() footer: Footer,
config: Config,
elementRef: ElementRef
) {
super(elementRef);
viewCtrl && viewCtrl.setToolbarRef(elementRef);

if (viewCtrl && (header || footer)) {
// only toolbars within headers and footer are view toolbars
// toolbars within the content are not view toolbars, since they
// are apart of the content, and could be anywhere within the content
viewCtrl.setToolbarRef(elementRef);
}

this._sbPadding = config.getBoolean('statusbarPadding');
}

Expand Down

0 comments on commit 3a7addf

Please sign in to comment.