Skip to content

Commit

Permalink
Refactor component enums and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardolat committed Aug 11, 2024
1 parent 8062c7c commit dde7dce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 223 deletions.
17 changes: 0 additions & 17 deletions internal/web/component/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@ package component

import "github.com/orsinium-labs/enum"

type color enum.Member[string]
type size enum.Member[string]
type buttonType enum.Member[string]
type inputType enum.Member[string]

var (
ColorBlack = color{"black"}
ColorRed = color{"red"}

SizeSm = size{"sm"}
SizeMd = size{"md"}
SizeLg = size{"lg"}

ButtonTypeSubmit = buttonType{"submit"}
ButtonTypeButton = buttonType{"button"}
ButtonTypeReset = buttonType{"reset"}

InputTypeText = inputType{"text"}
InputTypePassword = inputType{"password"}
InputTypeEmail = inputType{"email"}
InputTypeNumber = inputType{"number"}
InputTypeTel = inputType{"tel"}
InputTypeUrl = inputType{"url"}
)
26 changes: 1 addition & 25 deletions internal/web/component/hx_loading.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ func HxLoadingLg(centered bool, id ...string) gomponents.Node {
}

func hxLoading(centered bool, size size, id ...string) gomponents.Node {
style := func() string {
styleSm := "width: 15px; height: 15px;"
styleMd := "width: 25px; height: 25px;"
styleLg := "width: 40px; height: 40px;"

switch size {
case SizeSm:
return styleSm
case SizeMd:
return styleMd
case SizeLg:
return styleLg
default:
return styleMd
}
}()

pickedID := ""
if len(id) > 0 {
Expand All @@ -55,15 +39,7 @@ func hxLoading(centered bool, size size, id ...string) gomponents.Node {
"flex justify-center items-center": centered,
"w-full h-full": true,
},
html.Div(
html.Style(style),
gcomponents.Classes{
"border-black border-t-transparent animate-spin rounded-full": true,
"border-[2px]": size == SizeSm,
"border-[3px]": size == SizeMd,
"border-[5px]": size == SizeLg,
},
),
spinner(size),
),
)
}
72 changes: 0 additions & 72 deletions internal/web/component/input.go

This file was deleted.

96 changes: 0 additions & 96 deletions internal/web/component/input_control.go

This file was deleted.

23 changes: 10 additions & 13 deletions internal/web/page/index_editor_icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@ func indexEditorIconPicker() gomponents.Node {
html.Div(
html.Class("space-y-4 h-full"),

component.Input(component.InputParams{
Name: "q",
Type: component.InputTypeText,
Color: component.ColorBlack,
Placeholder: "Search for an icon",
Block: true,
Children: []gomponents.Node{
htmx.HxGet("/icons"),
htmx.HxTrigger("input changed delay:500ms, search"),
htmx.HxTarget("#icon-picker-results"),
htmx.HxIndicator("#icon-picker-indicator"),
},
}),
html.Input(
html.Class("input input-bordered w-full"),
html.Type("text"),
html.Name("q"),
html.Placeholder("Search for an icon"),
htmx.HxGet("/icons"),
htmx.HxTrigger("input changed delay:500ms, search"),
htmx.HxTarget("#icon-picker-results"),
htmx.HxIndicator("#icon-picker-indicator"),
),

html.Div(
html.ID("icon-picker-results"),
Expand Down

0 comments on commit dde7dce

Please sign in to comment.