badge.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. package vuetify
  2. import (
  3. "context"
  4. "fmt"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VBadgeBuilder struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VBadge(children ...h.HTMLComponent) (r *VBadgeBuilder) {
  11. r = &VBadgeBuilder{
  12. tag: h.Tag("v-badge").Children(children...),
  13. }
  14. return
  15. }
  16. func (b *VBadgeBuilder) Avatar(v bool) (r *VBadgeBuilder) {
  17. b.tag.Attr(":avatar", fmt.Sprint(v))
  18. return b
  19. }
  20. func (b *VBadgeBuilder) Bordered(v bool) (r *VBadgeBuilder) {
  21. b.tag.Attr(":bordered", fmt.Sprint(v))
  22. return b
  23. }
  24. func (b *VBadgeBuilder) Bottom(v bool) (r *VBadgeBuilder) {
  25. b.tag.Attr(":bottom", fmt.Sprint(v))
  26. return b
  27. }
  28. func (b *VBadgeBuilder) Color(v string) (r *VBadgeBuilder) {
  29. b.tag.Attr("color", v)
  30. return b
  31. }
  32. func (b *VBadgeBuilder) Content(v interface{}) (r *VBadgeBuilder) {
  33. b.tag.Attr(":content", h.JSONString(v))
  34. return b
  35. }
  36. func (b *VBadgeBuilder) Dark(v bool) (r *VBadgeBuilder) {
  37. b.tag.Attr(":dark", fmt.Sprint(v))
  38. return b
  39. }
  40. func (b *VBadgeBuilder) Dot(v bool) (r *VBadgeBuilder) {
  41. b.tag.Attr(":dot", fmt.Sprint(v))
  42. return b
  43. }
  44. func (b *VBadgeBuilder) Icon(v string) (r *VBadgeBuilder) {
  45. b.tag.Attr("icon", v)
  46. return b
  47. }
  48. func (b *VBadgeBuilder) Inline(v bool) (r *VBadgeBuilder) {
  49. b.tag.Attr(":inline", fmt.Sprint(v))
  50. return b
  51. }
  52. func (b *VBadgeBuilder) Label(v string) (r *VBadgeBuilder) {
  53. b.tag.Attr("label", v)
  54. return b
  55. }
  56. func (b *VBadgeBuilder) Left(v bool) (r *VBadgeBuilder) {
  57. b.tag.Attr(":left", fmt.Sprint(v))
  58. return b
  59. }
  60. func (b *VBadgeBuilder) Light(v bool) (r *VBadgeBuilder) {
  61. b.tag.Attr(":light", fmt.Sprint(v))
  62. return b
  63. }
  64. func (b *VBadgeBuilder) Mode(v string) (r *VBadgeBuilder) {
  65. b.tag.Attr("mode", v)
  66. return b
  67. }
  68. func (b *VBadgeBuilder) OffsetX(v int) (r *VBadgeBuilder) {
  69. b.tag.Attr(":offset-x", fmt.Sprint(v))
  70. return b
  71. }
  72. func (b *VBadgeBuilder) OffsetY(v int) (r *VBadgeBuilder) {
  73. b.tag.Attr(":offset-y", fmt.Sprint(v))
  74. return b
  75. }
  76. func (b *VBadgeBuilder) Origin(v string) (r *VBadgeBuilder) {
  77. b.tag.Attr("origin", v)
  78. return b
  79. }
  80. func (b *VBadgeBuilder) Overlap(v bool) (r *VBadgeBuilder) {
  81. b.tag.Attr(":overlap", fmt.Sprint(v))
  82. return b
  83. }
  84. func (b *VBadgeBuilder) Tile(v bool) (r *VBadgeBuilder) {
  85. b.tag.Attr(":tile", fmt.Sprint(v))
  86. return b
  87. }
  88. func (b *VBadgeBuilder) Transition(v string) (r *VBadgeBuilder) {
  89. b.tag.Attr("transition", v)
  90. return b
  91. }
  92. func (b *VBadgeBuilder) Value(v interface{}) (r *VBadgeBuilder) {
  93. b.tag.Attr(":value", h.JSONString(v))
  94. return b
  95. }
  96. func (b *VBadgeBuilder) SetAttr(k string, v interface{}) {
  97. b.tag.SetAttr(k, v)
  98. }
  99. func (b *VBadgeBuilder) Attr(vs ...interface{}) (r *VBadgeBuilder) {
  100. b.tag.Attr(vs...)
  101. return b
  102. }
  103. func (b *VBadgeBuilder) Children(children ...h.HTMLComponent) (r *VBadgeBuilder) {
  104. b.tag.Children(children...)
  105. return b
  106. }
  107. func (b *VBadgeBuilder) AppendChildren(children ...h.HTMLComponent) (r *VBadgeBuilder) {
  108. b.tag.AppendChildren(children...)
  109. return b
  110. }
  111. func (b *VBadgeBuilder) PrependChildren(children ...h.HTMLComponent) (r *VBadgeBuilder) {
  112. b.tag.PrependChildren(children...)
  113. return b
  114. }
  115. func (b *VBadgeBuilder) Class(names ...string) (r *VBadgeBuilder) {
  116. b.tag.Class(names...)
  117. return b
  118. }
  119. func (b *VBadgeBuilder) ClassIf(name string, add bool) (r *VBadgeBuilder) {
  120. b.tag.ClassIf(name, add)
  121. return b
  122. }
  123. func (b *VBadgeBuilder) On(name string, value string) (r *VBadgeBuilder) {
  124. b.tag.Attr(fmt.Sprintf("v-on:%s", name), value)
  125. return b
  126. }
  127. func (b *VBadgeBuilder) Bind(name string, value string) (r *VBadgeBuilder) {
  128. b.tag.Attr(fmt.Sprintf("v-bind:%s", name), value)
  129. return b
  130. }
  131. func (b *VBadgeBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  132. return b.tag.MarshalHTML(ctx)
  133. }