-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathdatetime.ios.scss
More file actions
307 lines (250 loc) · 8.28 KB
/
datetime.ios.scss
File metadata and controls
307 lines (250 loc) · 8.28 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
296
297
298
299
300
301
302
303
304
305
306
307
@import "./datetime.scss";
@import "./datetime.ios.vars.scss";
@import "../../themes/ionic.globals.ios";
:host {
--background: #{ion-color(light, base)};
--background-rgb: #{ion-color(light, base, null, true)};
--title-color: #{$text-color-step-400};
}
:host(.datetime-presentation-date-time:not(.datetime-prefer-wheel)),
:host(.datetime-presentation-time-date:not(.datetime-prefer-wheel)),
:host(.datetime-presentation-date:not(.datetime-prefer-wheel)) {
min-height: 350px;
}
// Header
// -----------------------------------
:host .datetime-header {
@include padding($datetime-ios-padding, $datetime-ios-padding, $datetime-ios-padding, $datetime-ios-padding);
border-bottom: $datetime-ios-border-color;
font-size: dynamic-font-max(14px, 1.6);
}
:host .datetime-header .datetime-title {
color: var(--title-color);
}
:host .datetime-header .datetime-selected-date {
@include margin(10px, null, null, null);
}
// Calendar / Header / Action Buttons
// -----------------------------------
.calendar-month-year-toggle {
@include padding(0px, 16px, 0px, #{$datetime-ios-padding});
min-height: 44px;
font-size: dynamic-font-max(16px, 1.6);
font-weight: 600;
&.ion-focused::after {
opacity: 0.15;
}
}
.calendar-month-year-toggle #toggle-wrapper {
@include margin(10px, 8px, 10px, 0);
}
:host .calendar-action-buttons .calendar-month-year-toggle ion-icon,
:host .calendar-action-buttons ion-buttons ion-button {
color: current-color(base);
}
:host .calendar-action-buttons ion-buttons {
align-items: stretch;
height: 100%;
}
:host .calendar-action-buttons ion-buttons ion-button {
@include margin(0, 0, 0, 0);
}
// Calendar / Header / Days of Week
// -----------------------------------
:host .calendar-days-of-week {
@include padding(0, $datetime-ios-padding * 0.5, 0, $datetime-ios-padding * 0.5);
color: $text-color-step-700;
font-size: dynamic-font-max(12px, 1.6);
font-weight: 600;
line-height: 24px;
text-transform: uppercase;
}
@supports (border-radius: mod(1px, 1px)) {
.calendar-days-of-week .day-of-week {
/**
* When the computed font size is 24px
* we want the days of the week to only
* show the first letter of each day.
*
* We use the modulus operator to ensure
* that any font size less than 24px is
* unchanged (i.e. 16 % 24 = 16). If the
* font size is 24px then the remainder
* will be 0.
*/
$max-font-size: min(1rem, $datetime-dynamic-font-breakpoint);
$remainder: mod($max-font-size, $datetime-dynamic-font-breakpoint);
/**
* From here, we scale the remainder to get
* a width value larger than 20px.
* We then clamp the width to have a max width
* of 100% so that each element does not appear
* too wide if $width is a very large number.
*
* When the font size is >=24px then $remainder
* will be 0px. This results in $width being 0px
* since 0px * 10 is still 0px. We set a minimum
* width of 20px below so that the days of the
* week still show when the font size is >=24px
* and have a fixed width of 20px.
*
* The days of the week text on iOS have a maximum font size
* that is no larger than 20px, so setting a minimum width
* of 20px ensures that the text will always fit. (See font-size
* declaration in the .calendar-days-of-week block).
*/
$width: calc($remainder * 10);
width: clamp(20px, #{$width}, 100%);
/**
* We show the first letter of the week
* by setting the width small such that all other
* letters wrap to the next line. While we do have
* overflow: hidden to visually hide the overflowing
* text, we need to explicitly set the height of the
* container too otherwise it will increase as the text wraps.
*/
height: $datetime-dynamic-font-breakpoint;
/**
* The above width will cause
* all the other letters to overflow
* to other lines. The below code hides
* those additional letters so only
* the first letter is shown.
*/
overflow: hidden;
}
.calendar-day {
/**
* We use the modulus operator to ensure
* that any font size less than 24px is
* unchanged (i.e. 16 % 24 = 16). If the
* font size is 24px then the remainder
* will be 0.
*/
$maxFontSize: min(1rem, $datetime-dynamic-font-breakpoint);
$remainder: mod($maxFontSize, $datetime-dynamic-font-breakpoint);
/**
* From here, we scale the remainder. The purpose of
* scaling the remainder is to get a border radius
* large enough such that the element's
* shape is a circle.
*
* Note that when the font size is 24px
* then the remainder will be 0, so $radius
* will still be zero.
*/
$radius: calc($remainder * 10);
/**
* In the event that $radius is 0
* we use max() to ensure a minimum
* border radius of 8px which will
* give the day button the rounded
* rectangle appearance.
* For font sizes smaller than 24px
* the border radius will give a circle appearance.
*/
@include border-radius(max(8px, $radius));
}
}
/**
* iOS <17 has a bug where the result of mod() is
* used incorrectly if used inside of another CSS function such
* as calc(). The first set of @support checks accounts for iOS <17.
* We check -webkit-named-image to ensure that non-WebKit browsers are ignored.
* The second set of @support checks account for all other browsers that
* do not support mod() yet.
*/
@supports ((border-radius: mod(1px, 1px)) and (background: -webkit-named-image(apple-pay-logo-black)) and (not (contain-intrinsic-size: none))) or (not (border-radius: mod(1px, 1px))) {
.calendar-days-of-week .day-of-week {
width: auto;
height: auto;
overflow: initial;
}
.calendar-day {
@include border-radius(32px);
}
}
// Calendar / Body
// -----------------------------------
:host .calendar-body .calendar-month .calendar-month-grid {
/**
* We need to apply the padding to
* each month grid item otherwise
* older versions of WebKit will consider
* this padding a snapping point if applied
* on .calendar-month
*/
@include padding($datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5);
align-items: center;
height: calc(100% - #{$datetime-ios-padding});
}
:host .calendar-day-wrapper {
@include padding(4px);
// This is required so that the calendar day wrapper
// will collapse instead of expanding to fill the button
height: 0;
min-height: dynamic-font(16px);
}
:host .calendar-day {
width: $datetime-ios-day-width;
min-width: $datetime-ios-day-width;
height: $datetime-ios-day-height;
font-size: dynamic-font-max(20px, 1.6);
}
.calendar-day.calendar-day-active {
background: current-color(base, 0.2);
font-size: dynamic-font-max(22px, 1.6);
}
/**
* Day that today but not selected
* should have ion-color for text color.
*/
:host .calendar-day.calendar-day-today {
color: current-color(base);
}
/**
* Day that is not today but
* is selected should have ion-color for
* text color and be bolder.
*/
:host .calendar-day.calendar-day-active,
:host .calendar-day.calendar-day-adjacent-day.calendar-day-active {
color: current-color(base);
font-weight: 600;
}
/**
* Day that is selected and is today
* should have base background color
* with contrast text.
*/
:host .calendar-day.calendar-day-today.calendar-day-active {
background: current-color(base);
color: current-color(contrast);
}
:host .calendar-day.calendar-day-adjacent-day {
color: $text-color-step-700;
}
// Time / Header
// -----------------------------------
:host .datetime-time {
@include padding($datetime-ios-padding * 0.5, $datetime-ios-padding, $datetime-ios-padding, $datetime-ios-padding);
font-size: dynamic-font-max(16px, 1.6);
}
:host .datetime-time .time-header {
font-weight: 600;
}
// Footer
// -----------------------------------
:host .datetime-buttons {
@include padding($datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5);
border-top: $datetime-ios-border-color;
}
:host .datetime-buttons ::slotted(ion-buttons),
:host .datetime-buttons ion-buttons {
display: flex;
align-items: center;
justify-content: space-between;
}
:host .datetime-action-buttons {
width: 100%;
}