avatar.go 2.8 KB

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