Skip to content

Commit 2e8677a

Browse files
committed
Fix a few visual issues on the top bar and sidebar
- add `data-bs-theme` to the body, accordingly to the current theme; - add `data-bs-theme=dark` the the top bar, because we always use some background color with white text, on this element; - change the default theme font-size to 15px. The previous theme used 14px (too small) and the original AdminLTE uses 16px (maybe too big); - use `bg-body-secondary` class on the body to match the previous gray background color on the content area; - use `bg-body-tertiary` class on the sidebar. It is still a dark color, but it will be changed according to the selected themes (when all themes are implemented); - adjust the top bar text color and border color to match the previous theme look; - adjust (or remove) the height on some elements on the top bar, to avoid breaking the layout; - move the old "logo" element to the sidebar (`.sidebar-brand` element); - use CSS to show a smaller "Pi-hole" text logo in the collapse sidebar; - adjust the collapsed sidebar layout, adding `.nav-badge` class to the every badge on the sidebar; - remove the outdated `pull-left` class; - remove other outdated CSS rules; Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
1 parent 7fb27b1 commit 2e8677a

5 files changed

Lines changed: 55 additions & 69 deletions

File tree

scripts/lua/header.lp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ hostname = sanitize_hostname(hostname)
6262
-- Variable to check if user is already authenticated
6363
is_authenticated = mg.request_info.is_authenticated
6464

65-
local bs_theme = theme.dark and 'dark' or 'light'
65+
bs_theme = theme.dark and 'dark' or 'light'
6666
if theme.name == 'default-auto' then
6767
bs_theme = 'auto'
6868
elseif theme.name == 'default-light' then

scripts/lua/header_authenticated.lp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mg.include('header.lp','r')
2727
<script src="<?=pihole.fileversion('vendor/waitMe-js/modernized-waitme-min.js')?>"></script>
2828
<script src="<?=pihole.fileversion('scripts/js/logout.js')?>"></script>
2929
</head>
30-
<body class="<?=theme.name?> hold-transition sidebar-mini sidebar-expand-lg <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in page-<?=pihole.format_path(scriptname)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>">
30+
<body class="<?=theme.name?> hold-transition sidebar-mini sidebar-expand-lg bg-body-secondary <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in page-<?=pihole.format_path(scriptname)?>" data-apiurl="<?=pihole.api_url()?>" data-webhome="<?=webhome?>" data-bs-theme="<?= bs_theme ?>">
3131
<noscript>
3232
<!-- JS Warning -->
3333
<div>
@@ -42,7 +42,7 @@ mg.include('header.lp','r')
4242
<!-- Send token to JS -->
4343
<div id="enableTimer" hidden></div>
4444
<div class="app-wrapper">
45-
<nav class="app-header navbar navbar-expand">
45+
<nav class="app-header navbar navbar-expand" data-bs-theme="dark">
4646
<div class="container-fluid">
4747
<!-- Sidebar toggle button + logo -->
4848
<ul class="navbar-nav">
@@ -52,14 +52,6 @@ mg.include('header.lp','r')
5252
<span class="warning-count hidden" id="top-warning-count"></span>
5353
</a>
5454
</li>
55-
<li class="nav-item">
56-
<a href="<?=webhome?>" class="nav-link logo">
57-
<!-- mini logo for sidebar mini 50x50 pixels -->
58-
<span class="logo-mini">P<strong>h</strong></span>
59-
<!-- logo for regular state and mobile devices -->
60-
<span class="logo-lg">Pi-<strong>hole</strong></span>
61-
</a>
62-
</li>
6355
</ul>
6456
<!-- Right navbar links -->
6557
<ul class="navbar-nav ms-auto">

