profile.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package e21_presents
  2. import (
  3. "strings"
  4. "github.com/qor5/admin/presets"
  5. . "github.com/qor5/ui/vuetify"
  6. "github.com/qor5/web"
  7. h "github.com/theplant/htmlgo"
  8. )
  9. func PresetsProfile(b *presets.Builder) {
  10. // @snippet_begin(ProfileSample)
  11. b.URIPrefix(PresetsProfilePath).BrandTitle("Admin").
  12. ProfileFunc(func(ctx *web.EventContext) h.HTMLComponent {
  13. // Demo
  14. logoutURL := "."
  15. name := "QOR5"
  16. account := "hello@getqor.com"
  17. roles := []string{"Developer"}
  18. return VMenu().OffsetY(true).Children(
  19. h.Template().Attr("v-slot:activator", "{on, attrs}").Children(
  20. VList(
  21. VListItem(
  22. VListItemAvatar(
  23. VAvatar().Class("ml-1").Color("secondary").Size(40).Children(
  24. h.Span(string(name[0])).Class("white--text text-h5"),
  25. ),
  26. ),
  27. VListItemContent(
  28. VListItemTitle(h.Text(name)),
  29. h.Br(),
  30. VListItemSubtitle(h.Text(strings.Join(roles, ", "))),
  31. ),
  32. ).Class("pa-0 mb-2"),
  33. VListItem(
  34. VListItemContent(
  35. VListItemTitle(h.Text(account)),
  36. ),
  37. VListItemIcon(
  38. VIcon("logout").Small(true).Attr("@click", web.Plaid().URL(logoutURL).Go()),
  39. ),
  40. ).Class("pa-0 my-n4 ml-1").Dense(true),
  41. ).Class("pa-0 ma-n4"),
  42. ),
  43. )
  44. })
  45. // @snippet_end
  46. b.Model(&brand{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  47. r.Body = VContainer()
  48. return
  49. })
  50. }
  51. const PresetsProfilePath = "/samples/profile"