Skip to content

Commit 51a86fb

Browse files
feat(datetime): add datetime styles for ionic theme (#29807)
Adds the styles for Datetime in the `ionic` theme for the following (days, months, arrows, weeks): - Typography - Colors - Spacing - Sizing - States (selected, pressed, focus, hover)
1 parent ccf1f65 commit 51a86fb

19 files changed

+340
-140
lines changed

core/api.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,19 +691,16 @@ ion-datetime,event,ionFocus,void,true
691691
ion-datetime,css-prop,--background,ionic
692692
ion-datetime,css-prop,--background,ios
693693
ion-datetime,css-prop,--background,md
694-
ion-datetime,css-prop,--background-rgb,ionic
695694
ion-datetime,css-prop,--background-rgb,ios
696695
ion-datetime,css-prop,--background-rgb,md
697-
ion-datetime,css-prop,--title-color,ionic
696+
ion-datetime,css-prop,--focus-ring-color,ionic
697+
ion-datetime,css-prop,--focus-ring-width,ionic
698698
ion-datetime,css-prop,--title-color,ios
699699
ion-datetime,css-prop,--title-color,md
700-
ion-datetime,css-prop,--wheel-fade-background-rgb,ionic
701700
ion-datetime,css-prop,--wheel-fade-background-rgb,ios
702701
ion-datetime,css-prop,--wheel-fade-background-rgb,md
703-
ion-datetime,css-prop,--wheel-highlight-background,ionic
704702
ion-datetime,css-prop,--wheel-highlight-background,ios
705703
ion-datetime,css-prop,--wheel-highlight-background,md
706-
ion-datetime,css-prop,--wheel-highlight-border-radius,ionic
707704
ion-datetime,css-prop,--wheel-highlight-border-radius,ios
708705
ion-datetime,css-prop,--wheel-highlight-border-radius,md
709706
ion-datetime,part,calendar-day

core/src/components/datetime/datetime.scss renamed to core/src/components/datetime/datetime.common.scss

Lines changed: 5 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
@import "../../themes/native/native.globals";
22

3-
// Datetime
3+
// Datetime: Common Styles
44
// --------------------------------------------------
55

66
:host {
77
/**
88
* @prop --background: The primary background of the datetime component.
9-
* @prop --background-rgb: The primary background of the datetime component in RGB format.
10-
* @prop --title-color: The text color of the title.
11-
*
12-
* @prop --wheel-highlight-background: The background of the highlight under the selected
13-
* item when using a wheel style layout, or in the month/year picker for grid style layouts.
14-
* @prop --wheel-highlight-border-radius: The border radius of the highlight under the selected
15-
* item when using a wheel style layout, or in the month/year picker for grid style layouts.
16-
* @prop --wheel-fade-background-rgb: The color of the gradient covering non-selected items
17-
* when using a wheel style layout, or in the month/year picker for grid style layouts. Must
18-
* be in RGB format, e.g. `255, 255, 255`.
199
*/
20-
2110
display: flex;
2211

2312
flex-flow: column;
@@ -32,19 +21,6 @@
3221
height: auto;
3322
}
3423

35-
:host(.datetime-size-fixed:not(.datetime-prefer-wheel)) {
36-
max-width: 350px;
37-
}
38-
39-
/**
40-
* This ensures that the picker is appropriately
41-
* sized and never truncates the text.
42-
*/
43-
:host(.datetime-size-fixed.datetime-prefer-wheel) {
44-
min-width: 350px;
45-
max-width: max-content;
46-
}
47-
4824
:host(.datetime-size-cover) {
4925
width: 100%;
5026
}
@@ -68,6 +44,7 @@
6844

6945
opacity: 1;
7046
}
47+
7148
/**
7249
* Changing the physical order of the
7350
* picker columns in the DOM is added
@@ -157,7 +134,6 @@
157134
* Disabled buttons should have full opacity
158135
* in readonly mode
159136
*/
160-
161137
.calendar-day[disabled]:not(.calendar-day-constrained),
162138
.datetime-action-buttons ion-button[disabled] {
163139
opacity: 1;
@@ -213,12 +189,9 @@
213189
justify-content: space-between;
214190
}
215191