scripts/lua/sidebar.lp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
* Please see LICENSE file for your rights under this license.
88
*/ ]]-- ?>
99
<!-- Left side column. contains the logo and sidebar -->
10-
<aside class="app-sidebar bg-dark shadow" data-bs-theme="dark">
10+
<aside class="app-sidebar bg-body-tertiary shadow" data-bs-theme="dark">
11+
<div class="sidebar-brand">
12+
<a href="<?=webhome?>" class="brand-link">
13+
<span class="brand-text fw-light">Pi-<strong>hole</strong></span>
14+
</a>
15+
</div>
1116
<div class="sidebar-wrapper">
1217
<!-- Sidebar user panel -->
1318
<div class="user-panel">
14-
<div class="pull-left image">
19+
<div class="image">
1520
<img class="logo-img" src="<?=webhome?>img/logo.svg" alt="Pi-hole logo" width="60" height="87">
1621
</div>
17-
<div class="pull-left info">
22+
<div class="info">
1823
<p>Status</p>
1924
<span id="status"></span><br>
2025
<span id="query_frequency"></span><br>
@@ -45,33 +50,37 @@
4550
<a href="<?=webhome?>groups" class="nav-link<? if scriptname == 'groups' then ?> active<? end ?>">
4651
<i class="nav-icon fa fa-fw fa-user-friends"></i>
4752
<p>Groups
48-
<span class="badge text-bg-primary float-end" id="num_groups" title="Number of enabled groups"></span>
53+
<span class="nav-badge badge text-bg-primary float-end" id="num_groups" title="Number of enabled groups"></span>
4954
</p>
5055
</a>
5156
</li>
5257
<li class="nav-item">
5358
<a href="<?=webhome?>groups/clients" class="nav-link<? if scriptname == 'groups/clients' then ?> active<? end ?>">
5459
<i class="nav-icon fa fa-fw fa-laptop"></i>
5560
<p>Clients
56-
<span class="badge text-bg-primary float-end" id="num_clients" title="Number of defined clients"></span>
61+
<span class="nav-badge badge text-bg-primary float-end" id="num_clients" title="Number of defined clients"></span>
5762
</p>
5863
</a>
5964
</li>
6065
<li class="nav-item">
6166
<a href="<?=webhome?>groups/domains" class="nav-link<? if scriptname == 'groups/domains' then ?> active<? end ?>">
6267
<i class="nav-icon fa fa-fw fa-list"></i>
6368
<p>Domains
64-
<span class="badge text-bg-danger float-end" id="num_denied" title="Number of enabled deny rules (domains and regex)"></span>
65-
<span class="badge text-bg-success float-end me-1" id="num_allowed" title="Number of enabled allow rules (domains and regex)"></span>
69+
<span class="nav-badge">
70+
<span class="badge text-bg-danger float-end" id="num_denied" title="Number of enabled deny rules (domains and regex)"></span>
71+
<span class="badge text-bg-success float-end me-1" id="num_allowed" title="Number of enabled allow rules (domains and regex)"></span>
72+
</span>
6673
</p>
6774
</a>
6875
</li>
6976
<li class="nav-item">
7077
<a href="<?=webhome?>groups/lists" class="nav-link<? if scriptname == 'groups/lists' then ?> active<? end ?>">
7178
<i class="nav-icon fa fa-fw fa-shield-alt"></i>
7279
<p>Lists
73-
<span class="badge text-bg-primary float-end" id="num_lists" title="Number of subscribed and enabled lists"></span>
74-
<span class="badge text-bg-warning float-end me-1" id="num_gravity" title="Total number of domains subscribed by your Pi-hole"></span>
80+
<span class="nav-badge">
81+
<span class="badge text-bg-primary float-end" id="num_lists" title="Number of subscribed and enabled lists"></span>
82+
<span class="badge text-bg-warning float-end me-1" id="num_gravity" title="Total number of domains subscribed by your Pi-hole"></span>
83+
</span>
7584
</p>
7685
</a>
7786
</li>

style/pi-hole.css

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
--blocked-color: #b00000;
1818
--cached-color: #9be;
1919
--other-color: #908878;
20+
21+
/* AdminLTE root variables */
22+
--bs-body-font-size: 15px;
23+
}
24+
25+
/* AdminLTE Color variables */
26+
.navbar[data-bs-theme="dark"] {
27+
--bs-navbar-color: rgb(255, 255, 255);
28+
--bs-border-color: var(--bs-gray-300);
2029
}
2130

