Use images as background again
This commit is contained in:
parent
fcd007d7be
commit
859db5db39
2 changed files with 30 additions and 4 deletions
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Develop
|
||||
|
||||
```sh
|
||||
docker compose run --rm node yarn install
|
||||
docker compose up --build
|
||||
```
|
|
@ -1,12 +1,32 @@
|
|||
package application
|
||||
|
||||
import (
|
||||
"gitlab.unjx.de/flohoss/godash/services"
|
||||
)
|
||||
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">
|
||||
<img class={ "rounded w-8 h-8 opacity-90", templ.KV("backgroundColor",application.Background !="") } src={ application.Icon }/>
|
||||
@templ.FromGoHTML(ImageTemplate, Bar{Background: backgroundColor(application.Background), Icon: application.Icon})
|
||||
<div class="uppercase truncate ml-2">{ application.Name }</div>
|
||||
</a>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue