Skip to content

Commit

Permalink
fix(button): allow any element type to use the "icon-only" slot (#22168)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitflower authored Oct 6, 2020
1 parent 1878c8e commit c454c84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
}

private get hasIconOnly() {
return !!this.el.querySelector('ion-icon[slot="icon-only"]');
return !!this.el.querySelector('[slot="icon-only"]');
}

private get rippleType() {
Expand Down
37 changes: 19 additions & 18 deletions core/src/components/button/test/icon/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<ion-header>
<ion-toolbar>
<ion-title>Button - Icon</ion-title>
<ion-buttons slot="end">
<ion-button>
<ion-icon slot="icon-only" name="heart"></ion-icon>
</ion-button>
<ion-button class="avatar-button">
<img slot="icon-only" src="/src/components/avatar/test/avatar.svg">
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>

Expand All @@ -26,8 +34,6 @@
<ion-icon name="home" slot="start"></ion-icon>
Left Icon
</ion-button>
</p>
<p>
<ion-button href="#">
<ion-icon name="home" slot="start"></ion-icon>
Left Icon
Expand All @@ -38,8 +44,6 @@
<ion-icon name="star" slot="end"></ion-icon>
Right Icon
</ion-button>
</p>
<p>
<ion-button href="#">
<ion-icon name="star" slot="end"></ion-icon>
Right Icon
Expand All @@ -49,8 +53,6 @@
<ion-button>
<ion-icon name="flag" slot="icon-only"></ion-icon>
</ion-button>
</p>
<p>
<ion-button href="#">
<ion-icon name="flag" slot="icon-only"></ion-icon>
</ion-button>
Expand All @@ -60,8 +62,6 @@
<ion-icon name="help-circle" slot="start"></ion-icon>
Left, Large
</ion-button>
</p>
<p>
<ion-button size="large" href="#">
<ion-icon name="help-circle" slot="start"></ion-icon>
Left, Large
Expand All @@ -72,8 +72,6 @@
<ion-icon name="settings" slot="end"></ion-icon>
Right, Large
</ion-button>
</p>
<p>
<ion-button size="large" href="#">
<ion-icon name="settings" slot="end"></ion-icon>
Right, Large
Expand All @@ -83,8 +81,6 @@
<ion-button size="large">
<ion-icon name="heart" slot="icon-only"></ion-icon>
</ion-button>
</p>
<p>
<ion-button size="large" href="#">
<ion-icon name="heart" slot="icon-only"></ion-icon>
</ion-button>
Expand All @@ -94,8 +90,6 @@
<ion-icon name="checkmark" slot="start"></ion-icon>
Left, Small
</ion-button>
</p>
<p>
<ion-button size="small" href="#">
<ion-icon name="checkmark" slot="start"></ion-icon>
Left, Small
Expand All @@ -106,8 +100,6 @@
<ion-icon name="arrow-forward" slot="end"></ion-icon>
Right, Small
</ion-button>
</p>
<p>
<ion-button size="small" href="#">
<ion-icon name="arrow-forward" slot="end"></ion-icon>
Right, Small
Expand All @@ -117,8 +109,6 @@
<ion-button size="small">
<ion-icon name="search" slot="icon-only"></ion-icon>
</ion-button>
</p>
<p>
<ion-button size="small" href="#">
<ion-icon name="search" slot="icon-only"></ion-icon>
</ion-button>
Expand All @@ -128,4 +118,15 @@
</ion-app>
</body>

<style>
.avatar-button img {
border-radius: 50%;
}

.ios .avatar-button img {
width: 26px;
height: 26px;
}
</style>

</html>

0 comments on commit c454c84

Please sign in to comment.