Add more background
This commit is contained in:
parent
5dff046ae0
commit
7b04abc023
5 changed files with 21 additions and 5 deletions
|
@ -14,6 +14,7 @@ RUN go build -ldflags="-s -w" cmd/godash/godash.go
|
||||||
FROM node:${NODE_VERSION}-alpine AS nodeBuilder
|
FROM node:${NODE_VERSION}-alpine AS nodeBuilder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./internal/router/templates.go ./internal/router/templates.go
|
||||||
COPY ./web .
|
COPY ./web .
|
||||||
RUN yarn install --frozen-lockfile
|
RUN yarn install --frozen-lockfile
|
||||||
RUN yarn run tailwind:build
|
RUN yarn run tailwind:build
|
||||||
|
|
|
@ -6,7 +6,6 @@ type Config struct {
|
||||||
Category string
|
Category string
|
||||||
Entries []struct {
|
Entries []struct {
|
||||||
Name string
|
Name string
|
||||||
Background bool
|
|
||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +14,7 @@ type Config struct {
|
||||||
Entries []struct {
|
Entries []struct {
|
||||||
Name string
|
Name string
|
||||||
Icon string
|
Icon string
|
||||||
Background bool
|
Background string
|
||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,20 @@ import (
|
||||||
"github.com/labstack/echo/v4"
|
"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 {
|
type Template struct {
|
||||||
templates *template.Template
|
templates *template.Template
|
||||||
}
|
}
|
||||||
|
@ -18,6 +32,8 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con
|
||||||
|
|
||||||
func initTemplates() *Template {
|
func initTemplates() *Template {
|
||||||
return &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")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: ["./templates/**/*.html"],
|
content: ["./templates/**/*.html", "../internal/router/templates.go"],
|
||||||
theme: {
|
theme: {
|
||||||
container: {
|
container: {
|
||||||
center: true
|
center: true
|
||||||
|
|
|
@ -287,7 +287,7 @@
|
||||||
<div class="grid-apps">
|
<div class="grid-apps">
|
||||||
{{ range .Entries }}
|
{{ range .Entries }}
|
||||||
<a href="{{ .URL }}" class="bookmark-link flex items-center hover-effect">
|
<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>
|
<div class="uppercase truncate ml-2">{{ .Name }}</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue