Skip to content

Commit acb7e7f

Browse files
refactor!: update month-calendar Lumo to use base styles (#12595) (#12746)
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
1 parent 6f51784 commit acb7e7f

3 files changed

Lines changed: 59 additions & 91 deletions

File tree

‎packages/date-picker/src/vaadin-month-calendar.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class MonthCalendar extends MonthCalendarMixin(ThemableMixin(PolylitMixin(LumoIn
2626
return monthCalendarStyles;
2727
}
2828

29+
static get lumoInjector() {
30+
return { ...super.lumoInjector, includeBaseStyles: true };
31+
}
32+
2933
/** @protected */
3034
render() {
3135
const weekDayNames = this.__computeWeekDayNames(this.i18n, this.showWeekNumbers);

‎packages/vaadin-lumo-styles/src/components/date-picker-month-calendar.css‎

Lines changed: 52 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,134 +5,104 @@
55
*/
66
@media lumo_components_date-picker-month-calendar {
77
:host {
8-
display: block;
9-
-webkit-user-select: none;
10-
-webkit-tap-highlight-color: transparent;
11-
user-select: none;
128
font-size: var(--lumo-font-size-m);
139
color: var(--lumo-body-text-color);
1410
text-align: center;
15-
padding: 0 var(--lumo-space-xs);
11+
padding: var(--vaadin-date-picker-month-padding, 0 var(--lumo-space-xs));
1612
--_focus-ring-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
1713
--_focus-ring-width: var(--vaadin-focus-ring-width, 2px);
1814
--_selection-color: var(--vaadin-selection-color, var(--lumo-primary-color));
1915
--_selection-color-text: var(--vaadin-selection-color-text, var(--lumo-primary-text-color));
2016
}
2117

22-
#monthGrid {
23-
width: 100%;
24-
border-collapse: collapse;
25-
}
26-
27-
#days-container tr,
28-
#weekdays-container tr {
29-
display: flex;
30-
}
31-
3218
[part~='disabled'] {
3319
pointer-events: none;
3420
}
3521

3622
/* Month header */
3723

3824
[part='month-header'] {
39-
color: var(--lumo-header-text-color);
40-
font-size: var(--lumo-font-size-l);
41-
line-height: 1;
42-
font-weight: 500;
25+
color: var(--vaadin-date-picker-month-header-color, var(--lumo-header-text-color));
26+
font-size: var(--vaadin-date-picker-month-header-font-size, var(--lumo-font-size-l));
4327
margin-bottom: var(--lumo-space-m);
4428
}
4529

4630
/* Week days and numbers */
4731

48-
[part='weekdays'],
49-
[part='weekday'],
50-
[part='week-number'] {
51-
font-size: var(--lumo-font-size-xxs);
32+
[part~='weekday'] {
33+
color: var(--vaadin-date-picker-weekday-color, var(--lumo-secondary-text-color));
34+
font-size: var(--vaadin-date-picker-weekday-font-size, var(--lumo-font-size-xxs));
35+
font-weight: var(--vaadin-date-picker-weekday-font-weight, normal);
5236
line-height: 1;
53-
color: var(--lumo-secondary-text-color);
54-
}
55-
56-
[part='weekdays'] {
5737
margin-bottom: var(--lumo-space-s);
5838
}
5939

60-
[part='weekday']:empty,
61-
[part='week-number'] {
62-
flex-shrink: 0;
63-
padding: 0;
64-
width: var(--lumo-size-xs);
40+
:host([week-numbers]) table {
41+
grid-template-columns: var(--lumo-size-xs) repeat(7, 1fr);
6542
}
6643

67-
[part='week-number'][hidden],
68-
[part='weekday'][hidden] {
69-
display: none;
44+
:host([week-numbers]) [part~='weekday']:empty {
45+
display: flex;
7046
}
7147

72-
/* Date and week number cells */
48+
[part~='week-number'] {
49+
color: var(--vaadin-date-picker-week-number-color, var(--lumo-secondary-text-color));
50+
font-size: var(--vaadin-date-picker-week-number-font-size, var(--lumo-font-size-xxs));
51+
grid-column: auto;
52+
margin: 0;
53+
}
7354

74-
[part~='date'],
75-
[part='week-number'] {
76-
box-sizing: border-box;
77-
display: inline-flex;
78-
align-items: center;
79-
justify-content: center;
80-
height: var(--lumo-size-m);
81-
position: relative;
55+
[part~='week-number']::after {
56+
display: none;
8257
}
8358

59+
/* Date cells */
60+
8461
[part~='date'] {
85-
outline: none;
62+
border-radius: var(--vaadin-date-picker-date-border-radius, var(--lumo-border-radius-m));
63+
height: var(--vaadin-date-picker-date-height, var(--lumo-size-m));
8664
transition: color 0.1s;
8765
}
8866

8967
[part~='date']:not(:empty) {
9068
cursor: var(--lumo-clickable-cursor);
9169
}
9270

93-
[part='weekday'],
94-
[part~='date'] {
95-
width: calc(100% / 7);
96-
padding: 0;
97-
font-weight: normal;
98-
}
99-
100-
:host([week-numbers]) [part='weekday']:not(:empty),
101-
:host([week-numbers]) [part~='date'] {
102-
width: calc((100% - var(--lumo-size-xs)) / 7);
71+
[part~='today'] {
72+
color: var(--vaadin-date-picker-date-today-color, var(--_selection-color-text));
10373
}
10474

105-
/* Today date */
106-
107-
[part~='date'][part~='today'] {
108-
color: var(--_selection-color-text);
75+
[part~='selected'] {
76+
color: var(--vaadin-date-picker-date-selected-color, var(--lumo-primary-contrast-color));
10977
}
11078

111-
/* Focused date */
79+
/* Selection, hover and focus indicator */
11280

113-
[part~='date']::before {
114-
content: '';
115-
position: absolute;
116-
z-index: -1;
81+
[part~='date']::after {
11782
top: 50%;
11883
left: 50%;
119-
transform: translate(-50%, -50%);
120-
min-width: 2em;
121-
min-height: 2em;
84+
translate: -50% -50%;
12285
width: 80%;
12386
height: 80%;
124-
max-height: 100%;
87+
min-width: 2em;
88+
min-height: 2em;
12589
max-width: 100%;
126-
border-radius: var(--lumo-border-radius-m);
90+
max-height: 100%;
91+
aspect-ratio: auto;
92+
outline: none;
93+
}
94+
95+
[part~='selected']::after {
96+
background: var(--vaadin-date-picker-date-selected-background, var(--_selection-color));
12797
}
12898

129-
[part~='date'][part~='focused']::before {
99+
[part~='date'][part~='focused']::after {
130100
box-shadow:
131101
0 0 0 1px var(--lumo-base-color),
132102
0 0 0 calc(var(--_focus-ring-width) + 1px) var(--_focus-ring-color);
133103
}
134104

135-
:host(:not([focused])) [part~='date'][part~='focused']::before {
105+
:host(:not([focused])) [part~='date'][part~='focused']::after {
136106
animation: vaadin-date-picker-month-calendar-focus-date 1.4s infinite;
137107
}
138108

@@ -144,38 +114,32 @@
144114
}
145115
}
146116

147-
[part~='date']:not(:empty):not([part~='disabled']):not([part~='selected']):hover::before {
117+
[part~='date']:not(:empty):not([part~='disabled']):not([part~='selected']):hover::after {
148118
background-color: var(--lumo-primary-color-10pct);
149119
}
150120

151-
[part~='date'][part~='selected'] {
152-
color: var(--lumo-primary-contrast-color);
153-
}
154-
155-
[part~='date'][part~='selected']::before {
156-
background-color: var(--_selection-color);
157-
}
158-
159-
[part~='date'][part~='disabled'] {
160-
color: var(--lumo-disabled-text-color);
161-
}
162-
163121
@media (pointer: coarse) {
164-
[part~='date']:hover:not([part~='selected'])::before,
165-
:host(:not([focus-ring])) [part~='focused']:not([part~='selected'])::before {
122+
[part~='date']:hover:not([part~='selected'])::after,
123+
:host(:not([focus-ring])) [part~='focused']:not([part~='selected'])::after {
166124
display: none;
167125
}
168126

169-
[part~='date']:not(:empty):not([part~='disabled']):active::before {
127+
[part~='date']:not(:empty):not([part~='disabled']):active::after {
170128
display: block;
171129
}
172130

173-
:host(:not([focus-ring])) [part~='date'][part~='selected']::before {
131+
:host(:not([focus-ring])) [part~='date'][part~='selected']::after {
174132
box-shadow: none;
175133
}
176134
}
135+
177136
/* Disabled */
178137

138+
[disabled] {
139+
color: var(--vaadin-date-picker-date-disabled-color, var(--lumo-disabled-text-color));
140+
opacity: 1;
141+
}
142+
179143
:host([disabled]) * {
180144
color: var(--lumo-disabled-text-color) !important;
181145
}

‎packages/vaadin-lumo-styles/src/components/date-picker-overlay-content.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
/* prettier-ignore */
2828
--vaadin-infinite-scroller-item-height:
2929
calc(
30-
var(--lumo-font-size-l) + var(--lumo-space-m)
31-
+ var(--lumo-font-size-xs) + var(--lumo-space-s)
32-
+ var(--lumo-size-m) * 6
30+
var(--vaadin-date-picker-month-header-font-size, var(--lumo-font-size-l)) + var(--lumo-space-m)
31+
+ var(--vaadin-date-picker-weekday-font-size, var(--lumo-font-size-xs)) + var(--lumo-space-s)
32+
+ var(--vaadin-date-picker-date-height, var(--lumo-size-m)) * 6
3333
+ var(--lumo-space-s)
3434
);
3535
--vaadin-infinite-scroller-buffer-offset: 10%;

0 commit comments

Comments
 (0)