2231
/* Dashboard graphic bars */
@@ -41,7 +50,7 @@
4150
margin: 0 auto;
4251
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
4352
position: relative;
44-
background-color: var(--bs-body-bg);
53+
background-color: var(--bs-secondary-bg);
4554
}
4655

4756
/* Bootstrap 5 dropped the `.hidden` utility that Bootstrap 3 (and AdminLTE 2)
@@ -109,17 +118,31 @@
109118
color: var(--bs-secondary-color);
110119
}
111120

112-
/* AdminLTE 4 no longer swaps the mini/full logo in the header when the sidebar
113-
is collapsed, so the full "Pi-hole" wordmark stays and wraps in the narrow
114-
header. Show the compact "Ph" mark while collapsed instead. */
115-
.logo-mini {
116-
display: none;
121+
/* AdminLTE 4 moved the logo to the sidebar (.sidebar-brand class).
122+
By default, AdminLTE expects an image and a text for the logo, but we only use
123+
"Pi-hole" text as logo.
124+
AdminLTE 4 automatically hides the text when the sidebar is collapsed, rsulting
125+
in an empty brand.
126+
To avoid this issue, we use ::before and ::after pseudo elements to show a
127+
smaller text, so the full "Pi-hole" wordmark is always shown. */
128+
.sidebar-brand .brand-text {
129+
margin: 0;
130+
font-size: 1.35em;
117131
}
118-
.sidebar-collapse .app-header .logo-lg {
119-
display: none;
132+
.sidebar-collapse .sidebar-brand .brand-link::before {
133+
content: "Pi-";
134+
color: var(--lte-sidebar-menu-active-color);
135+
font-size: 15px;
120136
}
121-
.sidebar-collapse .app-header .logo-mini {
122-
display: inline;
137+
.sidebar-collapse .sidebar-brand .brand-link::after {
138+
content: "hole";
139+
color: var(--lte-sidebar-menu-active-color);
140+
font-size: 15px;
141+
font-weight: bold;
142+
}
143+
.sidebar-collapse .app-sidebar:hover .brand-link::before,
144+
.sidebar-collapse .app-sidebar:hover .brand-link::after {
145+
content: none;
123146
}
124147

125148
@keyframes Pulse {
@@ -568,40 +591,6 @@ tfoot.add-new-item > tr > th {
568591
padding: 0.25em 0.6em 0.35em;
569592
}
570593

571-
.sidebar-toggle-svg {
572-
position: relative;
573-
color: #fff;
574-
float: left;
575-
background-color: transparent;
576-
border: none;
577-
padding: 15px;
578-
width: 50px;
579-
text-align: center;
580-
}
581-
582-
.sidebar-toggle-svg:hover {
583-
color: #f6f6f6;
584-
background: #367fa9;
585-
}
586-
587-
/* AdminLTE 4 no longer ships a default mini/full logo swap for the header
588-
(that concept now only exists for the sidebar-brand), so we provide it. */
589-
.app-header .logo-mini {
590-
display: none;
591-
}
592-
593-
/* Hide the "Ph" and move the toggle to the left */
594-
.sidebar-mini.sidebar-collapse .app-header .logo {
595-
width: 0;
596-
position: absolute;
597-
}
598-
.sidebar-mini.sidebar-collapse .app-header .logo-mini {
599-
visibility: hidden;
600-
}
601-
.sidebar-mini.sidebar-collapse .app-header.navbar {
602-
margin-left: 0;
603-
}
604-
605594
.sidebar-menu > li.nav-header {
606595
color: transparent;
607596
padding: 5px;
@@ -1065,10 +1054,6 @@ li:not(.menu-open) .nav-treeview .warning-count {
10651054
flex: 1 0 auto;
10661055
}
10671056

1068-
.navbar-nav {
1069-
height: 50px;
1070-
}
1071-
10721057
.navbar-nav > .user-menu {
10731058
margin-left: 15px;
10741059
width: 50px;

style/themes/lcars.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ p.login-box-msg,
10181018
margin: 1px 0;
10191019
}
10201020

1021-
.user-panel .pull-left.image {
1021+
.user-panel .image {
10221022
margin-top: 20px;
10231023
}
10241024

0 commit comments

Comments
 (0)