Skip to content

Commit 13762ca

Browse files
tesar-techstsrki
andauthored
DatePicker: add Today and Clear button (#6089)
* Add "Today" button support to DatePicker component. * today translation for datepicker * release notes * Remove showTodayButton from datePicker in favor of adding showTodayButton options to faltpickr itself. Styling bs5. * Update flatpickr.js * Clear Button * Add missing ShowClearButton * Add default flatpickr scss * Remove bs5 styles * Use new buttons in the demo * Release notes * Example in the docs * material css * fluent styles * hover styles --------- Co-authored-by: Mladen Macanovic <mladen.macanovic@blazorise.com> Co-authored-by: Mladen Macanovic <mladen.macanovic@gmail.com>
1 parent 0285364 commit 13762ca

49 files changed

Lines changed: 566 additions & 82 deletions

File tree

Some content is hidden

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

Demos/Blazorise.Demo/Pages/Tests/PickersPage.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Field Horizontal>
1010
<FieldLabel ColumnSize="ColumnSize.IsFull.OnTablet.Is3.OnDesktop">Date</FieldLabel>
1111
<FieldBody ColumnSize="ColumnSize.IsFull.OnTablet.Is9.OnDesktop">
12-
<DatePicker TValue="DateOnly?" @bind-Date="@d1" Placeholder="Select date..." />
12+
<DatePicker TValue="DateOnly?" @bind-Date="@d1" Placeholder="Select date..." ShowTodayButton ShowClearButton />
1313
</FieldBody>
1414
</Field>
1515
<Field Horizontal="true">

Documentation/Blazorise.Docs/Models/Snippets.generated.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,8 @@ void OnDateChanged( DateTime? date )
19171917
DateTime? value;
19181918
}";
19191919

1920+
public const string DatePickerShowButtonsExample = @"<DatePicker TValue=""DateTime?"" ShowTodayButton ShowClearButton />";
1921+
19201922
public const string DatePickerShowWeekNumbersExample = @"<DatePicker TValue=""DateTime?"" ShowWeekNumbers=""true"" />";
19211923

19221924
public const string DatePickerWithIconExample = @"<Addons>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="blazorise-codeblock">
2+
<div class="html"><pre>
3+
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DatePicker</span> <span class="htmlAttributeName">TValue</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">DateTime?</span><span class="quot">&quot;</span> <span class="htmlAttributeName">ShowTodayButton</span> <span class="htmlAttributeName">ShowClearButton</span> <span class="htmlTagDelimiter">/&gt;</span>
4+
</pre></div>
5+
</div>

Documentation/Blazorise.Docs/Pages/Docs/Components/Dates/DatePickerPage.razor

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@
145145
<DocsPageSectionSource Code="DatePickerShowWeekNumbersExample" />
146146
</DocsPageSection>
147147

148+
<DocsPageSection>
149+
<DocsPageSectionHeader Title="Show buttons">
150+
<Paragraph>
151+
Use the <Code>ShowTodayButton</Code>, or <Code>ShowClearButton</Code> parameters to toggle the visibility of the buttons in the calendar view.
152+
</Paragraph>
153+
<Paragraph>
154+
When enabled, a row of buttons will appear at the bottom of the calendar allowing users to quickly navigate to today or clear the selected date.
155+
</Paragraph>
156+
</DocsPageSectionHeader>
157+
<DocsPageSectionContent Outlined FullWidth>
158+
<DatePickerShowButtonsExample />
159+
</DocsPageSectionContent>
160+
<DocsPageSectionSource Code="DatePickerShowButtonsExample" />
161+
</DocsPageSection>
162+
148163
<DocsPageSubtitle>
149164
Formats
150165
</DocsPageSubtitle>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@namespace Blazorise.Docs.Docs.Examples
2+
3+
<DatePicker TValue="DateTime?" ShowTodayButton ShowClearButton />

Documentation/Blazorise.Docs/Pages/News/2025-03-10-release-notes-180.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@
134134
The <Code>DatePicker</Code> component now includes a <Code>ShowWeekNumbers</Code> parameter. When enabled, the calendar displays ISO week numbers alongside each row. This can be helpful for planning or referencing by week.
135135
</Paragraph>
136136

137+
<Heading Size="HeadingSize.Is3">
138+
New Buttons on DatePicker Calendar
139+
</Heading>
140+
141+
<Paragraph>
142+
The <Code>DatePicker</Code> component now includes a <Code>ShowTodayButton</Code> parameter, and a <Code>ShowClearButton</Code> parameter. When enabled, these buttons appear on the calendar, allowing users to quickly select the current date or clear the selected date, respectively. This enhances usability and provides a more intuitive experience for users interacting with the date picker.
143+
</Paragraph>
144+
137145
<Heading Size="HeadingSize.Is3">
138146
Optimized Chart Plugins
139147
</Heading>

Source/Blazorise.AntDesign/Styles/vendors/_flatpickr.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ span.flatpickr-weekday {
8585
.flatpickr-monthSelect-month.selected {
8686
background-color: $primary;
8787
}
88+
89+
.flatpickr-button {
90+
&:hover {
91+
background: rgba($primary,.15);
92+
}
93+
}

Source/Blazorise.AntDesign/wwwroot/blazorise.antdesign.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10772,3 +10772,7 @@ span.flatpickr-weekday {
1077210772
.flatpickr-monthSelect-month.selected {
1077310773
background-color: #1890ff;
1077410774
}
10775+
10776+
.flatpickr-button:hover {
10777+
background: rgba(24, 144, 255, 0.15);
10778+
}

Source/Blazorise.AntDesign/wwwroot/blazorise.antdesign.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Blazorise.Bootstrap/Styles/_vendors/_flatpickr.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ span.flatpickr-weekday {
8585
.flatpickr-monthSelect-month.selected {
8686
background-color: $primary;
8787
}
88+
89+
.flatpickr-button {
90+
&:hover {
91+
background: rgba($primary,.15);
92+
}
93+
}

0 commit comments

Comments
 (0)