Skip to content

added radio card, progress bar, datepicker #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 25, 2025
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Install templ
run: |
go install github.com/a-h/templ/cmd/[email protected].819
go install github.com/a-h/templ/cmd/[email protected].856
templ --help

- name: Install TailwindCSS
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM golang:1.23.2
WORKDIR /build

COPY scripts/install.sh .
RUN chmod +x install.sh && ./install.sh && go install github.com/a-h/templ/cmd/[email protected].819
RUN chmod +x install.sh && ./install.sh && go install github.com/a-h/templ/cmd/[email protected].856

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0

Expand Down
2 changes: 1 addition & 1 deletion components/base/alert/alert_templ.go

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

2 changes: 1 addition & 1 deletion components/base/avatar/avatar_templ.go

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

2 changes: 1 addition & 1 deletion components/base/button/button_templ.go

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

2 changes: 1 addition & 1 deletion components/base/card/card_templ.go

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

2 changes: 1 addition & 1 deletion components/base/combobox_templ.go

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

2 changes: 1 addition & 1 deletion components/base/dialog/dialog_templ.go

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

2 changes: 1 addition & 1 deletion components/base/dialog/drawer_templ.go

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

2 changes: 1 addition & 1 deletion components/base/dropdown_templ.go

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

92 changes: 92 additions & 0 deletions components/base/input/datepicker.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package input

import "fmt"
import "github.com/iota-uz/iota-sdk/pkg/composables"

type DatePickerMode string
type DateSelectorType string

const (
DatePickerModeSingle = DatePickerMode("single")
DatePickerModeMultiple = DatePickerMode("multiple")
DatePickerModeRange = DatePickerMode("range")
)

const (
DateSelectorTypeDay = DateSelectorType("day")
DateSelectorTypeMonth = DateSelectorType("month")
DateSelectorTypeWeek = DateSelectorType("week")
DateSelectorTypeYear = DateSelectorType("year")
)

type DatePickerProps struct {
Label string
Placeholder string
Mode DatePickerMode
SelectorType DateSelectorType
Attrs templ.Attributes
DateFormat string
LabelFormat string
MinDate string
MaxDate string
Selected []string
Name string
EndName string
StartName string
Form string
}

templ DatePicker(props DatePickerProps) {
{{ pageCtx := composables.UsePageCtx(ctx) }}
{{ selected, _ := templ.JSONString(props.Selected) }}
<div x-data={ fmt.Sprintf("datePicker({locale: '%s', mode: '%s', dateFormat: '%s', labelFormat: '%s', minDate: '%s', maxDate: '%s', selectorType: '%s', selected: %s})", pageCtx.Locale.String(), props.Mode, props.DateFormat, props.LabelFormat, props.MinDate, props.MaxDate, props.SelectorType, selected) }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be easier to do with templ JSON calling? Like it's done in charts/charts.templ?

Copy link
Contributor Author

@jcbbb jcbbb Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? fmt.Sprintf("datePicker(%s)", templ.JSONString(props))?

Copy link
Contributor

@diyor28 diyor28 Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you're not defining the function the same way I do in charts. Event the option you proposed looks better, don't u agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check @diyor28

@Text(&Props{
Label: props.Label,
Placeholder: props.Placeholder,
Attrs: templ.Attributes{
"x-ref": "input",
},
})
if props.Mode == DatePickerModeRange {
<template x-if="selected.length === 2">
<div class="contents">
<input
type="hidden"
x-model="selected[0]"
if props.Form != "" {
form={ props.Form }
}
if props.StartName != "" {
name={ props.StartName }
} else {
name={ props.Name }
}
/>
<input
type="hidden"
x-model="selected[1]"
if props.Form != "" {
form={ props.Form }
}
if props.EndName != "" {
name={ props.EndName }
} else {
name={ props.Name }
}
/>
</div>
</template>
} else {
<template x-for="date in selected">
<input
type="hidden"
name={ props.Name }
x-model="date"
if props.Form != "" {
form={ props.Form }
}
/>
</template>
}
</div>
}
Loading