2024-03-12 16:16:49 +01:00
|
|
|
package application
|
2024-03-12 15:49:08 +01:00
|
|
|
|
2024-03-14 16:33:34 +01:00
|
|
|
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 ""
|
|
|
|
}
|
|
|
|
}
|
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-14 16:33:34 +01:00
|
|
|
@templ.FromGoHTML(ImageTemplate, Bar{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>
|
|
|
|
}
|