From f6ed2feab4d810f424bda9078d469b43899b0107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sun, 7 Mar 2021 11:02:52 -0800 Subject: [PATCH] Use SVG sprite for icons --- template/functions.go | 7 + template/templates/common/feed_list.html | 8 +- template/templates/common/icons.html | 135 ------------------- template/templates/common/item_meta.html | 12 +- template/templates/common/layout.html | 16 +-- template/templates/views/categories.html | 8 +- template/templates/views/entry.html | 16 +-- template/templates/views/shared_entries.html | 4 +- ui/static/bin/sprite.svg | 109 +++++++++++++++ ui/static/css/common.css | 5 +- ui/static_app_icon.go | 9 +- 11 files changed, 155 insertions(+), 174 deletions(-) delete mode 100644 template/templates/common/icons.html create mode 100644 ui/static/bin/sprite.svg diff --git a/template/functions.go b/template/functions.go index 7fff2eac..33519e95 100644 --- a/template/functions.go +++ b/template/functions.go @@ -80,6 +80,13 @@ func (f *funcMap) Map() template.FuncMap { "theme_color": func(theme string) string { return model.ThemeColor(theme) }, + "icon": func(iconName string) template.HTML { + return template.HTML(fmt.Sprintf( + ``, + route.Path(f.router, "appIcon", "filename", "sprite.svg"), + iconName, + )) + }, // These functions are overrided at runtime after the parsing. "elapsed": func(timezone string, t time.Time) string { diff --git a/template/templates/common/feed_list.html b/template/templates/common/feed_list.html index 27116a36..5825d216 100644 --- a/template/templates/common/feed_list.html +++ b/template/templates/common/feed_list.html @@ -28,10 +28,10 @@ diff --git a/template/templates/common/icons.html b/template/templates/common/icons.html deleted file mode 100644 index 0b82a3b3..00000000 --- a/template/templates/common/icons.html +++ /dev/null @@ -1,135 +0,0 @@ - -{{ define "icon_read" }} - - - - - -{{ end }} -{{ define "icon_unread" }} - - - - - -{{ end }} -{{ define "icon_star" }} - - - - -{{ end }} -{{ define "icon_unstar" }} - - - - -{{ end }} -{{ define "icon_save" }} - - - - - - -{{ end }} -{{ define "icon_scraper" }} - - - - - - -{{ end }} -{{ define "icon_share" }} - - - - - - - - -{{ end }} -{{ define "icon_comment" }} - - - - - - - -{{ end }} -{{ define "icon_external_link" }} - - - - - - -{{ end }} -{{ define "icon_delete" }} - - - - - - - - -{{ end }} -{{ define "icon_edit" }} - - - - - - -{{ end }} -{{ define "icon_feeds" }} - - - - - -{{ end }} -{{ define "icon_entries" }} - - - - - - - -{{ end }} -{{ define "icon_refresh" }} - - - - - -{{ end }} \ No newline at end of file diff --git a/template/templates/common/item_meta.html b/template/templates/common/item_meta.html index e2991ff8..c4f4f4bb 100644 --- a/template/templates/common/item_meta.html +++ b/template/templates/common/item_meta.html @@ -23,7 +23,7 @@ data-label-read="{{ t "entry.status.read" }}" data-label-unread="{{ t "entry.status.unread" }}" data-value="{{ if eq .entry.Status "read" }}read{{ else }}unread{{ end }}" - >{{ if eq .entry.Status "read" }}{{ template "icon_unread" }}{{ else }}{{ template "icon_read" }}{{ end }}{{ if eq .entry.Status "read" }}{{ t "entry.status.unread" }}{{ else }}{{ t "entry.status.read" }}{{ end }} + >{{ if eq .entry.Status "read" }}{{ icon "unread" }}{{ else }}{{ icon "read" }}{{ end }}{{ if eq .entry.Status "read" }}{{ t "entry.status.unread" }}{{ else }}{{ t "entry.status.read" }}{{ end }}
  • {{ if .entry.Starred }}{{ template "icon_unstar" }}{{ else }}{{ template "icon_star" }}{{ end }}{{ if .entry.Starred }}{{ t "entry.bookmark.toggle.off" }}{{ else }}{{ t "entry.bookmark.toggle.on" }}{{ end }} + >{{ if .entry.Starred }}{{ icon "unstar" }}{{ else }}{{ icon "star" }}{{ end }}{{ if .entry.Starred }}{{ t "entry.bookmark.toggle.off" }}{{ else }}{{ t "entry.bookmark.toggle.on" }}{{ end }}
  • {{ if .entry.ShareCode }}
  • {{ template "icon_share" }}{{ t "entry.shared_entry.label" }} + target="_blank">{{ icon "share" }}{{ t "entry.shared_entry.label" }}
  • {{ end }} {{ if .hasSaveEntry }} @@ -50,7 +50,7 @@ data-save-url="{{ route "saveEntry" "entryID" .entry.ID }}" data-label-loading="{{ t "entry.state.saving" }}" data-label-done="{{ t "entry.save.completed" }}" - >{{ template "icon_save" }}{{ t "entry.save.label" }} + >{{ icon "save" }}{{ t "entry.save.label" }} {{ end }}
  • @@ -58,7 +58,7 @@ target="_blank" rel="noopener noreferrer" referrerpolicy="no-referrer" - data-original-link="true">{{ template "icon_external_link" }}{{ t "entry.external_link.label" }} + data-original-link="true">{{ icon "external-link" }}{{ t "entry.external_link.label" }}
  • {{ if .entry.CommentsURL }}
  • @@ -67,7 +67,7 @@ target="_blank" rel="noopener noreferrer" referrerpolicy="no-referrer" - data-comments-link="true">{{ template "icon_comment" }}{{ t "entry.comments.label" }} + data-comments-link="true">{{ icon "comment" }}{{ t "entry.comments.label" }}
  • {{ end }} diff --git a/template/templates/common/layout.html b/template/templates/common/layout.html index d56218be..7376b416 100644 --- a/template/templates/common/layout.html +++ b/template/templates/common/layout.html @@ -157,18 +157,10 @@ - - - - + + + + {{ end }} diff --git a/template/templates/views/categories.html b/template/templates/views/categories.html index e37932e7..0ccc4bc4 100644 --- a/template/templates/views/categories.html +++ b/template/templates/views/categories.html @@ -30,13 +30,13 @@ diff --git a/template/templates/views/entry.html b/template/templates/views/entry.html index f253ee42..70b8a408 100644 --- a/template/templates/views/entry.html +++ b/template/templates/views/entry.html @@ -18,7 +18,7 @@ data-toast-unread="✘ {{ t "entry.status.toast.unread" }}" data-toast-read="✔︎ {{ t "entry.status.toast.read" }}" data-value="{{ if eq .entry.Status "read" }}read{{ else }}unread{{ end }}" - >{{ if eq .entry.Status "unread" }}{{ template "icon_read" }}{{ else }}{{ template "icon_unread" }}{{ end }}{{ if eq .entry.Status "unread" }}{{ t "entry.status.read" }}{{ else }}{{ t "entry.status.unread" }}{{ end }} + >{{ if eq .entry.Status "unread" }}{{ icon "read" }}{{ else }}{{ icon "unread" }}{{ end }}{{ if eq .entry.Status "unread" }}{{ t "entry.status.read" }}{{ else }}{{ t "entry.status.unread" }}{{ end }}
  • {{ if .entry.Starred }}{{ template "icon_unstar" }}{{ else }}{{ template "icon_star" }}{{ end }}{{ if .entry.Starred }}{{ t "entry.bookmark.toggle.off" }}{{ else }}{{ t "entry.bookmark.toggle.on" }}{{ end }} + >{{ if .entry.Starred }}{{ icon "unstar" }}{{ else }}{{ icon "star" }}{{ end }}{{ if .entry.Starred }}{{ t "entry.bookmark.toggle.off" }}{{ else }}{{ t "entry.bookmark.toggle.on" }}{{ end }}
  • {{ if .hasSaveEntry }}
  • @@ -41,18 +41,18 @@ data-label-loading="{{ t "entry.state.saving" }}" data-label-done="{{ t "entry.save.completed" }}" data-toast-done="{{ t "entry.save.toast.completed" }}" - >{{ template "icon_save" }}{{ t "entry.save.label" }} + >{{ icon "save" }}{{ t "entry.save.label" }}
  • {{ end }}
  • {{ if .entry.ShareCode }} {{ template "icon_share" }}{{ t "entry.shared_entry.label" }} + target="_blank">{{ icon "share" }}{{ t "entry.shared_entry.label" }} {{ else }} {{ template "icon_share" }}{{ t "entry.share.label" }} + target="_blank">{{ icon "share" }}{{ t "entry.share.label" }} {{ end }}
  • @@ -60,7 +60,7 @@ target="_blank" rel="noopener noreferrer" referrerpolicy="no-referrer" - data-original-link="true">{{ template "icon_external_link" }}{{ t "entry.external_link.label" }} + data-original-link="true">{{ icon "external-link" }}{{ t "entry.external_link.label" }}
  • {{ template "icon_scraper" }}{{ t "entry.scraper.label" }} + >{{ icon "scraper" }}{{ t "entry.scraper.label" }}
  • {{ if .entry.CommentsURL }}
  • @@ -78,7 +78,7 @@ rel="noopener noreferrer" referrerpolicy="no-referrer" data-comments-link="true" - >{{ template "icon_comment" }}{{ t "entry.comments.label" }} + >{{ icon "comment" }}{{ t "entry.comments.label" }}
  • {{ end }} diff --git a/template/templates/views/shared_entries.html b/template/templates/views/shared_entries.html index 1423723b..0dd77632 100644 --- a/template/templates/views/shared_entries.html +++ b/template/templates/views/shared_entries.html @@ -36,7 +36,7 @@ {{ if .ShareCode }} {{ template "icon_share" }} + target="_blank">{{ icon "share" }} {{ end }} {{ .Feed.Category.Title }} @@ -52,7 +52,7 @@