From 8f17bf6a8c879a514a2029c4c8c65fce141f6aac Mon Sep 17 00:00:00 2001 From: Zeni Kim Date: Tue, 8 Oct 2024 07:58:42 -0500 Subject: [PATCH] add form components --- template/components/form_checkbox.go | 14 ++++++++++++++ template/components/form_checkbox.html | 11 +++++++++++ template/components/form_radio.go | 15 +++++++++++++++ template/components/form_radio.html | 11 +++++++++++ template/components/form_select.go | 13 +++++++++++++ template/components/form_select.html | 10 ++++++++++ template/components/form_textarea.go | 7 +++++++ template/components/form_textarea.html | 6 ++++++ 8 files changed, 87 insertions(+) create mode 100644 template/components/form_checkbox.go create mode 100644 template/components/form_checkbox.html create mode 100644 template/components/form_radio.go create mode 100644 template/components/form_radio.html create mode 100644 template/components/form_select.go create mode 100644 template/components/form_select.html create mode 100644 template/components/form_textarea.go create mode 100644 template/components/form_textarea.html diff --git a/template/components/form_checkbox.go b/template/components/form_checkbox.go new file mode 100644 index 0000000..819da82 --- /dev/null +++ b/template/components/form_checkbox.go @@ -0,0 +1,14 @@ +package components + +type FormCheckbox struct { + Label string + AllCheckbox []FormCheckboxItem +} + +type FormCheckboxItem struct { + ID string + Name string + Value string + Label string + IsChecked bool +} diff --git a/template/components/form_checkbox.html b/template/components/form_checkbox.html new file mode 100644 index 0000000..9a8d845 --- /dev/null +++ b/template/components/form_checkbox.html @@ -0,0 +1,11 @@ +{{define "form_checkbox"}} +
+ + {{range $options := .AllCheckbox}} +
+ + +
+ {{end}} +
+{{end}} \ No newline at end of file diff --git a/template/components/form_radio.go b/template/components/form_radio.go new file mode 100644 index 0000000..e8e923c --- /dev/null +++ b/template/components/form_radio.go @@ -0,0 +1,15 @@ +package components + +type FormRadio struct { + Label string + AllRadios []FormRadioItem +} + +type FormRadioItem struct { + ID string + Name string + Value string + Label string + IsDisabled bool + IsChecked bool +} diff --git a/template/components/form_radio.html b/template/components/form_radio.html new file mode 100644 index 0000000..a0c26cd --- /dev/null +++ b/template/components/form_radio.html @@ -0,0 +1,11 @@ +{{define "form_radio"}} +
+ + {{range $options := .AllRadios}} +
+ + +
+ {{end}} +
+{{end}} \ No newline at end of file diff --git a/template/components/form_select.go b/template/components/form_select.go new file mode 100644 index 0000000..db94fe3 --- /dev/null +++ b/template/components/form_select.go @@ -0,0 +1,13 @@ +package components + +type FormSelect struct { + ID string + SelectedOption FormSelectOption + Label string + AllOptions []FormSelectOption +} + +type FormSelectOption struct { + Value string + Caption string +} diff --git a/template/components/form_select.html b/template/components/form_select.html new file mode 100644 index 0000000..6317e6b --- /dev/null +++ b/template/components/form_select.html @@ -0,0 +1,10 @@ +{{define "form_select"}} +
+ + +
+{{end}} \ No newline at end of file diff --git a/template/components/form_textarea.go b/template/components/form_textarea.go new file mode 100644 index 0000000..8fbaf51 --- /dev/null +++ b/template/components/form_textarea.go @@ -0,0 +1,7 @@ +package components + +type FormTextarea struct { + ID string + Label string + AllOptions []FormSelectOption +} diff --git a/template/components/form_textarea.html b/template/components/form_textarea.html new file mode 100644 index 0000000..5372a42 --- /dev/null +++ b/template/components/form_textarea.html @@ -0,0 +1,6 @@ +{{define "form_textarea"}} +
+ + +
+{{end}} \ No newline at end of file