user_home_templ.go

  1// Code generated by templ - DO NOT EDIT.
  2
  3// templ: version: v0.3.1020
  4package pages
  5
  6//lint:file-ignore SA4006 This context is only used if a nested component is present.
  7
  8import "github.com/a-h/templ"
  9import templruntime "github.com/a-h/templ/runtime"
 10
 11import (
 12	"git.kilimanjaro.io/rtw/document"
 13	"git.kilimanjaro.io/rtw/pages/components"
 14	"git.kilimanjaro.io/rtw/pages/utils"
 15)
 16
 17// blue, red, orange, yellow, green, cyan, purple, magenta
 18var colors = []string{"#205ea6", "#af3029", "#bc5215", "#ad8301", "#66800b", "#24837b", "#5e409d", "#a02f6f"}
 19
 20func UserHome(data UserHomeData) templ.Component {
 21	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 22		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 23		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 24			return templ_7745c5c3_CtxErr
 25		}
 26		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
 27		if !templ_7745c5c3_IsBuffer {
 28			defer func() {
 29				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
 30				if templ_7745c5c3_Err == nil {
 31					templ_7745c5c3_Err = templ_7745c5c3_BufErr
 32				}
 33			}()
 34		}
 35		ctx = templ.InitializeContext(ctx)
 36		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
 37		if templ_7745c5c3_Var1 == nil {
 38			templ_7745c5c3_Var1 = templ.NopComponent
 39		}
 40		ctx = templ.ClearChildren(ctx)
 41		templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 42			templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 43			templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
 44			if !templ_7745c5c3_IsBuffer {
 45				defer func() {
 46					templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
 47					if templ_7745c5c3_Err == nil {
 48						templ_7745c5c3_Err = templ_7745c5c3_BufErr
 49					}
 50				}()
 51			}
 52			ctx = templ.InitializeContext(ctx)
 53			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"px-2 md:px-0 py-18\"><div class=\"w-full h-[50dvh] mx-auto flex flex-col rounded-xl shadow-md\">")
 54			if templ_7745c5c3_Err != nil {
 55				return templ_7745c5c3_Err
 56			}
 57			templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 58				templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 59				templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
 60				if !templ_7745c5c3_IsBuffer {
 61					defer func() {
 62						templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
 63						if templ_7745c5c3_Err == nil {
 64							templ_7745c5c3_Err = templ_7745c5c3_BufErr
 65						}
 66					}()
 67				}
 68				ctx = templ.InitializeContext(ctx)
 69				for i, tripWaypoints := range data.Waypoints {
 70					for _, tp := range tripWaypoints {
 71						for _, route := range tp.From {
 72							templ_7745c5c3_Err = components.Route(route.ID, colors[i%len(colors)]).Render(ctx, templ_7745c5c3_Buffer)
 73							if templ_7745c5c3_Err != nil {
 74								return templ_7745c5c3_Err
 75							}
 76						}
 77					}
 78				}
 79				return nil
 80			})
 81			templ_7745c5c3_Err = components.Map(data.StyleURL, data.Bbox, "rounded-xl w-full h-full").Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
 82			if templ_7745c5c3_Err != nil {
 83				return templ_7745c5c3_Err
 84			}
 85			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div><div class=\"py-2 mt-4\"><span class=\"font-extrabold text-xl md:text-2xl\">Trips</span> <span class=\"font-gray-600 pl-2\">(")
 86			if templ_7745c5c3_Err != nil {
 87				return templ_7745c5c3_Err
 88			}
 89			var templ_7745c5c3_Var4 string
 90			templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(len(data.Waypoints))
 91			if templ_7745c5c3_Err != nil {
 92				return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 28, Col: 59}
 93			}
 94			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
 95			if templ_7745c5c3_Err != nil {
 96				return templ_7745c5c3_Err
 97			}
 98			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, ")</span></div><div class=\"w-10 h-1 bg-(--color-orange) mb-4\"></div><div class=\"flex flex-col gap-10\">")
 99			if templ_7745c5c3_Err != nil {
100				return templ_7745c5c3_Err
101			}
102			for i, wp := range data.Waypoints {
103				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\"flex flex-row gap-4\"><div class=\"h-[200px] md:w-[200px] w-full rounded-xl shadow-md\">")
104				if templ_7745c5c3_Err != nil {
105					return templ_7745c5c3_Err
106				}
107				templ_7745c5c3_Err = components.TripMap(data.StyleURL, wp, colors[i%len(colors)]).Render(ctx, templ_7745c5c3_Buffer)
108				if templ_7745c5c3_Err != nil {
109					return templ_7745c5c3_Err
110				}
111				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</div><div class=\"w-full h-full flex flex-col grow max-h-[300px] md:max-h-[200px]\"><div class=\"grow truncate mb-2 border-1 border-gray-300 rounded-xl px-2 py-1 shadow-md flex flex-col md:flex-row gap-4\"><div class=\"border-b-2 md:border-r-2 md:border-b-0 border-(--color-orange) pb-2 md:pr-2 md:pb-0 flex flex-row md:flex-col justify-between\"><div class=\"flex flex-row md:flex-col gap-2 md:gap-0\"><div class=\"uppercase text-gray-600 text-sm\">Waypoints</div><div class=\"font-bold text-(--color-black) mb-1 text-sm md:text-md\">")
112				if templ_7745c5c3_Err != nil {
113					return templ_7745c5c3_Err
114				}
115				var templ_7745c5c3_Var5 string
116				templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(len(wp))
117				if templ_7745c5c3_Err != nil {
118					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 42, Col: 87}
119				}
120				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
121				if templ_7745c5c3_Err != nil {
122					return templ_7745c5c3_Err
123				}
124				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</div></div><div class=\"flex flex-row md:flex-col gap-2 md:gap-0\"><div class=\"uppercase text-gray-600 text-sm\">Distance</div><div class=\"font-bold text-(--color-black) mb-1 text-sm md:text-md\">")
125				if templ_7745c5c3_Err != nil {
126					return templ_7745c5c3_Err
127				}
128				var templ_7745c5c3_Var6 string
129				templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(utils.FormatDistance(utils.Distance(wp)))
130				if templ_7745c5c3_Err != nil {
131					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 46, Col: 120}
132				}
133				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
134				if templ_7745c5c3_Err != nil {
135					return templ_7745c5c3_Err
136				}
137				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</div></div><div class=\"flex flex-row md:flex-col gap-2 md:gap-0\"><div class=\"uppercase text-gray-600 text-sm\">Countries</div><div class=\"font-bold text-(--color-black) mb-1 text-sm md:text-md\">")
138				if templ_7745c5c3_Err != nil {
139					return templ_7745c5c3_Err
140				}
141				var templ_7745c5c3_Var7 string
142				templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(len(utils.Countries(wp)))
143				if templ_7745c5c3_Err != nil {
144					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 50, Col: 104}
145				}
146				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
147				if templ_7745c5c3_Err != nil {
148					return templ_7745c5c3_Err
149				}
150				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</div></div></div>")
151				if templ_7745c5c3_Err != nil {
152					return templ_7745c5c3_Err
153				}
154				templ_7745c5c3_Err = document.DocumentComponent(data.Documents[i]).Render(ctx, templ_7745c5c3_Buffer)
155				if templ_7745c5c3_Err != nil {
156					return templ_7745c5c3_Err
157				}
158				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</div><div class=\"justify-start mt-1 flex flex-row\">")
159				if templ_7745c5c3_Err != nil {
160					return templ_7745c5c3_Err
161				}
162				if data.IsLoggedInUser {
163					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<a href=\"")
164					if templ_7745c5c3_Err != nil {
165						return templ_7745c5c3_Err
166					}
167					var templ_7745c5c3_Var8 templ.SafeURL
168					templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL("/edit/" + data.DocumentIDs[i].Compact()))
169					if templ_7745c5c3_Err != nil {
170						return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 58, Col: 68}
171					}
172					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
173					if templ_7745c5c3_Err != nil {
174						return templ_7745c5c3_Err
175					}
176					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" class=\"bg-(--color-blue) rounded-full text-white px-5 py-1 w-content flex flex-row cursor-pointer hover:ring-2 hover:ring-white\">Edit this trip <svg class=\"ml-2 items-center m-auto\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-file-pen-line-icon lucide-file-pen-line\"><path d=\"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z\"></path><path d=\"M14.487 7.858A1 1 0 0 1 14 7V2\"></path><path d=\"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516\"></path><path d=\"M8 18h1\"></path></svg></a>")
177					if templ_7745c5c3_Err != nil {
178						return templ_7745c5c3_Err
179					}
180				} else {
181					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<a href=\"")
182					if templ_7745c5c3_Err != nil {
183						return templ_7745c5c3_Err
184					}
185					var templ_7745c5c3_Var9 templ.SafeURL
186					templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL("/trip/" + data.DocumentIDs[i].Compact()))
187					if templ_7745c5c3_Err != nil {
188						return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/user_home.templ`, Line: 66, Col: 68}
189					}
190					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
191					if templ_7745c5c3_Err != nil {
192						return templ_7745c5c3_Err
193					}
194					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\" class=\"border-2 border-gray-300 rounded-md text-(--color-black) px-5 py-1 w-content flex flex-row cursor-pointer hover:ring-4 hover:ring-(--color-orange)\">View this trip <svg class=\"ml-2 items-center m-auto\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-map-icon lucide-map\"><path d=\"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z\"></path><path d=\"M15 5.764v15\"></path><path d=\"M9 3.236v15\"></path></svg></a>")
195					if templ_7745c5c3_Err != nil {
196						return templ_7745c5c3_Err
197					}
198				}
199				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</div></div></div>")
200				if templ_7745c5c3_Err != nil {
201					return templ_7745c5c3_Err
202				}
203			}
204			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div></div>")
205			if templ_7745c5c3_Err != nil {
206				return templ_7745c5c3_Err
207			}
208			return nil
209		})
210		templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
211		if templ_7745c5c3_Err != nil {
212			return templ_7745c5c3_Err
213		}
214		return nil
215	})
216}
217
218var _ = templruntime.GeneratedTemplate