66 "strconv"
77
88 "github.com/mgnsk/calendar/contract"
9+ "github.com/mgnsk/calendar/html/components"
910 . "maragu.dev/gomponents"
1011 . "maragu.dev/gomponents/html"
1112)
@@ -17,7 +18,8 @@ func EditEventMain(form contract.EditEventForm, errs url.Values, csrf string) No
1718 Form (ID ("edit-form" ), Class ("w-full px-3 py-4 mx-auto" ),
1819 Method ("POST" ),
1920
20- H1 (baseFormElementClasses (),
21+ // TODO: refactor this usage of classes
22+ H1 (components .BaseFormElementClasses (),
2123 Text ("Status: " ),
2224 B (Text (func () string {
2325 if form .IsDraft || form .EventID == 0 {
@@ -27,20 +29,20 @@ func EditEventMain(form contract.EditEventForm, errs url.Values, csrf string) No
2729 }())),
2830 ),
2931
30- input ("title" , "text" , "Title" , form .Title , errs .Get ("title" ), true , false ),
31- input ("url" , "url" , "URL" , form .URL , errs .Get ("url" ), false , false ),
32- dateTimeLocalInput ("start_at" , form .StartAt , errs .Get ("start_at" ), true , false ),
32+ components . InputElement ("title" , "text" , "Title" , form .Title , errs .Get ("title" ), true , false ),
33+ components . InputElement ("url" , "url" , "URL" , form .URL , errs .Get ("url" ), false , false ),
34+ components . DateTimeLocalInput ("start_at" , form .StartAt , errs .Get ("start_at" ), true , false ),
3335
3436 Div (Class ("relative" ),
35- input ("location" , "text" , "Location" , form .Location , errs .Get ("location" ), true , false ),
37+ components . InputElement ("location" , "text" , "Location" , form .Location , errs .Get ("location" ), true , false ),
3638 Input (Type ("hidden" ), Name ("osm_type" ), Value (form .OSMType )),
3739 Input (Type ("hidden" ), Name ("osm_id" ), Value (strconv .FormatUint (form .OSMID , 10 ))),
3840 Div (ID ("location-spinner" ), Class ("opacity-0 absolute top-0 right-0 h-full flex items-center mr-2" ),
39- spinner (2 ),
41+ components . Spinner (2 ),
4042 ),
4143 ),
4244
43- textarea ("desc" , form .Description , errs .Get ("desc" ), true , false ),
45+ components . TextareaElement ("desc" , form .Description , errs .Get ("desc" ), 3 , true , false ),
4446
4547 Input (Type ("hidden" ), Name ("csrf" ), Value (csrf )),
4648 Input (Type ("hidden" ), Name ("easymde_cache_key" ), Value (form .EventID .String ())),
@@ -54,14 +56,10 @@ func EditEventMain(form contract.EditEventForm, errs url.Values, csrf string) No
5456 // Draft or new event.
5557 Iff (form .IsDraftOrNew (), func () Node {
5658 return Group {
57- Button (buttonClasses (),
58- Type ("submit" ),
59- Text ("Save Draft" ),
59+ components .SubmitButtonElement ("Save Draft" ,
6060 FormAction (fmt .Sprintf ("/edit/%s?draft=1" , form .EventID .String ())),
6161 ),
62- Button (buttonClasses (),
63- Type ("submit" ),
64- Text ("Publish" ),
62+ components .SubmitButtonElement ("Publish" ,
6563 Attr ("onclick" , "return confirm('Confirm publishing this event')" ),
6664 FormAction (fmt .Sprintf ("/edit/%s?draft=0" , form .EventID .String ())),
6765 ),
@@ -71,14 +69,10 @@ func EditEventMain(form contract.EditEventForm, errs url.Values, csrf string) No
7169 // Already published event.
7270 Iff (! form .IsDraftOrNew (), func () Node {
7371 return Group {
74- Button (buttonClasses (),
75- Type ("submit" ),
76- Text ("Save" ),
72+ components .SubmitButtonElement ("Save" ,
7773 FormAction (fmt .Sprintf ("/edit/%s?draft=0" , form .EventID .String ())),
7874 ),
79- Button (buttonClasses (),
80- Type ("submit" ),
81- Text ("Unpublish" ),
75+ components .SubmitButtonElement ("Unpublish" ,
8276 Attr ("onclick" , "return confirm('Confirm unpublishing this event')" ),
8377 FormAction (fmt .Sprintf ("/edit/%s?draft=1" , form .EventID .String ())),
8478 ),
0 commit comments