2024-03-18 16:12:25 +01:00
|
|
|
package components
|
2024-03-12 15:49:08 +01:00
|
|
|
|
2024-03-18 16:12:25 +01:00
|
|
|
import (
|
|
|
|
"gitlab.unjx.de/flohoss/godash/services"
|
|
|
|
"html/template"
|
|
|
|
)
|
2024-03-14 16:33:34 +01:00
|
|
|
|
|
|
|
var ImageTemplate = template.Must(template.New("bar").Parse("<div class=\"{{ .Background }}img rounded w-8 h-8 bg-contain bg-center bg-origin-content bg-no-repeat opacity-90\" style=\"background-image: url({{ .Icon }})\"></div>"))
|
|
|
|
|
2024-03-18 16:12:25 +01:00
|
|
|
type Image struct {
|
2024-03-14 16:33:34 +01:00
|
|
|
Background string
|
|
|
|
Icon string
|
|
|
|
}
|
|
|
|
|
|
|
|
func backgroundColor(config string) string {
|
|
|
|
result := "p-[0.05rem] "
|
|
|
|
switch config {
|
|
|
|
case "dark":
|
|
|
|
return result + "bg-black "
|
|
|
|
case "light":
|
|
|
|
return result + "bg-white "
|
|
|
|
case "base":
|
|
|
|
return result + "bg-base-300 "
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2024-03-12 15:49:08 +01:00
|
|
|
|
|
|
|
templ Application(application services.Application) {
|
|
|
|
<a href={ templ.URL(application.URL) } class="flex items-center hover-effect">
|
2024-03-18 16:12:25 +01:00
|
|
|
@templ.FromGoHTML(ImageTemplate, Image{Background: backgroundColor(application.Background), Icon: application.Icon})
|
2024-03-12 15:49:08 +01:00
|
|
|
<div class="uppercase truncate ml-2">{ application.Name }</div>
|
|
|
|
</a>
|
|
|
|
}
|
2024-03-18 16:12:25 +01:00
|
|
|
|
|
|
|
templ Link(link services.Link) {
|
|
|
|
<a href={ templ.URL(link.URL) } class="hover-effect">
|
|
|
|
<div class="truncate">{ link.Name }</div>
|
|
|
|
</a>
|
|
|
|
}
|