lazy.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package vuetify
  2. import (
  3. "context"
  4. "fmt"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VLazyBuilder struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VLazy(children ...h.HTMLComponent) (r *VLazyBuilder) {
  11. r = &VLazyBuilder{
  12. tag: h.Tag("v-lazy").Children(children...),
  13. }
  14. return
  15. }
  16. func (b *VLazyBuilder) Height(v int) (r *VLazyBuilder) {
  17. b.tag.Attr(":height", fmt.Sprint(v))
  18. return b
  19. }
  20. func (b *VLazyBuilder) MaxHeight(v int) (r *VLazyBuilder) {
  21. b.tag.Attr(":max-height", fmt.Sprint(v))
  22. return b
  23. }
  24. func (b *VLazyBuilder) MaxWidth(v int) (r *VLazyBuilder) {
  25. b.tag.Attr(":max-width", fmt.Sprint(v))
  26. return b
  27. }
  28. func (b *VLazyBuilder) MinHeight(v int) (r *VLazyBuilder) {
  29. b.tag.Attr(":min-height", fmt.Sprint(v))
  30. return b
  31. }
  32. func (b *VLazyBuilder) MinWidth(v int) (r *VLazyBuilder) {
  33. b.tag.Attr(":min-width", fmt.Sprint(v))
  34. return b
  35. }
  36. func (b *VLazyBuilder) Options(v interface{}) (r *VLazyBuilder) {
  37. b.tag.Attr(":options", h.JSONString(v))
  38. return b
  39. }
  40. func (b *VLazyBuilder) Tag(v string) (r *VLazyBuilder) {
  41. b.tag.Attr("tag", v)
  42. return b
  43. }
  44. func (b *VLazyBuilder) Transition(v string) (r *VLazyBuilder) {
  45. b.tag.Attr("transition", v)
  46. return b
  47. }
  48. func (b *VLazyBuilder) Value(v interface{}) (r *VLazyBuilder) {
  49. b.tag.Attr(":value", h.JSONString(v))
  50. return b
  51. }
  52. func (b *VLazyBuilder) Width(v int) (r *VLazyBuilder) {
  53. b.tag.Attr(":width", fmt.Sprint(v))
  54. return b
  55. }
  56. func (b *VLazyBuilder) SetAttr(k string, v interface{}) {
  57. b.tag.SetAttr(k, v)
  58. }
  59. func (b *VLazyBuilder) Attr(vs ...interface{}) (r *VLazyBuilder) {
  60. b.tag.Attr(vs...)
  61. return b
  62. }
  63. func (b *VLazyBuilder) Children(children ...h.HTMLComponent) (r *VLazyBuilder) {
  64. b.tag.Children(children...)
  65. return b
  66. }
  67. func (b *VLazyBuilder) AppendChildren(children ...h.HTMLComponent) (r *VLazyBuilder) {
  68. b.tag.AppendChildren(children...)
  69. return b
  70. }
  71. func (b *VLazyBuilder) PrependChildren(children ...h.HTMLComponent) (r *VLazyBuilder) {
  72. b.tag.PrependChildren(children...)
  73. return b
  74. }
  75. func (b *VLazyBuilder) Class(names ...string) (r *VLazyBuilder) {
  76. b.tag.Class(names...)
  77. return b
  78. }
  79. func (b *VLazyBuilder) ClassIf(name string, add bool) (r *VLazyBuilder) {
  80. b.tag.ClassIf(name, add)
  81. return b
  82. }
  83. func (b *VLazyBuilder) On(name string, value string) (r *VLazyBuilder) {
  84. b.tag.Attr(fmt.Sprintf("v-on:%s", name), value)
  85. return b
  86. }
  87. func (b *VLazyBuilder) Bind(name string, value string) (r *VLazyBuilder) {
  88. b.tag.Attr(fmt.Sprintf("v-bind:%s", name), value)
  89. return b
  90. }
  91. func (b *VLazyBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  92. return b.tag.MarshalHTML(ctx)
  93. }