-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathbutton.md.scss
More file actions
245 lines (201 loc) · 7.65 KB
/
button.md.scss
File metadata and controls
245 lines (201 loc) · 7.65 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
@import "./button.native";
@import "./button.md.vars";
// Material Design Button
// --------------------------------------------------
:host {
--padding-top: #{$button-md-padding-top};
--padding-bottom: #{$button-md-padding-bottom};
--padding-start: #{$button-md-padding-start};
--padding-end: #{$button-md-padding-end};
--transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1), background-color 15ms linear, color 15ms linear;
@include margin($button-md-margin-top, $button-md-margin-end, $button-md-margin-bottom, $button-md-margin-start);
min-height: #{$button-md-min-height};
font-size: #{$button-md-font-size};
font-weight: #{$button-md-font-weight};
letter-spacing: #{$button-md-letter-spacing};
text-transform: #{$button-md-text-transform};
}
// Solid Button
// --------------------------------------------------
:host(.button-solid) {
--background-activated: transparent;
--background-hover: #{ion-color(primary, contrast)};
--background-focused: #{ion-color(primary, contrast)};
--background-activated-opacity: 0;
--background-focused-opacity: 0.24;
--background-hover-opacity: 0.08;
--box-shadow: #{$button-md-box-shadow};
}
:host(.button-solid.ion-activated) {
--box-shadow: #{$button-md-box-shadow-activated};
}
// Outline Button
// --------------------------------------------------
:host(.button-outline) {
--border-width: 2px;
--border-style: solid;
--box-shadow: none;
--background-activated: transparent;
--background-focused: #{ion-color(primary, base)};
--background-hover: #{ion-color(primary, base)};
--background-activated-opacity: 0;
--background-focused-opacity: 0.12;
--background-hover-opacity: 0.04;
}
:host(.button-outline.ion-activated.ion-color) .button-native {
background: transparent;
}
// Clear Button
// --------------------------------------------------
:host(.button-clear) {
--background-activated: transparent;
--background-focused: #{ion-color(primary, base)};
--background-hover: #{ion-color(primary, base)};
--background-activated-opacity: 0;
--background-focused-opacity: 0.12;
--background-hover-opacity: 0.04;
}
// Button Shapes
// -------------------------------------------------------------------------------
:host(.button-soft) {
--border-radius: 4px;
}
:host(.button-round) {
--border-radius: 999px;
}
:host(.button-rectangular) {
--border-radius: 0px;
}
// Button Sizes
// --------------------------------------------------
:host(.button-large) {
--padding-top: #{$button-md-large-padding-top};
--padding-start: #{$button-md-large-padding-start};
--padding-end: #{$button-md-large-padding-end};
--padding-bottom: #{$button-md-large-padding-bottom};
min-height: #{$button-md-large-min-height};
font-size: #{$button-md-large-font-size};
}
:host(.button-small) {
--padding-top: #{$button-md-small-padding-top};
--padding-start: #{$button-md-small-padding-start};
--padding-end: #{$button-md-small-padding-end};
--padding-bottom: #{$button-md-small-padding-bottom};
min-height: #{$button-md-small-min-height};
font-size: #{$button-md-small-font-size};
}
// Strong Button
// --------------------------------------------------
:host(.button-strong) {
font-weight: #{$button-md-strong-font-weight};
}
// Icon Only Button
//
// MD does not specify a small size, these
// styles are based on the iOS small size.
//
// MD does not specify a large size, these
// styles are based on the iOS large size.
// --------------------------------------------------
: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.86em, 60px);
// TODO(FW-6053): replace em value with the min-height variable.
min-height: clamp(30px, 2.86em, 60px);
}
::slotted(ion-icon[slot="icon-only"]) {
/**
* The values were provided through MD design,
* large and small are based on the iOS sizes.
* min font size: 15px, default font size: 22.4px, 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 14px
* (derived from rem) and the default font size of the icon is
* 22.4px, then the base size would need to be increased.
*/
font-size: dynamic-font-clamp(0.59, 25.6px, 1.68, 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 MD design,
* large and small are based on the iOS sizes.
* min font size: 12px, default font size: 16px, 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
* 16px, then the base size would need to be increased.
*/
font-size: dynamic-font-clamp(0.66, 19.7px, 2.05, 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 MD design,
* large and small are based on the iOS sizes.
* min font size: 15px, default font size: 28px, 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
* 28px, then the base size would need to be increased.
*/
font-size: dynamic-font-clamp(0.67, 22.4px, 1.92, 1em);
}
// Button: Hover
// --------------------------------------------------
/**
* Only allow overriding of opacity here
* as developers should not be overriding
* colors when using the color prop.
*/
:host(.button-solid.ion-color.ion-focused) .button-native::after {
background: #{current-color(contrast)};
}
:host(.button-clear.ion-color.ion-focused) .button-native::after,
:host(.button-outline.ion-color.ion-focused) .button-native::after {
background: #{current-color(base)};
}
@media (any-hover: hover) {
:host(.button-solid.ion-color:hover) .button-native::after {
background: #{current-color(contrast)};
}
:host(.button-clear.ion-color:hover) .button-native::after,
:host(.button-outline.ion-color:hover) .button-native::after {
background: #{current-color(base)};
}
}
// Activated Button in Toolbar
// --------------------------------------------------
:host(.button-outline.ion-activated.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native {
background: var(--ion-components-ion-toolbar-activated-bg);
color: #{var(--ion-toolbar-color, var(--background), ion-color(primary, contrast))};
}