Skip to content

Commit 68c0e71

Browse files
authored
fix(button): buttons using fill and color properties now account for hover and focused opacity variables (#23442)
resolves #23441
1 parent 87b4a42 commit 68c0e71

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

core/src/components/button/button.md.scss

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,30 +129,29 @@
129129
// Material Design Button: Hover
130130
// --------------------------------------------------
131131

132+
/**
133+
* Only allow overriding of opacity here
134+
* as developers should not be overriding
135+
* colors when using the color prop.
136+
*/
137+
132138
:host(.button-solid.ion-color.ion-focused) .button-native::after {
133139
background: #{current-color(contrast)};
134-
135-
opacity: .24;
136140
}
137141

138142
:host(.button-clear.ion-color.ion-focused) .button-native::after,
139143
:host(.button-outline.ion-color.ion-focused) .button-native::after {
140144
background: #{current-color(base)};
141-
142-
opacity: .12;
143145
}
144146

147+
145148
@media (any-hover: hover) {
146149
:host(.button-solid.ion-color:hover) .button-native::after {
147150
background: #{current-color(contrast)};
148-
149-
opacity: .08;
150151
}
151152

152153
:host(.button-clear.ion-color:hover) .button-native::after,
153154
:host(.button-outline.ion-color:hover) .button-native::after {
154155
background: #{current-color(base)};
155-
156-
opacity: .04;
157156
}
158157
}

core/src/components/button/test/outline/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<ion-button fill="outline" class="ion-focused" color="dark">Dark.focused</ion-button>
9191
<ion-button fill="outline" class="ion-activated ion-focused" color="dark">Dark.activated.focused</ion-button>
9292
</p>
93+
9394
<p>
9495
<ion-button fill="outline" disabled>Disabled</ion-button>
9596
<ion-button fill="outline" color="secondary" disabled>Secondary Disabled</ion-button>

core/src/components/button/test/states/index.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,31 @@ <h3>Custom</h3>
8989
<ion-button class="custom ion-activated" color="warning" fill="outline">Outline</ion-button>
9090
<ion-button class="custom ion-activated" color="dark" fill="clear">Clear</ion-button>
9191
</p>
92+
93+
<div class="custom-variables">
94+
<ion-button>Button</ion-button>
95+
<ion-button fill="clear">Button</ion-button>
96+
<ion-button fill="outline">Button</ion-button>
97+
98+
<br>
99+
100+
<ion-button class="ion-focused">Button</ion-button>
101+
<ion-button class="ion-focused" fill="clear">Button</ion-button>
102+
<ion-button class="ion-focused" fill="outline">Button</ion-button>
103+
104+
<br>
105+
106+
<ion-button color="tertiary">Button</ion-button>
107+
<ion-button color="tertiary" fill="clear">Button</ion-button>
108+
<ion-button color="tertiary" fill="outline">Button</ion-button>
109+
110+
<br>
111+
112+
<ion-button color="tertiary" class="ion-focused">Button</ion-button>
113+
<ion-button color="tertiary" class="ion-focused" fill="clear">Button</ion-button>
114+
<ion-button color="tertiary" class="ion-focused" fill="outline">Button</ion-button>
115+
</div>
116+
92117
</ion-content>
93118
</ion-app>
94119

@@ -110,6 +135,17 @@ <h3>Custom</h3>
110135
.custom {
111136
--color: red;
112137
}
138+
139+
.custom-variables ion-button {
140+
--color: black;
141+
142+
--background: pink;
143+
--background-focused: red;
144+
--background-hover: green;
145+
146+
--background-focused-opacity: .5;
147+
--background-hover-opacity: .5;
148+
}
113149
</style>
114150
</body>
115151
</html>

0 commit comments

Comments
 (0)