notfound.go 837 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package app
  2. var (
  3. // NotFound is the ui element that is displayed when a request is not
  4. // routed.
  5. NotFound UI = &notFound{}
  6. )
  7. type notFound struct {
  8. Compo
  9. Icon string
  10. }
  11. func (n *notFound) OnMount(Context) {
  12. links := Window().Get("document").Call("getElementsByTagName", "link")
  13. for i := 0; i < links.Length(); i++ {
  14. link := links.Index(i)
  15. rel := link.Call("getAttribute", "rel")
  16. if rel.String() == "icon" {
  17. favicon := link.Call("getAttribute", "href")
  18. n.Icon = favicon.String()
  19. return
  20. }
  21. }
  22. }
  23. func (n *notFound) Render() UI {
  24. return Div().
  25. Class("goapp-app-info").
  26. Body(
  27. Div().
  28. Class("goapp-notfound-title").
  29. Body(
  30. Text("4"),
  31. Img().
  32. Class("goapp-logo").
  33. Alt("0").
  34. Src(n.Icon),
  35. Text("4"),
  36. ),
  37. P().
  38. Class("goapp-label").
  39. Text("Not Found"),
  40. )
  41. }