-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathbutton.ios.scss
More file actions
295 lines (239 loc) · 8.76 KB
/
button.ios.scss
File metadata and controls
295 lines (239 loc) · 8.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
@import "./button.native";
@import "./button.ios.vars";
@import "../toolbar/toolbar.ios.vars";
// iOS Button
// --------------------------------------------------
:host {
--padding-top: #{$button-ios-padding-top};
--padding-bottom: #{$button-ios-padding-bottom};
--padding-start: #{$button-ios-padding-start};
--padding-end: #{$button-ios-padding-end};
--transition: background-color, opacity 100ms linear;
@include margin($button-ios-margin-top, $button-ios-margin-end, $button-ios-margin-bottom, $button-ios-margin-start);
min-height: #{$button-ios-min-height};
font-size: #{$button-ios-font-size};
font-weight: #{$button-ios-font-weight};
letter-spacing: #{$button-ios-letter-spacing};
}
// Solid Button
// --------------------------------------------------
:host(.button-solid) {
--background-activated: #{ion-color(primary, shade)};
--background-focused: #{ion-color(primary, shade)};
--background-hover: #{ion-color(primary, tint)};
--background-activated-opacity: 1;
--background-focused-opacity: 1;
--background-hover-opacity: 1;
}
// Outline Button
// --------------------------------------------------
:host(.button-outline) {
--border-width: #{$button-ios-outline-border-width};
--border-style: #{$button-ios-outline-border-style};
--background-activated: #{ion-color(primary, base)};
--background-focused: #{ion-color(primary, base)};
--background-hover: transparent;
--background-focused-opacity: 0.1;
--color-activated: #{ion-color(primary, contrast)};
}
// Clear Button
// --------------------------------------------------
:host(.button-clear) {
--background-activated: transparent;
--background-activated-opacity: 0;
--background-focused: #{ion-color(primary, base)};
--background-hover: transparent;
--background-focused-opacity: 0.1;
font-size: #{$button-ios-clear-font-size};
font-weight: #{$button-ios-clear-font-weight};
}
// Toolbar Buttons
// --------------------------------------------------
/**
* The default buttons in a toolbar
* have a different font size/weight
* than buttons outside of a toolbar on iOS.
* However, we still want the "size"/"strong"
* properties to be usable in a toolbar, so we add
* the .in-buttons selector such that we
* can add the different font size/weight in a toolbar
* but still let "size"/"strong" override it.
*/
:host(.in-buttons) {
font-size: #{$toolbar-ios-button-font-size};
font-weight: 400;
}
// Button Sizes
// --------------------------------------------------
:host(.button-large) {
--padding-top: #{$button-ios-large-padding-top};
--padding-start: #{$button-ios-large-padding-start};
--padding-end: #{$button-ios-large-padding-end};
--padding-bottom: #{$button-ios-large-padding-bottom};
min-height: #{$button-ios-large-min-height};
font-size: #{$button-ios-large-font-size};
}
:host(.button-small) {
--padding-top: #{$button-ios-small-padding-top};
--padding-start: #{$button-ios-small-padding-start};
--padding-end: #{$button-ios-small-padding-end};
--padding-bottom: #{$button-ios-small-padding-bottom};
min-height: #{$button-ios-small-min-height};
font-size: #{$button-ios-small-font-size};
}
// Button Shapes
// --------------------------------------------------
:host(.button-soft) {
--border-radius: 6px;
}
:host(.button-soft.button-large) {
--border-radius: 8px;
}
:host(.button-soft.button-small) {
--border-radius: 4px;
}
:host(.button-round) {
--border-radius: 999px;
}
:host(.button-rectangular) {
--border-radius: 0px;
}
// Strong Button
// --------------------------------------------------
:host(.button-strong) {
font-weight: #{$button-ios-strong-font-weight};
}
// Icon Only Button
// --------------------------------------------------
:host(.button-has-icon-only) {
--padding-top: 0;
--padding-bottom: var(--padding-top);
--padding-end: var(--padding-top);
--padding-start: var(--padding-end);
// TODO(FW-6053): replace em value with the min-height variable.
min-width: clamp(30px, 2.125em, 60px);
// TODO(FW-6053): replace em value with the min-height variable.
min-height: clamp(30px, 2.125em, 60px);
}
::slotted(ion-icon[slot="icon-only"]) {
/**
* The values were provided through a native iOS app.
* min font size: 15px, default font size: 18px, max font size: 43px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 16px
* (derived from rem), then the base size can use the default font
* size of the icon.
*/
font-size: dynamic-font-clamp(0.84, 18px, 2.39, 1em);
}
:host(.button-small.button-has-icon-only) {
// TODO(FW-6053): replace em value with the min-height variable.
min-width: clamp(23px, 2.16em, 54px);
// TODO(FW-6053): replace em value with the min-height variable.
min-height: clamp(23px, 2.16em, 54px);
}
:host(.button-small) ::slotted(ion-icon[slot="icon-only"]) {
/**
* The values were provided through a native iOS app.
* min font size: 12px, default font size: 17px, max font size: 40px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 13px
* (derived from rem) and the default font size of the icon is
* 17px, then the base size would need to be increased.
*/
font-size: dynamic-font-clamp(0.58, 20.93px, 1.92, 1em);
}
:host(.button-large.button-has-icon-only) {
// TODO(FW-6053): replace em value with the min-height variable.
min-width: clamp(46px, 2.5em, 78px);
// TODO(FW-6053): replace em value with the min-height variable.
min-height: clamp(46px, 2.5em, 78px);
}
:host(.button-large) ::slotted(ion-icon[slot="icon-only"]) {
/**
* The values were provided through a native iOS app.
* min font size: 15px, default font size: 18px, max font size: 43px
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 20px
* (derived from rem) and the default font size of the icon is
* 18px, then the base size would need to be decreased.
*/
font-size: dynamic-font-clamp(1.05, 14.4px, 2.99, 1em);
}
// iOS Button Focused
// --------------------------------------------------
:host(.button-outline.ion-focused.ion-color) .button-native,
:host(.button-clear.ion-focused.ion-color) .button-native {
color: current-color(base);
&::after {
background: current-color(base);
}
}
:host(.button-solid.ion-color.ion-focused) .button-native::after {
background: #{current-color(shade)};
}
// iOS Button Hover
// --------------------------------------------------
@media (any-hover: hover) {
// Clear and outline buttons use opacity so set
// background to transparent, but this shouldn't
// apply on top of activated
:host(.button-clear:not(.ion-activated):hover),
:host(.button-outline:not(.ion-activated):hover) {
opacity: #{$button-ios-clear-opacity-hover};
}
:host(.button-clear.ion-color:hover) .button-native,
:host(.button-outline.ion-color:hover) .button-native {
color: #{current-color(base)};
&::after {
background: transparent;
}
}
// Solid buttons use the tint background
:host(.button-solid.ion-color:hover) .button-native::after {
background: #{current-color(tint)};
}
// Solid buttons inside of a toolbar should use a tint of the current
// background so use white to tint it, but this should not apply
// when activated
:host(:hover.button-solid.in-toolbar:not(.ion-color):not(.in-toolbar-color):not(.ion-activated))
.button-native::after {
background: #fff;
opacity: 0.1;
}
}
// iOS Button Activated
// --------------------------------------------------
:host(.button-clear.ion-activated) {
opacity: #{$button-ios-clear-opacity-activated};
}
:host(.button-outline.ion-activated.ion-color) .button-native {
color: current-color(contrast);
&::after {
background: current-color(base);
}
}
:host(.button-solid.ion-color.ion-activated) .button-native::after {
background: #{current-color(shade)};
}
// Activated Button in Toolbar
// --------------------------------------------------
:host(.button-outline.ion-activated.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
background: var(--ion-toolbar-color, var(--color));
color: var(--ion-toolbar-activated-button-color);
}