Skip to content

Commit 79b005d

Browse files
feat(datetime): add parts for calendar day, active, and today (#27641)
Issue number: resolves #25340 --------- - Exposes the following parts for a calendar day: `calendar-day`, `today`, and `active` - Combines the `calendar-day-highlight` element with the `calendar-day` element so developers don't have to know to style two different elements & we don't have to expose them as separate parts - Improves height parity of the calendar day across browsers - Updates the `custom` e2e test to include an example of styling days using the newly exposed CSS parts - Adds tests for the focus states of the calendar day
1 parent e6c7bb6 commit 79b005d

File tree

180 files changed

+370
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+370
-150
lines changed

core/api.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ ion-datetime,css-prop,--background-rgb
428428
ion-datetime,css-prop,--title-color
429429
ion-datetime,css-prop,--wheel-fade-background-rgb
430430
ion-datetime,css-prop,--wheel-highlight-background
431+
ion-datetime,part,calendar-day
432+
ion-datetime,part,calendar-day active
433+
ion-datetime,part,calendar-day today
431434
ion-datetime,part,month-year-button
432435
ion-datetime,part,time-button
433436
ion-datetime,part,time-button active
Loading
Loading
Loading
Loading
Loading
Loading

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@include padding($datetime-ios-padding, $datetime-ios-padding, $datetime-ios-padding, $datetime-ios-padding);
2121

2222
border-bottom: $datetime-ios-border-color;
23-
23+
2424
font-size: 14px;
2525
}
2626

@@ -85,27 +85,32 @@
8585
*/
8686
@include padding($datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5, $datetime-ios-padding * 0.5);
8787

88+
align-items: center;
89+
8890
height: calc(100% - #{$datetime-ios-padding});
8991
}
9092

91-
:host .calendar-day {
92-
font-size: 20px;
93-
}
93+
:host .calendar-day-wrapper {
94+
@include padding(4px);
95+
96+
// This is required so that the calendar day wrapper
97+
// will collapse instead of expanding to fill the button
98+
height: 0;
9499

95-
.calendar-day:focus .calendar-day-highlight,
96-
.calendar-day.calendar-day-active .calendar-day-highlight {
97-
opacity: 0.2;
100+
min-height: 16px;
98101
}
99102

100-
.calendar-day.calendar-day-active .calendar-day-highlight {
101-
background: current-color(base);
103+
:host .calendar-day {
104+
width: $datetime-ios-day-width;
105+
min-width: $datetime-ios-day-width;
106+
107+
height: $datetime-ios-day-height;
108+
109+
font-size: 20px;
102110
}
103111

104-
// !important is needed here to overwrite custom highlight background, which is inline.
105-
// Does not apply to the active state because highlights aren't applied at all there.
106-
.calendar-day:focus .calendar-day-highlight {
107-
/* stylelint-disable-next-line declaration-no-important */
108-
background: current-color(base) !important;
112+
.calendar-day.calendar-day-active {
113+
background: current-color(base, 0.2);
109114
}
110115

111116
/**
@@ -135,12 +140,6 @@
135140
color: current-color(contrast);
136141
}
137142

138-
.calendar-day.calendar-day-today.calendar-day-active .calendar-day-highlight {
139-
background: current-color(base);
140-
141-
opacity: 1;
142-
}
143-
144143
// Time / Header
145144
// -----------------------------------
146145
:host .datetime-time {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ $datetime-ios-time-width: 68px !default;
1515

1616
/// @prop - Border radius of the time picker
1717
$datetime-ios-time-border-radius: 8px !default;
18+
19+
/// @prop - Width of the calendar day
20+
$datetime-ios-day-width: 40px !default;
21+
22+
/// @prop - Height of the calendar day
23+
$datetime-ios-day-height: $datetime-ios-day-width !default;

core/src/components/datetime/datetime.md.scss

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,22 @@
6969

7070
// Individual day button in month
7171
:host .calendar-day {
72-
@include padding(13px, 0, 13px, 0px);
72+
width: $datetime-md-day-width;
73+
min-width: $datetime-md-day-width;
7374

74-
font-size: $datetime-md-calendar-item-font-size;
75-
}
76-
77-
.calendar-day:focus .calendar-day-highlight {
78-
background: current-color(base, 0.2);
75+
height: $datetime-md-day-height;
7976

80-
box-shadow: 0px 0px 0px 4px current-color(base, 0.2);
77+
font-size: $datetime-md-calendar-item-font-size;
8178
}
8279

8380
/**
8481
* Day that today but not selected
8582
* should have ion-color for text color.
8683
*/
8784
:host .calendar-day.calendar-day-today {
88-
color: current-color(base);
89-
}
90-
91-
.calendar-day.calendar-day-today .calendar-day-highlight {
9285
border: 1px solid current-color(base);
86+
87+
color: current-color(base);
9388
}
9489

9590
/**
@@ -101,7 +96,7 @@
10196
color: current-color(contrast);
10297
}
10398

104-
.calendar-day.calendar-day-active .calendar-day-highlight {
99+
.calendar-day.calendar-day-active {
105100
border: 1px solid current-color(base);
106101

107102
background: current-color(base);

0 commit comments

Comments
 (0)