Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

SSR: Standardize 'empty state' message across pages to a reusable template.

Kailash Nadhfff59679ad29
diff --git a/static/admin/assets/css/style.css b/static/admin/assets/css/style.css
index 21fdc403..6b2b5252 100644
--- a/static/admin/assets/css/style.css
+++ b/static/admin/assets/css/style.css
@@ -569,6 +569,32 @@ main {
}
}
+/* Placeholder for empty tables, lists and cards ({{ template "empty-state" }}). */
+.empty-state {
+ align-items: center;
+ color: var(--muted-foreground);
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-3);
+ padding-block: var(--space-10);
+ text-align: center;
+
+ svg.icon {
+ color: var(--faint-foreground);
+ font-size: var(--text-2);
+ margin: 0;
+ stroke-width: 1.5;
+ }
+
+ p {
+ margin: 0;
+ }
+}
+
+td > .empty-state {
+ padding-block: var(--space-8);
+}
+
.page-content {
margin-block-end: var(--space-6);
diff --git a/static/admin/assets/static/icons.svg b/static/admin/assets/static/icons.svg
index aca7dfbb..4c45e398 100644
--- a/static/admin/assets/static/icons.svg
+++ b/static/admin/assets/static/icons.svg
@@ -39,6 +39,10 @@
<polyline points="9 11 12 14 22 4" /><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11" />
</symbol>
+ <symbol id="icon-chevron-down" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="6 9 12 15 18 9" />
+ </symbol>
+
<symbol id="icon-chevron-left" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="15 18 9 12 15 6" />
</symbol>
@@ -83,6 +87,10 @@
<rect x="3" y="3" width="18" height="18" rx="2" ry="2" /><circle cx="8.5" cy="8.5" r="1.5" /><polyline points="21 15 16 10 5 21" />
</symbol>
+ <symbol id="icon-inbox" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="22 12 16 12 14 15 10 15 8 12 2 12" /><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
+ </symbol>
+
<symbol id="icon-info" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" />
</symbol>
@@ -103,6 +111,10 @@
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" /><polyline points="22,6 12,13 2,6" />
</symbol>
+ <symbol id="icon-menu" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="18" x2="21" y2="18" />
+ </symbol>
+
<symbol id="icon-minus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="5" y1="12" x2="19" y2="12" />
</symbol>
@@ -111,6 +123,10 @@
<circle cx="12" cy="12" r="1" /><circle cx="12" cy="5" r="1" /><circle cx="12" cy="19" r="1" />
</symbol>
+ <symbol id="icon-pause" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="6" y="4" width="4" height="16" /><rect x="14" y="4" width="4" height="16" />
+ </symbol>
+
<symbol id="icon-pause-circle" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" /><line x1="10" y1="15" x2="10" y2="9" /><line x1="14" y1="15" x2="14" y2="9" />
</symbol>
diff --git a/static/admin/icons.txt b/static/admin/icons.txt
index bebd9e7c..0e0e1393 100644
--- a/static/admin/icons.txt
+++ b/static/admin/icons.txt
@@ -8,6 +8,7 @@ bar-chart-2
calendar
check-circle
check-square
+chevron-down
chevron-left
chevron-right
clock
@@ -19,13 +20,16 @@ eye
file-text
grid
image
+inbox
info
link-2
list
log-out
mail
+menu
minus
more-vertical
+pause
pause-circle
plus
refresh-cw
@@ -43,4 +47,4 @@ user
user-check
user-x
users
-x-circle
\ No newline at end of file
+x-circle
diff --git a/static/admin/partials/campaign-attachments.html b/static/admin/partials/campaign-attachments.html
index da705838..7162226a 100644
--- a/static/admin/partials/campaign-attachments.html
+++ b/static/admin/partials/campaign-attachments.html
@@ -11,7 +11,7 @@
</template>
</ul>
<template x-if="form.media.length === 0">
- <div class="align-center text-light">{{ $root.L.T "globals.messages.emptyState" }}</div>
+ {{- template "empty-state" }}
</template>
<footer class="hstack mt-6">
diff --git a/static/admin/partials/empty-state.html b/static/admin/partials/empty-state.html
new file mode 100644
index 00000000..b8b4298f
--- /dev/null
+++ b/static/admin/partials/empty-state.html
@@ -0,0 +1,9 @@
+{{ define "empty-state" -}}
+{{- /* Optional data is a colspan, which wraps the block in a table row for use inside a <tbody>. */ -}}
+{{- if . }}<tr><td colspan="{{ . }}">{{ end -}}
+<div class="empty-state">
+ {{ Icon "inbox" }}
+ <p>{{ L.T "globals.messages.emptyState" }}</p>
+</div>
+{{- if . }}</td></tr>{{ end -}}
+{{- end }}
diff --git a/static/admin/partials/media-gallery.html b/static/admin/partials/media-gallery.html
index e9855404..998ba092 100644
--- a/static/admin/partials/media-gallery.html
+++ b/static/admin/partials/media-gallery.html
@@ -61,7 +61,7 @@
{{- end }}
</ul>
{{- else }}
- <div class="align-center text-light">{{ $root.L.T "globals.messages.emptyState" }}</div>
+ {{- template "empty-state" }}
{{- end }}
{{- template "pagination" $d.Page.Pagination }}
diff --git a/static/admin/partials/subscriber-bounces.html b/static/admin/partials/subscriber-bounces.html
index 006c963b..369e5623 100644
--- a/static/admin/partials/subscriber-bounces.html
+++ b/static/admin/partials/subscriber-bounces.html
@@ -26,7 +26,7 @@
</tbody>
</table>
{{- else }}
- <p class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</p>
+ {{- template "empty-state" }}
{{- end }}
</div>
{{- end }}
diff --git a/static/admin/partials/subscriber-lists.html b/static/admin/partials/subscriber-lists.html
index dd41a90d..fdfcf9ab 100644
--- a/static/admin/partials/subscriber-lists.html
+++ b/static/admin/partials/subscriber-lists.html
@@ -55,7 +55,7 @@
{{- end }}
</tr>
{{- else }}
- <tr><td colspan="6" class="align-center text-light">{{ $root.L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 6 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/analytics.html b/static/admin/views/analytics.html
index 4a578096..c8e105d8 100644
--- a/static/admin/views/analytics.html
+++ b/static/admin/views/analytics.html
@@ -51,17 +51,16 @@
</form>
{{- if $d.HasData }}
- {{- $empty := .L.T "globals.messages.emptyState" }}
- {{ template "analytics-chart" dict "Title" (.L.T "campaigns.views") "Count" $d.Counts.Views "Key" "views" "Empty" $empty }}
- {{ template "analytics-chart" dict "Title" (.L.T "campaigns.clicks") "Count" $d.Counts.Clicks "Key" "clicks" "Empty" $empty }}
- {{ template "analytics-chart" dict "Title" (.L.T "globals.terms.bounces") "Count" $d.Counts.Bounces "Key" "bounces" "Empty" $empty }}
+ {{ template "analytics-chart" dict "Title" (.L.T "campaigns.views") "Count" $d.Counts.Views "Key" "views" }}
+ {{ template "analytics-chart" dict "Title" (.L.T "campaigns.clicks") "Count" $d.Counts.Clicks "Key" "clicks" }}
+ {{ template "analytics-chart" dict "Title" (.L.T "globals.terms.bounces") "Count" $d.Counts.Bounces "Key" "bounces" }}
<article class="card">
<h4>{{ .L.T "analytics.links" }}</h4>
{{- if $d.Data.Links }}
<div class="chart-box"><canvas id="chart-links"></canvas></div>
{{- else }}
- <p class="text-light align-center">{{ $empty }}</p>
+ {{- template "empty-state" }}
{{- end }}
</article>
{{- end }}
@@ -83,7 +82,7 @@
<div class="col-3 donut-container"><canvas id="chart-{{ $key }}-donut"></canvas></div>
</div>
{{- else }}
- <p class="text-light align-center">{{ .Empty }}</p>
+ {{- template "empty-state" }}
{{- end }}
</article>
{{- end }}
diff --git a/static/admin/views/bounces.html b/static/admin/views/bounces.html
index 0dddea80..e469b581 100644
--- a/static/admin/views/bounces.html
+++ b/static/admin/views/bounces.html
@@ -86,7 +86,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="7" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 7 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/campaigns.html b/static/admin/views/campaigns.html
index 55590f26..3ceaa272 100644
--- a/static/admin/views/campaigns.html
+++ b/static/admin/views/campaigns.html
@@ -161,7 +161,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="7" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 7 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/dashboard.html b/static/admin/views/dashboard.html
index fb977fe7..49962da5 100644
--- a/static/admin/views/dashboard.html
+++ b/static/admin/views/dashboard.html
@@ -94,7 +94,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="3" class="text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 4 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/list-role.html b/static/admin/views/list-role.html
index fca3e14c..19069dcf 100644
--- a/static/admin/views/list-role.html
+++ b/static/admin/views/list-role.html
@@ -64,7 +64,7 @@
</tr>
</template>
<template x-if="form.lists.length === 0">
- <tr><td colspan="3" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 3 }}
</template>
</tbody>
</table>
diff --git a/static/admin/views/lists.html b/static/admin/views/lists.html
index eb3b486e..43c4e6b4 100644
--- a/static/admin/views/lists.html
+++ b/static/admin/views/lists.html
@@ -150,7 +150,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="6" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 6 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/roles.html b/static/admin/views/roles.html
index 95d7fba4..d75238e1 100644
--- a/static/admin/views/roles.html
+++ b/static/admin/views/roles.html
@@ -62,7 +62,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="4" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 4 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/subscribers.html b/static/admin/views/subscribers.html
index 0c875e43..ef134b49 100644
--- a/static/admin/views/subscribers.html
+++ b/static/admin/views/subscribers.html
@@ -134,7 +134,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="7" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 7 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/templates.html b/static/admin/views/templates.html
index 12342c6c..f3b0d903 100644
--- a/static/admin/views/templates.html
+++ b/static/admin/views/templates.html
@@ -81,7 +81,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="6" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 6 }}
{{- end }}
</tbody>
</table>
diff --git a/static/admin/views/users.html b/static/admin/views/users.html
index ed078c75..264d8f0f 100644
--- a/static/admin/views/users.html
+++ b/static/admin/views/users.html
@@ -98,7 +98,7 @@
</td>
</tr>
{{- else }}
- <tr><td colspan="8" class="align-center text-light">{{ .L.T "globals.messages.emptyState" }}</td></tr>
+ {{ template "empty-state" 8 }}
{{- end }}
</tbody>
</table>