diff --git a/assets/asset-corporate-portal/css/sas.bundle.css b/assets/asset-corporate-portal/css/sas.bundle.css index 138b79f..5c2272c 100644 --- a/assets/asset-corporate-portal/css/sas.bundle.css +++ b/assets/asset-corporate-portal/css/sas.bundle.css @@ -5200,6 +5200,11 @@ a.text-hover-tosca:hover .svg-icon svg:hover g [fill], height: auto; } +/* ### TOAST FONT SIZE */ +.toast { + font-size: 1.1rem; +} + /* ### OVERLAY */ .overlay-loading { position: relative !important; diff --git a/component/toastbootstrap/customtoastv2.templ b/component/toastbootstrap/customtoastv2.templ new file mode 100644 index 0000000..63db879 --- /dev/null +++ b/component/toastbootstrap/customtoastv2.templ @@ -0,0 +1,86 @@ +package customtoastv1 + +// kalau eror => bg nya danger +// kalau sukses => bgnya success +// kalau warning => bgnya warning + +func toastBackground(typeToast string) string { + return "bg-" + typeToast +} + +func toastBody(typeToastBody string) string { + return "bg-" + typeToastBody + "-transparent" +} + +func toastIcon(typeToast string) string { + var stringx string + if typeToast == "success" { + stringx = "solar:check-circle-broken" + } else { + if typeToast == "danger" { + stringx = "solar:close-circle-broken" + } else { + if typeToast == "warning" { + stringx = "solar:shield-warning-bold" + } else { + if typeToast == "information" { + stringx = "solar:info-square-broken" + } + } + } + } + + return stringx +} + +templ CustomToastV2Show(title string, message string, typeToast string) { + +} + +templ CustomToastV2Hide() { + +} diff --git a/component/toastbootstrap/customtoastv2_templ.go b/component/toastbootstrap/customtoastv2_templ.go new file mode 100644 index 0000000..ca03e98 --- /dev/null +++ b/component/toastbootstrap/customtoastv2_templ.go @@ -0,0 +1,175 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package customtoastv1 + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +// kalau eror => bg nya danger +// kalau sukses => bgnya success +// kalau warning => bgnya warning + +func toastBackground(typeToast string) string { + return "bg-" + typeToast +} + +func toastBody(typeToastBody string) string { + return "bg-" + typeToastBody + "-transparent" +} + +func toastIcon(typeToast string) string { + var stringx string + if typeToast == "success" { + stringx = "solar:check-circle-broken" + } else { + if typeToast == "danger" { + stringx = "solar:close-circle-broken" + } else { + if typeToast == "warning" { + stringx = "solar:shield-warning-bold" + } else { + if typeToast == "information" { + stringx = "solar:info-square-broken" + } + } + } + } + + return stringx +} + +func CustomToastV2Show(title string, message string, typeToast string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 = []any{"toast-header", toastBackground(typeToast), "text-white"} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\toastbootstrap\customtoastv2.templ`, Line: 54, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var6 = []any{"toast-body", toastBody(typeToast)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(message) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\toastbootstrap\customtoastv2.templ`, Line: 60, Col: 12} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func CustomToastV2Hide() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Success just now
This is a success toast.\r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} diff --git a/handlers/dev/mastermenuusergroup.handlers.go b/handlers/dev/mastermenuusergroup.handlers.go index 061cdf0..9870d58 100644 --- a/handlers/dev/mastermenuusergroup.handlers.go +++ b/handlers/dev/mastermenuusergroup.handlers.go @@ -25,6 +25,7 @@ import ( customtextfieldsearch "cpone/component/customtextfieldsearch" navbarmenu "cpone/component/navbar" sidebaruserprofile "cpone/component/sidebar_user_profile" + customtoastv2 "cpone/component/toastbootstrap" ) type MasterMenuUserGroupService interface { @@ -608,3 +609,11 @@ func (lh *MasterMenuUserGroupHandler) HandlerShowMasterMenuUserGroupTryAndy(c ec return utils.View(c, si) } + +func (lh *MasterMenuUserGroupHandler) HandlerHideToast(c echo.Context) error { + toastComponent := customtoastv2.CustomToastV2Hide() + + si := toastComponent + + return utils.View(c, si) +} diff --git a/handlers/public/tools.handler.go b/handlers/public/tools.handler.go new file mode 100644 index 0000000..1633f9c --- /dev/null +++ b/handlers/public/tools.handler.go @@ -0,0 +1,73 @@ +package public_handlers + +import ( + "cpone/models" + "cpone/utils" + "cpone/views/dev/mastermenuusergroup" + + tablecomponent "cpone/component/table" + + public_toast "cpone/views/public/toast" + + "github.com/labstack/echo/v4" +) + +type ToolsService interface { +} + +func NewToolsHandler(us ToolsService) *ToolsHandler { + return &ToolsHandler{ + ToolsService: us, + } +} + +type ToolsHandler struct { + ToolsService ToolsService +} + +func (lh *ToolsHandler) HandlerHideToast(c echo.Context) error { + toastComponent := public_toast.PublicToastV1Hide() + + si := toastComponent + + return utils.View(c, si) +} + +func (lh *ToolsHandler) HandlerShowToast(c echo.Context) error { + + inputansearchComponent := tablecomponent.DivEmpty() + // toastComponent := public_toast.PublicToastV1Show("Success", "Success Loaded", "success") + pagination := tablecomponent.DivEmpty() + + dummyData := []models.UserGroupV1{ + { + Nomor: "1", + M_UserGroupID: 1, + M_UserGroupCode: "group1", + M_UserGroupName: "Group 1", + M_UserGroupCreated: "2024-05-16", + M_UserGroupLastUpdated: "2024-05-16", + M_UserGroupIsActive: "Active", + }, + } + + tabelusergroupComponent := tablecomponent.TableV2( + []string{"KODE", "USERGROUP", "AKSI"}, + []string{"40%", "40%", "20%"}, + mastermenuusergroup.TableRowV1(dummyData), + pagination, + "", + inputansearchComponent, + ) + + si := public_toast.ShowToast("", + tabelusergroupComponent, + tabelusergroupComponent, + tabelusergroupComponent, + tabelusergroupComponent, + tabelusergroupComponent, + tabelusergroupComponent, + ) + + return utils.View(c, si) +} diff --git a/handlers/routes.go b/handlers/routes.go index 5f25680..b90e9ce 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -202,6 +202,8 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) { //ugcobanady dev.GET("/usergrouptryandy", devUGhandlers.HandlerShowMasterMenuUserGroupTryAndy) + dev.GET("/hidetoast", devUGhandlers.HandlerHideToast) + // clientgroup.GET("/usergroup/edit", mastermenuusergroupHandler.ChangeFormEdit) // clientgroup.GET("/usergroup/pagination", mastermenuusergroupHandler.HandleChangePage) } diff --git a/layout/layout_corporate.templ b/layout/layout_corporate.templ index 36e969b..364a6de 100644 --- a/layout/layout_corporate.templ +++ b/layout/layout_corporate.templ @@ -1,7 +1,7 @@ package layout // LAYOUT PLAYGROUND -templ CorporateLayout(title string, css templ.Component, js templ.Component, navbarmenu templ.Component, +templ CorporateLayout(title string, css templ.Component, js templ.Component, navbarmenu templ.Component, navbaruser templ.Component, sidebaruserprofile templ.Component) {
+ // toast +
+ + +
+ // end toast { children... }
diff --git a/layout/layout_corporate_templ.go b/layout/layout_corporate_templ.go index fffd952..c051324 100644 --- a/layout/layout_corporate_templ.go +++ b/layout/layout_corporate_templ.go @@ -62,7 +62,7 @@ func CorporateLayout(title string, css templ.Component, js templ.Component, navb if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Success just now
This is a success toast.\r
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/public/toast/toastpublicv1.templ b/views/public/toast/toastpublicv1.templ new file mode 100644 index 0000000..ff5e872 --- /dev/null +++ b/views/public/toast/toastpublicv1.templ @@ -0,0 +1,100 @@ +package public_toast + +import ( + "cpone/layout" +) + +// kalau eror => bg nya danger +// kalau sukses => bgnya success +// kalau warning => bgnya warning + +func toastBackground(typeToast string) string { + return "bg-" + typeToast +} + +func toastBody(typeToastBody string) string { + return "bg-" + typeToastBody + "-transparent" +} + +func toastIcon(typeToast string) string { + var stringx string + if typeToast == "success" { + stringx = "solar:check-circle-broken" + } else { + if typeToast == "danger" { + stringx = "solar:close-circle-broken" + } else { + if typeToast == "warning" { + stringx = "solar:shield-warning-bold" + } else { + if typeToast == "information" { + stringx = "solar:info-square-broken" + } + } + } + } + + return stringx +} + +templ PublicToastV1Show(title string, message string, typeToast string) { + +} + +templ PublicToastV1Hide() { + +} + +templ ShowToast(title string, cmp templ.Component, css templ.Component, js templ.Component, + navbarmenu templ.Component, + navbaruser templ.Component, + userprofile templ.Component) { + @layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile) { + @cmp + } +} diff --git a/views/public/toast/toastpublicv1_templ.go b/views/public/toast/toastpublicv1_templ.go new file mode 100644 index 0000000..62252dc --- /dev/null +++ b/views/public/toast/toastpublicv1_templ.go @@ -0,0 +1,221 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package public_toast + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import ( + "cpone/layout" +) + +// kalau eror => bg nya danger +// kalau sukses => bgnya success +// kalau warning => bgnya warning + +func toastBackground(typeToast string) string { + return "bg-" + typeToast +} + +func toastBody(typeToastBody string) string { + return "bg-" + typeToastBody + "-transparent" +} + +func toastIcon(typeToast string) string { + var stringx string + if typeToast == "success" { + stringx = "solar:check-circle-broken" + } else { + if typeToast == "danger" { + stringx = "solar:close-circle-broken" + } else { + if typeToast == "warning" { + stringx = "solar:shield-warning-bold" + } else { + if typeToast == "information" { + stringx = "solar:info-square-broken" + } + } + } + } + + return stringx +} + +func PublicToastV1Show(title string, message string, typeToast string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 = []any{"toast-header", toastBackground(typeToast), "text-white"} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\toast\toastpublicv1.templ`, Line: 58, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var6 = []any{"toast-body", toastBody(typeToast)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(message) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\toast\toastpublicv1.templ`, Line: 64, Col: 12} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func PublicToastV1Hide() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Success just now
This is a success toast.\r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ShowToast(title string, cmp templ.Component, css templ.Component, js templ.Component, + navbarmenu templ.Component, + navbaruser templ.Component, + userprofile templ.Component) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var11 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}