|
1 | | -// Licensed to the .NET Foundation under one or more agreements. |
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the Apache 2.0 License |
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 | // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone |
@@ -57,16 +57,26 @@ private DateTime StartDate |
57 | 57 | /// 获得/设置 日期样式 |
58 | 58 | /// </summary> |
59 | 59 | private string? GetDayClass(DateTime day, bool overflow) => CssBuilder.Default() |
60 | | - .AddClass("prev-month", day.Month < CurrentDate.Month) |
61 | | - .AddClass("next-month", day.Month > CurrentDate.Month) |
| 60 | + .AddClass("prev-month", IsPrevMonth(day)) |
| 61 | + .AddClass("next-month", IsNextMonth(day)) |
62 | 62 | .AddClass("current", day.Date == SelectValue.Date && Ranger == null && day.Month == SelectValue.Month && !overflow) |
63 | | - .AddClass("start", Ranger != null && day == Ranger.SelectedValue.Start.Date) |
64 | | - .AddClass("end", Ranger != null && day == Ranger.SelectedValue.End.Date) |
65 | | - .AddClass("range", Ranger != null && day >= Ranger.SelectedValue.Start.Date && day <= Ranger.SelectedValue.End.Date) |
| 63 | + .AddClass("start", Ranger != null && day == Ranger.SelectedValue.Start.Date && IsCurrentMonth(day)) |
| 64 | + .AddClass("end", Ranger != null && day == Ranger.SelectedValue.End.Date && IsCurrentMonth(day)) |
| 65 | + .AddClass("range", IsRange(day) && IsCurrentMonth(day)) |
66 | 66 | .AddClass("today", day == DateTime.Today) |
67 | 67 | .AddClass("disabled", IsDisabled(day) || overflow) |
68 | 68 | .Build(); |
69 | 69 |
|
| 70 | + private bool IsPrevMonth(DateTime day) => day.Month < CurrentDate.Month; |
| 71 | + |
| 72 | + private bool IsNextMonth(DateTime day) => day.Month > CurrentDate.Month; |
| 73 | + |
| 74 | + private bool IsCurrentMonth(DateTime day) => day.Month == CurrentDate.Month; |
| 75 | + |
| 76 | + private bool IsRange(DateTime day) => Ranger != null |
| 77 | + && day >= Ranger.SelectedValue.Start.Date |
| 78 | + && day <= Ranger.SelectedValue.End.Date; |
| 79 | + |
70 | 80 | private string? WrapperClassString => CssBuilder.Default("picker-panel-body-main-wrapper") |
71 | 81 | .AddClass("is-open", _showClockPicker) |
72 | 82 | .Build(); |
|
0 commit comments