godash/components/application/application.templ

32 lines
961 B
Text

package application
import "gitlab.unjx.de/flohoss/godash/services"
import "html/template"
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>"))
type Bar struct {
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 ""
}
}
templ Application(application services.Application) {
<a href={ templ.URL(application.URL) } class="flex items-center hover-effect">
@templ.FromGoHTML(ImageTemplate, Bar{Background: backgroundColor(application.Background), Icon: application.Icon})
<div class="uppercase truncate ml-2">{ application.Name }</div>
</a>
}