AnthoLume/ngtemplates/components/streak_card_templ.go

182 lines
7.8 KiB
Go
Raw Normal View History

2024-10-06 21:01:37 +00:00
// Code generated by templ - DO NOT EDIT.
2025-01-25 20:01:18 +00:00
// templ: version: v0.3.819
2024-10-06 21:01:37 +00:00
package components
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
2025-01-25 20:01:18 +00:00
import templruntime "github.com/a-h/templ/runtime"
2024-10-06 21:01:37 +00:00
import (
"fmt"
"reichard.io/antholume/database"
)
func StreakCard(streak database.UserStreak) templ.Component {
2025-01-25 20:01:18 +00:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
2024-10-06 21:01:37 +00:00
if !templ_7745c5c3_IsBuffer {
2025-01-25 20:01:18 +00:00
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
2024-10-06 21:01:37 +00:00
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"w-full\"><div class=\"relative w-full px-4 py-6 bg-white shadow-lg dark:bg-gray-700 rounded\"><p class=\"text-sm font-semibold text-gray-700 border-b border-gray-200 w-max dark:text-white dark:border-gray-500\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if streak.Window == "WEEK" {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Weekly Read Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "Daily Read Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</p><div class=\"flex items-end my-6 space-x-2\"><p class=\"text-5xl font-bold text-black dark:text-white\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(streak.CurrentStreak))
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 20, Col: 39}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div><div class=\"dark:text-white\"><div class=\"flex items-center justify-between pb-2 mb-2 text-sm border-b border-gray-200\"><div><p>")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if streak.Window == "WEEK" {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Current Read Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "Current Read Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</p><div class=\"flex items-end text-sm text-gray-400\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(streak.CurrentStreakStartDate)
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 34, Col: 38}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " ➞ ")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(streak.CurrentStreakEndDate)
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 34, Col: 74}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</div></div><div class=\"flex items-end font-bold\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(streak.CurrentStreak))
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 37, Col: 77}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div></div><div class=\"flex items-center justify-between pb-2 mb-2 text-sm\"><div><p>")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if streak.Window == "WEEK" {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "Best Weekly Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "Best Daily Streak")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</p><div class=\"flex items-end text-sm text-gray-400\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(streak.MaxStreakStartDate)
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 49, Col: 34}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " ➞ ")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(streak.MaxStreakEndDate)
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 49, Col: 66}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</div></div><div class=\"flex items-end font-bold\">")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(streak.MaxStreak))
if templ_7745c5c3_Err != nil {
2025-01-25 20:01:18 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/streak_card.templ`, Line: 52, Col: 73}
2024-10-06 21:01:37 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</div></div></div></div></div>")
2024-10-06 21:01:37 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 20:01:18 +00:00
return nil
2024-10-06 21:01:37 +00:00
})
}
2025-01-25 20:01:18 +00:00
var _ = templruntime.GeneratedTemplate