Skip to content

Commit 4f508a2

Browse files
Add disabled styling for out of range dates
1 parent 658b8cc commit 4f508a2

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

js/picker/views/DaysView.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,24 @@ export default class DaysView extends View {
164164
classList.add('today', 'bg-gray-100', 'dark:bg-gray-600');
165165
}
166166
if (current < this.minDate || current > this.maxDate || this.disabled.includes(current)) {
167-
classList.add('disabled', 'cursor-not-allowed');
167+
classList.remove(
168+
'text-gray-900',
169+
'dark:text-white',
170+
'hover:bg-gray-100',
171+
'dark:hover:bg-gray-600',
172+
'cursor-pointer',
173+
);
174+
classList.add('disabled', 'text-gray-500', 'dark:text-gray-400', 'cursor-not-allowed');
168175
}
169176
if (this.daysOfWeekDisabled.includes(day)) {
170-
classList.add('disabled', 'cursor-not-allowed');
177+
classList.remove(
178+
'text-gray-900',
179+
'dark:text-white',
180+
'hover:bg-gray-100',
181+
'dark:hover:bg-gray-600',
182+
'cursor-pointer',
183+
);
184+
classList.add('disabled', 'text-gray-500', 'dark:text-gray-400', 'cursor-not-allowed');
171185
pushUnique(this.disabled, current);
172186
}
173187
if (this.daysOfWeekHighlighted.includes(day)) {

js/picker/views/MonthsView.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,14 @@ export default class MonthsView extends View {
129129
|| isMinYear && index < this.minMonth
130130
|| isMaxYear && index > this.maxMonth
131131
) {
132-
classList.add('disabled');
132+
classList.remove(
133+
'text-gray-900',
134+
'dark:text-white',
135+
'hover:bg-gray-100',
136+
'dark:hover:bg-gray-600',
137+
'cursor-pointer',
138+
);
139+
classList.add('disabled', 'text-gray-500', 'dark:text-gray-400', 'cursor-not-allowed');
133140
}
134141
if (range) {
135142
const [rangeStart, rangeEnd] = range;

js/picker/views/YearsView.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ export default class YearsView extends View {
101101
classList.add('next');
102102
}
103103
if (current < this.minYear || current > this.maxYear) {
104-
classList.add('disabled');
104+
classList.remove(
105+
'text-gray-900',
106+
'dark:text-white',
107+
'hover:bg-gray-100',
108+
'dark:hover:bg-gray-600',
109+
'cursor-pointer',
110+
);
111+
classList.add('disabled', 'text-gray-500', 'dark:text-gray-400', 'cursor-not-allowed');
105112
}
106113
if (this.range) {
107114
const [rangeStart, rangeEnd] = this.range;

0 commit comments

Comments
 (0)