Skip to content

Commit 658b29b

Browse files
committed
fix(button): add the solid class to bar buttons
updated tests to include toolbar with solid buttons and bar buttons in karma tests. references #6202
1 parent cc50814 commit 658b29b

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

ionic/components/button/button.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ export class Button {
331331
// Support array to allow removal of many styles at once.
332332
let styles = (type instanceof Array ? type : [type]);
333333
styles.forEach(styleName => {
334-
let colorStyle = (styleName !== null && styleName !== 'default' && styleName !== 'solid' ? styleName.toLowerCase() + '-' : '');
334+
// If the role is not a bar-button, don't apply the solid style
335+
styleName = (this._role !== 'bar-button' && styleName === 'solid' ? 'default' : styleName);
336+
let colorStyle = (styleName !== null && styleName !== 'default' ? styleName.toLowerCase() + '-' : '');
335337
this._colors.forEach(colorName => {
336338
this._setClass(colorStyle + colorName, assignCssClass); // button-secondary, button-clear-secondary
337339
});

ionic/components/button/test/button.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export function run() {
6464
expect(hasClass(b, 'button-solid')).toEqual(true);
6565
expect(hasClass(b, 'button-primary')).toEqual(true);
6666
expect(hasClass(b, 'button-secondary')).toEqual(true);
67+
68+
b = mockButton(['solid', 'primary', 'secondary']);
69+
b.setRole('bar-button');
70+
b._assignCss(true);
71+
expect(hasClass(b, 'bar-button-solid')).toEqual(true);
72+
expect(hasClass(b, 'bar-button-solid-primary')).toEqual(true);
73+
expect(hasClass(b, 'bar-button-solid-secondary')).toEqual(true);
6774
});
6875

6976
it('should auto add the default style', () => {
@@ -99,12 +106,21 @@ export function run() {
99106
b._assignCss(true);
100107
expect(hasClass(b, 'button-outline')).toEqual(true);
101108

109+
b = mockButton(['solid']);
110+
b._assignCss(true);
111+
expect(hasClass(b, 'button-solid')).toEqual(true);
112+
102113
b = mockButton(['clear', 'outline', 'small', 'full']);
103114
b._assignCss(true);
104115
expect(hasClass(b, 'button-clear')).toEqual(false);
105116
expect(hasClass(b, 'button-outline')).toEqual(true);
106117
expect(hasClass(b, 'button-small')).toEqual(true);
107118
expect(hasClass(b, 'button-full')).toEqual(true);
119+
120+
b = mockButton(['outline']);
121+
b.setRole('bar-button');
122+
b._assignCss(true);
123+
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
108124
});
109125

110126
it('should read button shape attributes', () => {

ionic/components/button/test/dynamic/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class E2EApp {
88
isDestructive: boolean;
99
isSecondary: boolean;
1010
isCustom: boolean;
11+
isSolid: boolean;
1112
isOutline: boolean;
1213
isClear: boolean;
1314
isClicked: boolean;
@@ -23,6 +24,7 @@ class E2EApp {
2324
this.isDestructive = false;
2425
this.isSecondary = false;
2526
this.isCustom = false;
27+
this.isSolid = false;
2628
this.isOutline = false;
2729
this.isClear = false;
2830
this.isClicked = false;
@@ -35,6 +37,7 @@ class E2EApp {
3537
this.isDestructive = true;
3638
this.isSecondary = true;
3739
this.isCustom = true;
40+
this.isSolid = true;
3841
this.isOutline = true;
3942
this.isClear = true;
4043
this.isClicked = false;

ionic/components/button/test/dynamic/main.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11

22
<ion-toolbar>
3+
<ion-buttons start>
4+
<button [color]="isDestructive ? 'danger' : 'primary'" [outline]="isOutline">Outline</button>
5+
</ion-buttons>
36
<ion-title>Default Buttons</ion-title>
7+
<ion-buttons end>
8+
<button [color]="isSecondary ? 'secondary' : 'primary'" [solid]="isSolid">Solid</button>
9+
</ion-buttons>
410
</ion-toolbar>
511

6-
<ion-content padding text-center>
7-
<h1>Button Attributes Test</h1>
8-
<button block>Primary</button>
12+
<ion-content padding>
13+
<button block [solid]="isSolid">Solid</button>
914
<button block [color]="isDestructive ? 'danger' : 'primary'" [outline]="isOutline">Danger (Outline)</button>
1015
<button block [color]="isSecondary ? 'secondary' : 'primary'" [clear]="isClear">Secondary (Clear)</button>
1116
<button block [color]="myColor1" [round]="isCustom">Custom #1</button>

0 commit comments

Comments
 (0)