Skip to content

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

Refactor stick header to only make sidebar sticky and profile dropdown scroll.

Kailash Nadhd0c5d373c3a8
diff --git a/static/admin/assets/css/style.css b/static/admin/assets/css/style.css
index bdd8be48..0ded159b 100644
--- a/static/admin/assets/css/style.css
+++ b/static/admin/assets/css/style.css
@@ -500,22 +500,29 @@ body[data-sidebar-layout] {
#app[data-sidebar-layout] {
grid-template-columns: 12rem minmax(0, var(--container-max));
+ grid-template-rows: 1fr;
column-gap: var(--space-10);
height: auto;
justify-content: center;
min-height: 100dvh;
padding-inline: var(--space-5);
+ > aside,
> main {
+ grid-row: 1;
+ }
+
+ > main {
+ padding-block-start: 0;
overflow-y: visible;
}
}
-nav[data-topnav] {
- background: transparent;
- border-bottom: 0;
+.main-bar {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
padding: var(--space-4) 0 var(--space-2);
- box-shadow: none;
button[data-sidebar-toggle] {
border: 0;
@@ -557,36 +564,8 @@ nav[data-topnav] {
width: auto;
}
- .branding {
- align-items: center;
- display: flex;
- gap: var(--space-2);
-
- img {
- max-height: 17px;
- }
- }
-
- .favicon {
+ .mobile-branding {
display: none;
- line-height: 1;
- }
-
- .logo {
- display: inline-block;
- }
-
- .hstack {
- gap: var(--space-3);
- }
-
- > .row {
- grid-template-columns: minmax(0, 1fr) auto;
-
- > .branding,
- > .hstack {
- grid-column: auto;
- }
}
.theme-switch {
@@ -608,9 +587,26 @@ aside[data-sidebar] {
background: transparent;
border-inline-end: 0;
box-shadow: none;
- height: calc(100dvh - 4.5rem);
+ height: 100dvh;
position: sticky;
- top: 4.5rem;
+ top: 0;
+
+ > .sidebar-branding {
+ display: flex;
+ align-items: center;
+ padding: var(--space-4) 0 var(--space-2);
+
+ a {
+ padding: 0;
+ background: transparent;
+ }
+
+ img {
+ display: block;
+ height: 17px;
+ width: auto;
+ }
+ }
> nav {
margin-block-start: var(--space-3);
@@ -640,9 +636,8 @@ aside[data-sidebar] {
}
main {
- padding-block-start: var(--space-8);
-
> .container {
+ padding-block-start: var(--space-8);
padding-inline: 0;
margin-bottom: var(--space-6);
}
@@ -1756,7 +1751,7 @@ section.users {
/* Responsive */
@media (max-width: 769px) {
- main {
+ main > .container {
padding-block-start: var(--space-6);
}
@@ -1772,10 +1767,12 @@ section.users {
}
}
- nav[data-topnav] {
+ .main-bar {
background: var(--background);
box-shadow: var(--shadow-medium);
height: var(--topnav-height);
+ min-height: 0;
+ justify-content: space-between;
inset-block-start: 0;
inset-inline: 0;
padding-block: 0;
@@ -1783,19 +1780,12 @@ section.users {
position: fixed;
z-index: 10;
- > .row {
+ .mobile-branding {
+ display: flex;
align-items: center;
- }
-
- .hstack {
gap: var(--space-2);
}
- .favicon {
- display: inline-block;
- }
-
- .logo,
.user-label {
display: none;
}
@@ -1810,6 +1800,10 @@ section.users {
max-width: calc(100vw - var(--space-4));
position: static;
+ > .sidebar-branding {
+ display: none;
+ }
+
> nav {
margin-block-start: 0;
padding: var(--space-3) var(--space-2);
diff --git a/static/admin/views/base.html b/static/admin/views/base.html
index a83a934e..5d4d535c 100644
--- a/static/admin/views/base.html
+++ b/static/admin/views/base.html
@@ -42,41 +42,10 @@
</head>
<body x-data="adminApp"{{ if .Data.Can "settings:get" }} data-error-events{{ end }}>
<div id="app" data-sidebar-layout>
- <nav data-topnav>
- <div class="row">
- <div class="col-4 branding">
- <button data-sidebar-toggle type="button" aria-label="Toggle sidebar menu" class="small">
- {{ Icon "menu" }}
- </button>
- <a href="{{ URI "/admin" }}" class="favicon"><img src="{{ URI "/admin/static/favicon.png" }}?v={{ .AssetVersion }}" alt="listmonk" /></a>
- <a href="{{ URI "/admin" }}" class="logo"><img src="{{ URI "/admin/static/logo.svg" }}?v={{ .AssetVersion }}" alt="listmonk" /></a>
- </div>
- <div class="col-8 justify-end hstack">
- {{ with .Data.Profile }}
- <ot-dropdown>
- <button popovertarget="user-menu" type="button" class="user-nav-button ghost small user-trigger">
- <span class="avatar">{{ template "avatar-icon" dict "Kind" "user" "Name" (or .Name .Username) "URL" .Avatar.String }}
- <span class="avatar-label user-label">{{ .Username }}</span></span>
- </button>
- <menu popover id="user-menu">
- <a href="{{ URI "/admin/user/profile" }}" role="menuitem" class="button ghost">{{ Icon "user" }} {{ $.L.T "users.profile" }}</a>
- <button type="button" role="menuitem" class="ghost" onclick="fetch('{{ URI "/api/logout" }}', { method: 'POST' }).then(() => { document.location.href = '{{ URI "/admin/login" }}'; })">
- {{ Icon "log-out" }} {{ $.L.T "users.logout" }}
- </button>
- <hr />
- <div class="theme-switch" role="group" aria-label="Theme">
- <button type="button" class="ghost small" title="{{ $.L.T "globals.terms.system" }}" @click="setTheme('auto')" :class="{ 'is-active': theme === 'auto' }" :aria-pressed="theme === 'auto'">{{ Icon "monitor" }}</button>
- <button type="button" class="ghost small" title="{{ $.L.T "users.themeLight" }}" @click="setTheme('light')" :class="{ 'is-active': theme === 'light' }" :aria-pressed="theme === 'light'">{{ Icon "sun" }}</button>
- <button type="button" class="ghost small" title="{{ $.L.T "users.themeDark" }}" @click="setTheme('dark')" :class="{ 'is-active': theme === 'dark' }" :aria-pressed="theme === 'dark'">{{ Icon "moon" }}</button>
- </div>
- </menu>
- </ot-dropdown>
- {{ end }}
- </div>
- </div>
- </nav>
-
<aside data-sidebar>
+ <header class="sidebar-branding">
+ <a href="{{ URI "/admin" }}"><img src="{{ URI "/admin/static/logo.svg" }}?v={{ .AssetVersion }}" alt="listmonk" /></a>
+ </header>
{{ template "admin-sidebar" . }}
<footer id="footer">
@@ -85,6 +54,34 @@
</aside>
<main>
+ <header class="main-bar">
+ <div class="mobile-branding">
+ <button data-sidebar-toggle type="button" aria-label="Toggle sidebar menu" class="small">
+ {{ Icon "menu" }}
+ </button>
+ <a href="{{ URI "/admin" }}"><img src="{{ URI "/admin/static/favicon.png" }}?v={{ .AssetVersion }}" alt="listmonk" /></a>
+ </div>
+ {{ with .Data.Profile }}
+ <ot-dropdown>
+ <button popovertarget="user-menu" type="button" class="user-nav-button ghost small user-trigger">
+ <span class="avatar">{{ template "avatar-icon" dict "Kind" "user" "Name" (or .Name .Username) "URL" .Avatar.String }}
+ <span class="avatar-label user-label">{{ .Username }}</span></span>
+ </button>
+ <menu popover id="user-menu">
+ <a href="{{ URI "/admin/user/profile" }}" role="menuitem" class="button ghost">{{ Icon "user" }} {{ $.L.T "users.profile" }}</a>
+ <button type="button" role="menuitem" class="ghost" onclick="fetch('{{ URI "/api/logout" }}', { method: 'POST' }).then(() => { document.location.href = '{{ URI "/admin/login" }}'; })">
+ {{ Icon "log-out" }} {{ $.L.T "users.logout" }}
+ </button>
+ <hr />
+ <div class="theme-switch" role="group" aria-label="Theme">
+ <button type="button" class="ghost small" title="{{ $.L.T "globals.terms.system" }}" @click="setTheme('auto')" :class="{ 'is-active': theme === 'auto' }" :aria-pressed="theme === 'auto'">{{ Icon "monitor" }}</button>
+ <button type="button" class="ghost small" title="{{ $.L.T "users.themeLight" }}" @click="setTheme('light')" :class="{ 'is-active': theme === 'light' }" :aria-pressed="theme === 'light'">{{ Icon "sun" }}</button>
+ <button type="button" class="ghost small" title="{{ $.L.T "users.themeDark" }}" @click="setTheme('dark')" :class="{ 'is-active': theme === 'dark' }" :aria-pressed="theme === 'dark'">{{ Icon "moon" }}</button>
+ </div>
+ </menu>
+ </ot-dropdown>
+ {{ end }}
+ </header>
<div class="container">
{{ template "admin-global-notices" . }}
{{ end }}
diff --git a/static/admin/views/template.html b/static/admin/views/template.html
index 31474c78..33b2772b 100644
--- a/static/admin/views/template.html
+++ b/static/admin/views/template.html
@@ -67,7 +67,8 @@
</fieldset>
- <section class="card">
+ <fieldset class="card">
+ <legend>{{ .L.T "campaigns.content" }}</legend>
<div class="editor-body">
<template x-if="form.type === 'campaign_visual'">
<visual-editor base="{{ URI "/admin/static/email-builder" }}" @editor-change="form.body = $event.detail.body; form.body_source = $event.detail.source"><textarea>{{ $t.BodySource.String }}</textarea></visual-editor>
@@ -83,7 +84,7 @@
</template>
<a href="https://listmonk.app/docs/templating" target="_blank" rel="noopener noreferrer">{{ Icon "link-2" }} {{ .L.T "globals.buttons.learnMore" }}</a>
</p>
- </section>
+ </fieldset>
<footer class="hstack justify-between mt-6">
<div class="hstack gap-1">
{{- if not $isNew }}