Skip to content

Commit 5c21b93

Browse files
committed
Merge pull request #5310 from manucorporat/new-buttons-css
refactor(button): refactor button css to avoid using flex
2 parents 0e3b25f + 64ae100 commit 5c21b93

File tree

11 files changed

+56
-39
lines changed

11 files changed

+56
-39
lines changed

ionic/components/action-sheet/action-sheet.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ion-action-sheet {
8181
}
8282

8383
.action-sheet-cancel {
84-
font-weight: bold;
84+
font-weight: 600;
8585
background: $action-sheet-ios-cancel-button-background-color;
8686
}
8787

ionic/components/alert/alert.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ ion-alert {
222222
flex: 1 1 auto;
223223
min-width: 50%;
224224
font-size: $alert-ios-button-font-size;
225-
min-height: $alert-ios-button-min-height;
225+
height: $alert-ios-button-min-height;
226226
border-radius: $alert-ios-button-border-radius;
227227
border-top: 1px solid $alert-ios-button-border-color;
228228
border-right: 1px solid $alert-ios-button-border-color;

ionic/components/button/button.ios.scss

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $button-ios-small-icon-font-size: 1.3em !default;
3030
margin: $button-ios-margin;
3131
padding: $button-ios-padding;
3232

33-
min-height: $button-ios-height;
33+
height: $button-ios-height;
3434
font-size: $button-ios-font-size;
3535

3636
border-radius: $button-ios-border-radius;
@@ -75,13 +75,13 @@ $button-ios-small-icon-font-size: 1.3em !default;
7575

7676
.button-large {
7777
padding: 0 $button-ios-large-padding;
78-
min-height: $button-ios-large-height;
78+
height: $button-ios-large-height;
7979
font-size: $button-ios-large-font-size;
8080
}
8181

8282
.button-small {
8383
padding: 0 $button-ios-small-padding;
84-
min-height: $button-ios-small-height;
84+
height: $button-ios-small-height;
8585
font-size: $button-ios-small-font-size;
8686
}
8787

@@ -93,9 +93,6 @@ $button-ios-small-icon-font-size: 1.3em !default;
9393
// --------------------------------------------------
9494

9595
.button-block {
96-
// This fixes an issue with flexbox and button on iOS Safari. See #225
97-
display: block;
98-
line-height: $button-ios-height;
9996
margin-left: 0;
10097
margin-right: 0;
10198
}

ionic/components/button/button.md.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $button-md-small-icon-font-size: 1.4em !default;
4343
.button {
4444
margin: $button-md-margin;
4545
padding: $button-md-padding;
46-
min-height: $button-md-height;
46+
height: $button-md-height;
4747
border-radius: $button-md-border-radius;
4848

4949
font-weight: 500;
@@ -96,13 +96,13 @@ $button-md-small-icon-font-size: 1.4em !default;
9696

9797
.button-large {
9898
padding: 0 $button-md-large-padding;
99-
min-height: $button-md-large-height;
99+
height: $button-md-large-height;
100100
font-size: $button-md-large-font-size;
101101
}
102102

103103
.button-small {
104104
padding: 0 $button-md-small-padding;
105-
min-height: $button-md-small-height;
105+
height: $button-md-small-height;
106106
font-size: $button-md-small-font-size;
107107
}
108108

ionic/components/button/button.scss

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ $button-round-border-radius: 64px !default;
99

1010
.button {
1111
position: relative;
12-
display: inline-flex;
13-
flex-shrink: 0;
14-
flex-flow: row nowrap;
15-
align-items: center;
16-
justify-content: center;
12+
display: inline-block;
1713
transition: background-color, opacity 100ms linear;
1814
z-index: 0;
1915

@@ -23,6 +19,7 @@ $button-round-border-radius: 64px !default;
2319

2420
text-align: center;
2521
text-transform: none;
22+
font-kerning: none;
2623

2724
vertical-align: top; // the better option for most scenarios
2825
vertical-align: -webkit-baseline-middle; // the best for those that support it
@@ -32,6 +29,16 @@ $button-round-border-radius: 64px !default;
3229
@include appearance(none);
3330
}
3431

32+
span.button-inner {
33+
width: 100%;
34+
height: 100%;
35+
display: flex;
36+
flex-shrink: 0;
37+
flex-flow: row nowrap;
38+
align-items: center;
39+
justify-content: center;
40+
}
41+
3542
a.button {
3643
text-decoration: none;
3744
}

ionic/components/button/button.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Directive, ElementRef, Renderer, Attribute, Optional, Input} from 'angular2/core';
1+
import {Component, ElementRef, Renderer, Attribute, Optional, Input} from 'angular2/core';
22

33
import {Config} from '../../config/config';
44
import {Toolbar} from '../toolbar/toolbar';
@@ -28,8 +28,9 @@ import {Toolbar} from '../toolbar/toolbar';
2828
* @see {@link /docs/v2/components#buttons Button Component Docs}
2929
3030
*/
31-
@Directive({
32-
selector: 'button,[button]'
31+
@Component({
32+
selector: 'button:not([ion-item]),[button]',
33+
template: '<span class="button-inner"><ng-content></ng-content></span>'
3334
})
3435
export class Button {
3536
private _role: string = 'button'; // bar-button/item-button
@@ -78,7 +79,6 @@ export class Button {
7879
}
7980

8081
this._readAttrs(element);
81-
this._readIcon(element);
8282
}
8383

8484
/**
@@ -89,6 +89,7 @@ export class Button {
8989
if (this.color) {
9090
this._colors = [this.color];
9191
}
92+
this._readIcon(this._elementRef.nativeElement);
9293
this._assignCss(true);
9394
}
9495

@@ -124,6 +125,9 @@ export class Button {
124125
private _readIcon(element: HTMLElement) {
125126
// figure out if and where the icon lives in the button
126127
let childNodes = element.childNodes;
128+
if (childNodes.length == 1) {
129+
childNodes = childNodes[0].childNodes;
130+
}
127131
let childNode;
128132
let nodes = [];
129133
for (let i = 0, l = childNodes.length; i < l; i++) {
@@ -218,9 +222,9 @@ export class Button {
218222
}
219223
}
220224

221-
/**
222-
* @private
223-
*/
225+
/**
226+
* @private
227+
*/
224228
static setRoles(contentButtonChildren, role: string) {
225229
let buttons = contentButtonChildren.toArray();
226230
buttons.forEach(button => {
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1-
21
<ion-toolbar>
32
<ion-title>Full Buttons</ion-title>
43
</ion-toolbar>
54

65
<ion-content>
76

8-
<div>
7+
<p>
98
<a button full href="#">a[button][full]</a>
109
<button full>button[full]</button>
11-
</div>
10+
</p>
11+
12+
<p>
13+
<a button full href="#">
14+
<ion-icon name="help-circle"></ion-icon>
15+
a[button][full] + icon
16+
</a>
17+
<button full>
18+
<ion-icon name="help-circle"></ion-icon>
19+
button[full] + icon
20+
</button>
21+
</p>
1222

13-
<div>
23+
<p>
1424
<a button full outline secondary href="#">a[button][full][outline][secondary]</a>
1525
<button full outline secondary>button[full][outline][secondary]</button>
16-
</div>
26+
</p>
1727

18-
<div>
28+
<p>
1929
<a button full clear light href="#">a[button][full][clear][light]</a>
2030
<button full clear light>button[full][clear][light]</button>
21-
</div>
31+
</p>
2232

23-
<div>
33+
<p>
2434
<a button full clear dark href="#">a[button][full][clear][dark]</a>
2535
<button full clear dark>button[full][clear][dark]</button>
26-
</div>
27-
28-
</ion-content>
36+
</p>
37+
</ion-content>

ionic/components/item/item.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ion-thumbnail[item-right] {
121121
.item-button {
122122
padding: 0 0.5em;
123123
font-size: 1.3rem;
124-
min-height: 24px;
124+
height: 24px;
125125
}
126126

127127
.item-button.button-icon-only ion-icon,

ionic/components/item/item.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ion-icon[item-right] {
9494

9595
.item-button {
9696
padding: 0 0.6em;
97-
min-height: 25px;
97+
height: 25px;
9898
font-size: 1.2rem;
9999
}
100100

ionic/components/searchbar/searchbar.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ion-searchbar {
102102

103103
.searchbar-ios-cancel {
104104
transition: $searchbar-ios-cancel-transition;
105-
min-height: 30px;
105+
height: 30px;
106106

107107
margin-left: 0;
108108
margin-right: 0;

0 commit comments

Comments
 (0)