package containers import ( "fmt" "strings" "github.com/qor5/admin/media/media_library" "github.com/qor5/admin/presets" v "github.com/qor5/ui/vuetify" "github.com/qor5/web" . "github.com/theplant/htmlgo" ) const ( Blue = "blue" Orange = "orange" White = "white" Grey = "grey" ) var BackgroundColors = []string{White, Grey, Blue} var FontColors = []string{Blue, Orange, White} const LINK_ARROW_SVG = RawHTML(` `) var TextArea = func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) HTMLComponent { return v.VTextarea().FieldName(field.Name).Label(field.Label).Value(field.Value(obj)) } func ContainerWrapper(containerID, anchorID, classes, backgroundColor, transitionBackgroundColor, fontColor, imagePosition string, addTopSpace, addBottomSpace bool, isEditor bool, isReadonly bool, style string, comp ...HTMLComponent) HTMLComponent { r := Div(comp...). Id(anchorID). Class("container-instance").ClassIf(classes, classes != ""). AttrIf("data-background-color", backgroundColor, backgroundColor != ""). AttrIf("data-transition-background-color", transitionBackgroundColor, transitionBackgroundColor != ""). AttrIf("data-font-color", fontColor, fontColor != ""). AttrIf("data-image-position", imagePosition, imagePosition != ""). AttrIf("data-container-top-space", "true", addTopSpace). AttrIf("data-container-bottom-space", "true", addBottomSpace). Attr("data-container-id", containerID).Style("position:relative;").StyleIf(style, style != "") if isEditor { if isReadonly { r.AppendChildren(RawHTML(`
`)) } else { r.AppendChildren(RawHTML(fmt.Sprintf(`
`, containerID))) } } return r } func LinkTextWithArrow(text, link string, class ...string) HTMLComponent { if text == "" || link == "" { return nil } c := "link-arrow" if len(class) > 0 { class = append(class, c) c = strings.Join(class, " ") } return A(Span(text), LINK_ARROW_SVG).Class(c).Href(link) } func LazyImageHtml(m media_library.MediaBox, class ...string) HTMLComponent { class = append(class, "lazyload") return Img("").Attr("data-src", m.URL()).Alt(m.Description).Class(class...) } func ImageHtml(m media_library.MediaBox, class ...string) HTMLComponent { return Img("").Attr("src", m.URL()).Alt(m.Description).Class(class...) }