initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package ui
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
type InputField struct {
|
||||
ID string
|
||||
Legend string
|
||||
Type string
|
||||
Placeholder string
|
||||
Name string
|
||||
Value string
|
||||
Endpoint string
|
||||
Trigger string
|
||||
Hint string
|
||||
InputClass string
|
||||
}
|
||||
|
||||
func NewInputField(id, name, legend, placeholder, endpoint string) InputField {
|
||||
return InputField{
|
||||
ID: id,
|
||||
Legend: legend,
|
||||
Type: "text",
|
||||
Placeholder: placeholder,
|
||||
Name: name,
|
||||
Value: "",
|
||||
Endpoint: endpoint,
|
||||
Trigger: "blur",
|
||||
Hint: "",
|
||||
InputClass: "",
|
||||
}
|
||||
}
|
||||
|
||||
func (f InputField) ToMap() fiber.Map {
|
||||
return fiber.Map{
|
||||
"ID": f.ID,
|
||||
"Legend": f.Legend,
|
||||
"Type": f.Type,
|
||||
"Placeholder": f.Placeholder,
|
||||
"Name": f.Name,
|
||||
"Value": f.Value,
|
||||
"Endpoint": f.Endpoint,
|
||||
"Trigger": f.Trigger,
|
||||
"Hint": f.Hint,
|
||||
"InputClass": f.InputClass,
|
||||
}
|
||||
}
|
||||
|
||||
func (f InputField) WithValue(value string) InputField {
|
||||
f.Value = value
|
||||
return f
|
||||
}
|
||||
|
||||
func (f InputField) WithError(hint string) InputField {
|
||||
f.Hint = hint
|
||||
f.InputClass = "input-error text-error"
|
||||
return f
|
||||
}
|
||||
|
||||
func (f InputField) WithType(inputType string) InputField {
|
||||
f.Type = inputType
|
||||
return f
|
||||
}
|
||||
|
||||
func (f InputField) WithTrigger(trigger string) InputField {
|
||||
f.Trigger = trigger
|
||||
return f
|
||||
}
|
||||
Reference in New Issue
Block a user