Add more background

This commit is contained in:
Florian Hoss 2023-10-04 08:27:37 +00:00
parent 5dff046ae0
commit 7b04abc023
5 changed files with 21 additions and 5 deletions

View file

@ -14,6 +14,7 @@ RUN go build -ldflags="-s -w" cmd/godash/godash.go
FROM node:${NODE_VERSION}-alpine AS nodeBuilder
WORKDIR /app
COPY ./internal/router/templates.go ./internal/router/templates.go
COPY ./web .
RUN yarn install --frozen-lockfile
RUN yarn run tailwind:build

View file

@ -6,7 +6,6 @@ type Config struct {
Category string
Entries []struct {
Name string
Background bool
URL string
}
}
@ -15,7 +14,7 @@ type Config struct {
Entries []struct {
Name string
Icon string
Background bool
Background string
URL string
}
}

View file

@ -8,6 +8,20 @@ import (
"github.com/labstack/echo/v4"
)
func backgroundColor(config string) string {
result := "p-[0.1rem] "
switch config {
case "dark":
return result + "bg-black "
case "light":
return result + "bg-white "
case "base":
return result + "bg-base-300 "
default:
return ""
}
}
type Template struct {
templates *template.Template
}
@ -18,6 +32,8 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con
func initTemplates() *Template {
return &Template{
templates: template.Must(template.New("").Funcs(sprig.FuncMap()).ParseGlob("web/templates/*.html")),
templates: template.Must(template.New("").Funcs(sprig.FuncMap()).Funcs(template.FuncMap{
"backgroundColor": backgroundColor,
}).ParseGlob("web/templates/*.html")),
}
}

View file

@ -1,6 +1,6 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./templates/**/*.html"],
content: ["./templates/**/*.html", "../internal/router/templates.go"],
theme: {
container: {
center: true

View file

@ -287,7 +287,7 @@
<div class="grid-apps">
{{ range .Entries }}
<a href="{{ .URL }}" class="bookmark-link flex items-center hover-effect">
<div class="{{ if .Background }}bg-white {{ end }}img rounded w-8 h-8 bg-contain bg-center bg-no-repeat opacity-90" style="background-image: url({{ .Icon }})"></div>
<div class="{{ backgroundColor .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>
<div class="uppercase truncate ml-2">{{ .Name }}</div>
</a>
{{ end }}