portal.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package web
  2. import (
  3. "context"
  4. h "github.com/theplant/htmlgo"
  5. )
  6. type PortalBuilder struct {
  7. tag *h.HTMLTagBuilder
  8. }
  9. func Portal(children ...h.HTMLComponent) (r *PortalBuilder) {
  10. r = &PortalBuilder{
  11. tag: h.Tag("go-plaid-portal").Children(children...),
  12. }
  13. r.Visible("true").Form("plaidForm")
  14. return
  15. }
  16. func (b *PortalBuilder) Loader(v *VueEventTagBuilder) (r *PortalBuilder) {
  17. b.tag.SetAttr(":loader", v.String())
  18. return b
  19. }
  20. func (b *PortalBuilder) Visible(v string) (r *PortalBuilder) {
  21. b.tag.Attr(":visible", v)
  22. return b
  23. }
  24. func (b *PortalBuilder) Name(v string) (r *PortalBuilder) {
  25. b.tag.Attr("portal-name", v)
  26. return b
  27. }
  28. func (b *PortalBuilder) Form(v string) (r *PortalBuilder) {
  29. b.tag.Attr(":portal-form", v)
  30. return b
  31. }
  32. func (b *PortalBuilder) AutoReloadInterval(v interface{}) (r *PortalBuilder) {
  33. b.tag.Attr(":auto-reload-interval", v)
  34. return b
  35. }
  36. func (b *PortalBuilder) Children(comps ...h.HTMLComponent) (r *PortalBuilder) {
  37. b.tag.Children(comps...)
  38. return b
  39. }
  40. func (b *PortalBuilder) LoadWhenParentVisible() (r *PortalBuilder) {
  41. b.Visible("parent.isVisible")
  42. return b
  43. }
  44. func (b *PortalBuilder) ParentForceUpdateAfterLoaded() (r *PortalBuilder) {
  45. b.tag.Attr(":after-loaded", "parent.forceUpdate")
  46. return b
  47. }
  48. func (b *PortalBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  49. return b.tag.MarshalHTML(ctx)
  50. }