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"
|
|
|
|
"reichard.io/antholume/ngtemplates/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
func FirstNonZero[T comparable](all ...T) T {
|
|
|
|
var zeroT T
|
|
|
|
for _, item := range all {
|
|
|
|
if item != zeroT {
|
|
|
|
return item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return zeroT
|
|
|
|
}
|
|
|
|
|
|
|
|
func orUnknown(val *string) string {
|
|
|
|
if val == nil {
|
|
|
|
return "Unknown"
|
|
|
|
}
|
|
|
|
return *val
|
|
|
|
}
|
|
|
|
|
|
|
|
func DocumentCard(document database.GetDocumentsWithStatsRow) 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 relative\"><div class=\"flex gap-4 w-full h-full p-4 shadow-lg bg-white dark:bg-gray-700 rounded\"><div class=\"min-w-fit my-auto h-48 relative\"><a href=\"")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
var templ_7745c5c3_Var2 templ.SafeURL = templ.SafeURL(fmt.Sprintf("./documents/%s", document.ID))
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(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, 2, "\"><img class=\"rounded object-cover h-full\" src=\"")
|
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(fmt.Sprintf("./documents/%s/cover", document.ID))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-01-25 20:01:18 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/document_card.templ`, Line: 35, Col: 60}
|
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, 3, "\"></a></div><div class=\"flex flex-col justify-around dark:text-white w-full text-sm\"><div class=\"inline-flex shrink-0 items-center\"><div><p class=\"text-gray-400\">Title</p><p class=\"font-medium\">")
|
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(orUnknown(document.Title))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-01-25 20:01:18 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/document_card.templ`, Line: 43, Col: 56}
|
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, 4, "</p></div></div><div class=\"inline-flex shrink-0 items-center\"><div><p class=\"text-gray-400\">Author</p><p class=\"font-medium\">")
|
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(orUnknown(document.Author))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-01-25 20:01:18 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/document_card.templ`, Line: 49, Col: 57}
|
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, 5, "</p></div></div><div class=\"inline-flex shrink-0 items-center\"><div><p class=\"text-gray-400\">Progress</p><p class=\"font-medium\">")
|
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(fmt.Sprintf("%.2f%%", document.Percentage))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-01-25 20:01:18 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/document_card.templ`, Line: 55, Col: 73}
|
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, 6, "</p></div></div><div class=\"inline-flex shrink-0 items-center\"><div><p class=\"text-gray-400\">Time Read</p><p class=\"font-medium\">")
|
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(common.NiceSeconds(document.TotalTimeSeconds))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-01-25 20:01:18 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ngtemplates/components/document_card.templ`, Line: 61, Col: 76}
|
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, 7, "</p></div></div></div><div class=\"absolute flex flex-col gap-2 right-4 bottom-4 text-gray-500 dark:text-gray-400\"><a href=\"./activity?document={{ .ID }}\">")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Err = ActivitySVG("").Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
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, "</a> ")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
if document.Filepath != nil && *document.Filepath != "" {
|
2025-01-25 20:01:18 +00:00
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<a href=\"")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
var templ_7745c5c3_Var8 templ.SafeURL = templ.SafeURL(fmt.Sprintf("./documents/%s/file", document.ID))
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(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, 10, "\">")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Err = DownloadSVG("").Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
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, "</a>")
|
2024-10-06 21:01:37 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
templ_7745c5c3_Err = DownloadSVG("text-gray-200 dark:text-gray-600").Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
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, 12, "</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
|