package components import ( "fmt" "tankstopp/internal/currency" "tankstopp/internal/models" ) templ FormGroup(label, hint string) {
if label != "" { } { children... } if hint != "" {
{ hint }
}
} templ Input(name, inputType, placeholder, value string, required bool) { } templ NumberInput(name, placeholder string, value float64, step string, min float64, required bool) { } templ DateInput(name, value string, required bool) { } templ TextArea(name, placeholder, value string, rows int) { } templ Select(name string, required bool) { } templ Option(value, text string, selected bool) { } templ CurrencySelect(name, selectedCurrency string, currencies []currency.Currency) { @Select(name, false) { @Option("", "Select currency...", selectedCurrency == "") for _, curr := range currencies { @Option(curr.Code, fmt.Sprintf("%s %s - %s", curr.Symbol, curr.Code, curr.Name), curr.Code == selectedCurrency) } } } templ VehicleSelect(name string, selectedVehicleID uint, vehicles []models.Vehicle, required bool) { @Select(name, required) { @Option("", "Select vehicle...", selectedVehicleID == 0) for _, vehicle := range vehicles { if vehicle.LicensePlate != "" { @Option(fmt.Sprintf("%d", vehicle.ID), fmt.Sprintf("%s (%s)", vehicle.Name, vehicle.LicensePlate), vehicle.ID == selectedVehicleID) } else { @Option(fmt.Sprintf("%d", vehicle.ID), vehicle.Name, vehicle.ID == selectedVehicleID) } } } } templ FuelTypeSelect(name, selectedFuelType string, required bool) { @Select(name, required) { @Option("", "Select fuel type...", selectedFuelType == "") @Option("Super E5", "Super E5", selectedFuelType == "Super E5") @Option("Super E10", "Super E10", selectedFuelType == "Super E10") @Option("Super Plus", "Super Plus", selectedFuelType == "Super Plus") @Option("Diesel", "Diesel", selectedFuelType == "Diesel") @Option("Premium Diesel", "Premium Diesel", selectedFuelType == "Premium Diesel") @Option("LPG", "LPG", selectedFuelType == "LPG") @Option("CNG", "CNG", selectedFuelType == "CNG") @Option("Electric", "Electric", selectedFuelType == "Electric") @Option("Hybrid", "Hybrid (Mixed)", selectedFuelType == "Hybrid") } } templ InputGroup(prefix, suffix string) {
if prefix != "" { { prefix } } { children... } if suffix != "" { { suffix } }
} templ PasswordInput(name, placeholder string, required bool) {
@Icon("eye", 24)
} templ Switch(name, label string, checked bool) { } templ FormButtons(cancelHref, submitText, submitIcon string) { } templ Form(method, action string) {
{ children... }
} templ FormRow() {
{ children... }
} templ FormCol(size string) {
{ children... }
} templ DeleteButton(action, itemName string) {
} templ EditButton(href string) { @Icon("edit", 24) Edit } templ ButtonGroup() {
{ children... }
} templ PrimaryButton(text string, icon string) { } templ SecondaryButton(href, text string, icon string) { if icon != "" { @Icon(icon, 24) } { text } } templ InputWithIcon(name, inputType, placeholder, value string, icon string, required bool) { @FormGroup("", "") { if icon != "" { @Icon(icon, 24) } @Input(name, inputType, placeholder, value, required) } } templ CurrencyInputGroup(name string, value float64, currencySymbol string, step string) { @InputGroup(currencySymbol, "") { } } templ RefreshButton() { }