Skip to content

Commit

Permalink
hotfix: make datepicker work again
Browse files Browse the repository at this point in the history
  • Loading branch information
axzilla committed Nov 25, 2024
1 parent 0485471 commit a5d3e6e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
9 changes: 8 additions & 1 deletion pkg/components/datepicker.templ
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type DatepickerProps struct {
// Class adds custom CSS classes
Class string

Value string

// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
Expand All @@ -45,9 +47,10 @@ type DatepickerProps struct {
templ Datepicker(props DatepickerProps) {
<div
data-date-format={ props.Format }
data-date-value={ props.Value }
x-data="{
datePickerOpen: false,
datePickerValue: '',
datePickerValue: $el.getAttribute('data-date-value'),
datePickerFormat: $el.getAttribute('data-date-format'),
datePickerMonth: '',
datePickerYear: '',
Expand Down Expand Up @@ -153,6 +156,9 @@ templ Datepicker(props DatepickerProps) {
}"
x-init="
currentDate = new Date();
if (datePickerValue) {
currentDate = new Date(Date.parse(datePickerValue));
}
datePickerMonth = currentDate.getMonth();
datePickerYear = currentDate.getFullYear();
datePickerDay = currentDate.getDate();
Expand All @@ -168,6 +174,7 @@ templ Datepicker(props DatepickerProps) {
id={ props.ID }
name={ props.Name }
placeholder={ props.Placeholder }
:value="datePickerValue"
x-modelable="datePickerValue"
@click="toggleDatePicker()"
x-on:keydown.escape="datePickerOpen = false"
Expand Down
43 changes: 29 additions & 14 deletions pkg/components/datepicker_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a5d3e6e

Please sign in to comment.