From f0541ea5c8c9b1868b9ee0d80f771b5ae30a82b3 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Tue, 10 Jun 2025 08:25:34 +0100 Subject: [PATCH] Refactor icon stuff --- docs/configuration.md | 2 +- internal/glance/config-fields.go | 11 ++++------- internal/glance/templates/bookmarks.html | 2 +- internal/glance/templates/docker-containers.html | 2 +- internal/glance/templates/monitor.html | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 8b975b0..58fb997 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -188,7 +188,7 @@ This assumes that the config you want to print is in your current working direct ## Icons -For widgets which provide you with the ability to specify icons such as the monitor, bookmarks, docker containers, etc, you can use the `icon` property to specify a URL to an image. Alternatively, you can also use icon names from multiple libraries via prefixes: +For widgets which provide you with the ability to specify icons such as the monitor, bookmarks, docker containers, etc, you can use the `icon` property to specify a URL to an image or use icon names from multiple libraries via prefixes: ```yml icon: si:immich # si for Simple icons https://simpleicons.org/ diff --git a/internal/glance/config-fields.go b/internal/glance/config-fields.go index 608ffff..2eec599 100644 --- a/internal/glance/config-fields.go +++ b/internal/glance/config-fields.go @@ -131,10 +131,7 @@ func (d *durationField) UnmarshalYAML(node *yaml.Node) error { type customIconField struct { URL template.URL - IsFlatIcon bool - // TODO: along with whether the icon is flat, we also need to know - // whether the icon is black or white by default in order to properly - // invert the color based on the theme being light or dark + AutoInvert bool } func newCustomIconField(value string) customIconField { @@ -142,7 +139,7 @@ func newCustomIconField(value string) customIconField { field := customIconField{} if strings.HasPrefix(value, autoInvertPrefix) { - field.IsFlatIcon = true + field.AutoInvert = true value = strings.TrimPrefix(value, autoInvertPrefix) } @@ -164,12 +161,12 @@ func newCustomIconField(value string) customIconField { switch prefix { case "si": - field.IsFlatIcon = true + field.AutoInvert = true field.URL = template.URL("https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/" + basename + ".svg") case "di": field.URL = template.URL("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/" + ext + "/" + basename + "." + ext) case "mdi": - field.IsFlatIcon = true + field.AutoInvert = true field.URL = template.URL("https://cdn.jsdelivr.net/npm/@mdi/svg@latest/svg/" + basename + ".svg") case "sh": field.URL = template.URL("https://cdn.jsdelivr.net/gh/selfhst/icons/" + ext + "/" + basename + "." + ext) diff --git a/internal/glance/templates/bookmarks.html b/internal/glance/templates/bookmarks.html index 1952cdb..a1c9c51 100644 --- a/internal/glance/templates/bookmarks.html +++ b/internal/glance/templates/bookmarks.html @@ -13,7 +13,7 @@