216-
:host .calendar-action-buttons ion-button {
217-
--background: transparent;
218-
}
219-
220192
// Calendar / Header / Days of Week
221193
// -----------------------------------
194+
222195
:host .calendar-days-of-week {
223196
display: grid;
224197
grid-template-columns: repeat(7, 1fr);
@@ -237,6 +210,7 @@
237210

238211
// Calendar / Body
239212
// -----------------------------------
213+
240214
:host .calendar-body {
241215
/**
242216
* Show all calendar months inline
@@ -330,7 +304,6 @@
330304
* and horizontally within its grid cell.
331305
*/
332306
.calendar-day {
333-
@include border-radius(50%);
334307
@include padding(0px);
335308
@include margin(0px);
336309

@@ -348,25 +321,15 @@
348321
background: none;
349322
color: currentColor;
350323

351-
font-family: $font-family-base;
352-
353324
cursor: pointer;
354325

355326
appearance: none;
356327

357328
z-index: 0;
358329
}
359330

360-
:host .calendar-day[disabled] {
331+
.calendar-day[disabled] {
361332
pointer-events: none;
362-
363-
opacity: 0.4;
364-
}
365-
366-
.calendar-day:focus {
367-
background: current-color(base, 0.2);
368-
369-
box-shadow: 0px 0px 0px 4px current-color(base, 0.2);
370333
}
371334

372335
// Time / Header
@@ -378,32 +341,17 @@
378341
justify-content: space-between;
379342
}
380343

381-
:host(.datetime-presentation-time) .datetime-time {
382-
@include padding(0);
383-
}
384-
385-
:host ion-popover {
386-
--height: 200px;
387-
}
388-
389344
:host .time-header {
390345
display: flex;
391346

392347
align-items: center;
393348
}
394349

395350
:host .time-body {
396-
@include border-radius(8px);
397-
@include padding(6px, 12px, 6px, 12px);
398-
399351
display: flex;
400352

401353
border: none;
402354

403-
background: var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));
404-
405-
color: $text-color;
406-
407355
font-family: inherit;
408356
font-size: inherit;
409357

@@ -412,19 +360,12 @@
412360
appearance: none;
413361
}
414362

415-
:host .time-body-active {
416-
color: current-color(base);
417-
}
418-
419363
:host(.in-item) {
420364
position: static;
421365
}
422366

423367
// Year Picker
424368
// -----------------------------------
425-
:host(.show-month-and-year) .calendar-action-buttons .calendar-month-year-toggle {
426-
color: #{current-color(base)};
427-
}
428369

429370
.calendar-month-year {
430371
min-width: 0;
@@ -444,28 +385,9 @@
444385
cursor: pointer;
445386

446387
z-index: 1;
447-
448-
&::after {
449-
@include button-state();
450-
451-
transition: opacity 15ms linear, background-color 15ms linear;
452-
453-
z-index: -1;
454-
}
455-
456-
&.ion-focused::after {
457-
background: currentColor;
458-
}
459-
460-
&:disabled {
461-
opacity: 0.3;
462-
pointer-events: none;
463-
}
464388
}
465389

466390
.calendar-month-year-toggle ion-icon {
467-
@include padding(0, 0, 0, 4px);
468-
469391
flex-shrink: 0;
470392
}
471393

@@ -474,12 +396,3 @@
474396

475397
align-items: center;
476398
}
477-
478-
// Picker Custom Variables
479-
// -----------------------------------
480-
481-
ion-picker {
482-
--highlight-background: var(--wheel-highlight-background);
483-
--highlight-border-radius: var(--wheel-highlight-border-radius);
484-
--fade-background-rgb: var(--wheel-fade-background-rgb);
485-
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
@use "../../themes/ionic/ionic.globals.scss" as globals;
2+
@use "./datetime.common";
3+
4+
// Ionic Datetime
5+
// --------------------------------------------------
6+
7+
:host {
8+
/**
9+
* @prop --focus-ring-color: The color of the ring around the focused element.
10+
* @prop --focus-ring-width: The width of the ring around the focused element.
11+
*/
12+
--background: #{globals.$ionic-color-base-white};
13+
--focus-ring-color: #{globals.$ionic-state-focus-1};
14+
--focus-ring-width: #{globals.$ionic-border-radius-050};
15+
}
16+
17+
// Calendar Header
18+
// -----------------------------------
19+
20+
.calendar-action-buttons {
21+
@include globals.padding(globals.$ionic-space-200, null);
22+
23+
align-items: center;
24+
25+
height: globals.$ionic-scale-1400;
26+
27+
box-sizing: border-box;
28+
}
29+
30+
.calendar-month-year {
31+
flex: 1 0 0;
32+
}
33+
34+
// Month year toggle should match the
35+
// default round clear button style
36+
.calendar-month-year-toggle {
37+
@include globals.border-radius(globals.$ionic-border-radius-full);
38+
@include globals.typography(globals.$ionic-action-lg);
39+
@include globals.padding(globals.$ionic-space-200, globals.$ionic-space-400);
40+
41+
min-width: globals.$ionic-scale-1600;
42+
min-height: globals.$ionic-scale-1000;
43+
44+
border: var(--focus-ring-width) globals.$ionic-border-style-solid transparent;
45+
46+
color: globals.$ionic-color-primary-base;
47+
}
48+
49+
// Hovered Month Year Toggle
50+
@media (any-hover: hover) {
51+
.calendar-month-year-toggle:hover {
52+
background: globals.$ionic-color-neutral-200;
53+
}
54+
}
55+
56+
// Focused Month Year Toggle
57+
.calendar-month-year-toggle.ion-focused {
58+
border-color: var(--focus-ring-color);
59+
}
60+
61+
// Activated Month Year Toggle
62+
.calendar-month-year-toggle.ion-activated {
63+
background: globals.$ionic-color-neutral-200;
64+
}
65+
66+
// TODO(ROU-11119): Rewrite this when we replace the ion-button with a native button
67+
.calendar-next-prev ion-button.button-has-icon-only {
68+
--color: #{globals.$ionic-color-neutral-1000};
69+
--background-activated: #{globals.$ionic-color-neutral-200};
70+
--background-hover: #{globals.$ionic-color-neutral-200};
71+
--background-hover-opacity: 1;
72+
}
73+
74+
// TODO(ROU-11119): Rewrite this when we replace the ion-button with a native button
75+
.calendar-next-prev ion-button.button-has-icon-only.ion-focused::part(native) {
76+
border: globals.$ionic-border-size-050 globals.$ionic-border-style-solid globals.$ionic-state-focus-1;
77+
78+
outline: none;
79+
}
80+
81+
// Calendar Days of Week
82+
// -----------------------------------
83+
84+
.calendar-days-of-week {
85+
@include globals.typography(globals.$ionic-overline-medium);
86+
87+
align-content: center;
88+
89+
height: globals.$ionic-scale-1200;
90+
91+
color: globals.$ionic-color-neutral-800;
92+
}
93+
94+
// Calendar Day
95+
// -----------------------------------
96+
97+
.calendar-day {
98+
@include globals.border-radius(globals.$ionic-border-radius-full);
99+
@include globals.padding(globals.$ionic-space-100);
100+
@include globals.typography(globals.$ionic-action-md);
101+
102+
width: globals.$ionic-scale-1200;
103+
min-width: globals.$ionic-scale-1200;
104+
105+
height: globals.$ionic-scale-1200;
106+
107+
color: globals.$ionic-color-neutral-1200;
108+
}
109+
110+
// Disabled Day
111+
.calendar-day[disabled]:not(.calendar-day-constrained) {
112+
color: globals.$ionic-color-neutral-500;
113+
}
114+
115+
// Current Day
116+
.calendar-day.calendar-day-today {
117+
color: globals.$ionic-color-primary-base;
118+
}
119+
120+
// Selected Day
121+
.calendar-day.calendar-day-active {
122+
background: globals.$ionic-color-primary-100;
123+
}
124+
125+
// Focused Day
126+
.calendar-day:focus-visible {
127+
border: var(--focus-ring-width) globals.$ionic-border-style-solid var(--focus-ring-color);
128+
}
129+
130+
// Hovered Day
131+
@media (any-hover: hover) {
132+
.calendar-day:not([disabled]):not(:active):hover {
133+
background: globals.$ionic-color-primary-200;
134+
}
135+
}
136+
137+
// Pressed Day
138+
.calendar-day:active {
139+
background: globals.$ionic-color-primary-300;
140+
}

core/src/components/datetime/datetime.ios.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
@import "./datetime.scss";
1+
@import "./datetime.native.scss";
22
@import "./datetime.ios.vars.scss";
33
@import "../../themes/native/native.globals.ios";
44

5+
// iOS Datetime
6+
// --------------------------------------------------
7+
58
:host {
69
--background: #{ion-color(light, base)};
710
--background-rgb: #{ion-color(light, base, null, true)};

core/src/components/datetime/datetime.ios.vars.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
@use "../../themes/native/native.globals" as globals;
2+
13
// iOS Datetime
24
// --------------------------------------------------
35

46
/// @prop - Border color for dividers between header and footer
5-
$datetime-ios-border-color: 0.55px solid $background-color-step-200;
7+
$datetime-ios-border-color: 0.55px solid globals.$background-color-step-200;
68

79
/// @prop - Padding for content
810
$datetime-ios-padding: 16px;

0 commit comments

Comments
 (0)