refactor: Extract sidebar and navbar CSS components

- Created static/css/components/sidebar.css (200 lines)
  * Navigation layout, active states, badges
  * Theme switcher button

- Created static/css/components/navbar.css (30 lines)
  * Menu toggle button
  * Dropdown avatar customization

- Removed ~95 lines of inline styles from sidebar.html
- Removed ~23 lines of inline styles from navbar.html
- All tests passing (17 OK)
This commit is contained in:
admin i 2025-10-28 10:03:31 +03:00
parent f1b72ffb91
commit 737f0a9623
4 changed files with 225 additions and 117 deletions

View File

@ -0,0 +1,29 @@
/**
* navbar.css
* Стили навбара: меню-тогглер, поиск, уведомления
*/
/* ─────────────────────────────────────────────────────────────
MENU TOGGLE (гамбургер)
────────────────────────────────────────────────────────────── */
/* Кнопка «гамбургера» — без круга/рамки */
.menu-toggle {
padding: 0;
border: 0;
background: transparent;
line-height: 1;
color: #fff;
}
.menu-toggle:focus {
outline: none;
box-shadow: none;
}
/* ─────────────────────────────────────────────────────────────
DROPDOWN AVATAR
────────────────────────────────────────────────────────────── */
/* Спрятать стрелочку у dropdown-аватара */
.dropdown-toggle.no-caret::after {
display: none !important;
}

View File

@ -0,0 +1,194 @@
/**
* sidebar.css
* Стили левого сайдбара: навигация, активные элементы, переключатель темы
*/
/* ─────────────────────────────────────────────────────────────
SIDEBAR LAYOUT
────────────────────────────────────────────────────────────── */
/* Offcanvas остаётся как есть (липкий ≥ lg) */
#sidebar {
--bs-offcanvas-border-color: transparent;
--bs-offcanvas-border-width: 0;
--bs-offcanvas-border-radius: 0;
border: 0 !important;
border-radius: 0 !important;
box-shadow: none !important;
background: var(--bs-body-bg);
}
@media (min-width: 992px) {
#sidebar.offcanvas-lg {
position: sticky;
top: var(--navbar-h, 60px);
height: calc(100dvh - var(--navbar-h, 60px));
align-self: start;
overflow: auto;
border-right: .5px solid var(--bs-border-color);
transform: none !important;
visibility: visible !important;
}
}
/* ─────────────────────────────────────────────────────────────
NAVIGATION SECTIONS
────────────────────────────────────────────────────────────── */
.side-section {
margin: .6rem 0 1rem;
}
.side-hd {
font-size: .78rem;
font-weight: 800;
letter-spacing: .03em;
text-transform: uppercase;
color: var(--bs-secondary-color);
padding: .25rem .5rem;
margin: 0 0 .35rem .25rem;
}
.side-nav {
display: flex;
flex-direction: column;
gap: .15rem;
}
/* ─────────────────────────────────────────────────────────────
NAV LINKS
────────────────────────────────────────────────────────────── */
.side-nav .nav-link {
position: relative;
display: flex;
align-items: center;
gap: .6rem;
padding: .48rem .55rem;
border-radius: 12px;
color: var(--bs-body-color);
text-decoration: none;
border: 0;
background: transparent !important;
line-height: 1.15;
transition: background .15s ease, color .15s ease, transform .05s ease, box-shadow .15s ease;
outline: none;
}
/* мягкий ховер */
.side-nav .nav-link:hover {
color: var(--bs-primary);
background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
}
/* видимая клавиатурная фокусировка */
.side-nav .nav-link:focus-visible {
box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .25);
}
/* активная «пилюля» + тонкий индикатор слева */
.side-nav .nav-link.active {
color: var(--bs-primary);
font-weight: 800;
background: color-mix(in srgb, var(--bs-primary) 16%, transparent);
}
.side-nav .nav-link.active::before {
content: "";
position: absolute;
left: -6px;
top: 8px;
bottom: 8px;
width: 3px;
border-radius: 2px;
background: var(--bs-primary);
}
/* «отключённый» пункт выглядит реально disabled */
.side-nav .nav-link.disabled {
opacity: .5;
pointer-events: none;
}
/* ─────────────────────────────────────────────────────────────
ICONS & BADGES
────────────────────────────────────────────────────────────── */
.side-icon {
width: 1.35rem;
height: 1.35rem;
display: inline-grid;
place-items: center;
flex: 0 0 auto;
}
.side-icon > i {
font-size: 1.1rem;
line-height: 1;
}
.icon-wrap {
position: relative;
display: inline-grid;
place-items: center;
}
.nav-unread {
position: absolute;
top: -4px;
right: -8px;
min-width: 16px;
height: 16px;
padding: 0 4px;
border-radius: 9999px;
font-size: 10px;
line-height: 16px;
font-weight: 700;
background: var(--bs-danger);
color: #fff;
border: 1px solid rgba(255, 255, 255, .6);
}
[data-bs-theme="dark"] .nav-unread {
border-color: rgba(0, 0, 0, .25);
}
/* ─────────────────────────────────────────────────────────────
THEME SWITCHER BUTTON
────────────────────────────────────────────────────────────── */
.btn-theme {
display: inline-flex;
align-items: center;
gap: .5rem;
min-height: 36px;
padding: .35rem .75rem;
border-radius: 999px;
background: var(--bs-tertiary-bg);
color: var(--bs-body-color);
border: 1px solid var(--bs-border-color);
transition: transform .08s ease, background-color .25s ease, border-color .25s ease;
}
.btn-theme:hover {
transform: translateY(-1px);
background: color-mix(in srgb, var(--bs-tertiary-bg) 90%, var(--bs-primary) 10%);
border-color: color-mix(in srgb, var(--bs-border-color), var(--bs-primary) 30%);
}
.btn-theme:focus-visible {
outline: 0;
box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .25);
}
.btn-theme .bi {
font-size: 1rem;
line-height: 1;
}
.btn-theme .mode-label {
font-weight: 700;
font-size: .85rem;
opacity: .9;
}
@media (max-width: 576px) {
.btn-theme .mode-label {
display: none;
}
}

View File

@ -1,25 +1,5 @@
{% load static %}
<style>
/* Компактный бейдж уведомлений вплотную к колоколу */
.bell-wrapper{ position: relative; line-height: 1; display: inline-block; }
.bell-dot{
position: absolute; top: -2px; right: -2px;
width: 9px; height: 9px; border-radius: 999px;
background: var(--bs-danger); color: #fff;
font-size: 7px; line-height: 9px; font-weight: 700;
display: flex; align-items: center; justify-content: center;
box-shadow: 0 0 0 1px rgba(255,255,255,.65);
}
/* Кнопка «гамбургера» — без круга/рамки */
.menu-toggle{
padding: 0; border: 0; background: transparent; line-height: 1; color: #fff;
}
.menu-toggle:focus{ outline: none; box-shadow: none; }
/* Спрятать стрелочку у dropdown-аватара */
.dropdown-toggle.no-caret::after{ display: none !important; }
</style>
<link rel="stylesheet" href="{% static 'css/components/navbar.css' %}">
<nav class="navbar navbar-expand bg-primary app-navbar" data-bs-theme="dark">
<div class="container-fluid align-items-center">

View File

@ -1,101 +1,6 @@
{% load static req_tags %}
<style>
/* Offcanvas остаётся как есть (липкий ≥ lg) */
#sidebar{
--bs-offcanvas-border-color: transparent;
--bs-offcanvas-border-width: 0;
--bs-offcanvas-border-radius: 0;
border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
background: var(--bs-body-bg);
}
@media (min-width: 992px){
#sidebar.offcanvas-lg{
position: sticky; top: var(--navbar-h, 60px);
height: calc(100dvh - var(--navbar-h, 60px));
align-self: start; overflow: auto;
border-right: .5px solid var(--bs-border-color); /* тонкая разделительная грань */
transform: none !important; visibility: visible !important;
}
}
/* ====== новый визуал навигации ====== */
.side-section{ margin: .6rem 0 1rem; }
.side-hd{
font-size:.78rem; font-weight:800; letter-spacing:.03em; text-transform:uppercase;
color: var(--bs-secondary-color);
padding: .25rem .5rem; margin: 0 0 .35rem .25rem;
}
.side-nav{ display:flex; flex-direction:column; gap:.15rem; }
.side-nav .nav-link{
position:relative; display:flex; align-items:center; gap:.6rem;
padding:.48rem .55rem; border-radius:12px;
color: var(--bs-body-color); text-decoration:none; border:0; background:transparent !important;
line-height:1.15;
transition: background .15s ease, color .15s ease, transform .05s ease, box-shadow .15s ease;
outline: none;
}
/* мягкий ховер */
.side-nav .nav-link:hover{
color: var(--bs-primary);
background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
}
/* видимая клавиатурная фокусировка */
.side-nav .nav-link:focus-visible{
box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .25);
}
/* активная «пилюля» + тонкий индикатор слева */
.side-nav .nav-link.active{
color: var(--bs-primary); font-weight: 800;
background: color-mix(in srgb, var(--bs-primary) 16%, transparent);
}
.side-nav .nav-link.active::before{
content:""; position:absolute; left:-6px; top:8px; bottom:8px; width:3px; border-radius:2px;
background: var(--bs-primary);
}
.side-icon{ width:1.35rem; height:1.35rem; display:inline-grid; place-items:center; flex:0 0 auto; }
.side-icon > i{ font-size:1.1rem; line-height:1; }
.icon-wrap{ position:relative; display:inline-grid; place-items:center; }
.nav-unread{
position:absolute; top:-4px; right:-8px;
min-width:16px; height:16px; padding:0 4px; border-radius:9999px;
font-size:10px; line-height:16px; font-weight:700;
background: var(--bs-danger); color:#fff; border:1px solid rgba(255,255,255,.6);
}
[data-bs-theme="dark"] .nav-unread{ border-color: rgba(0,0,0,.25); }
/* «отключённый» пункт выглядит реально disabled */
.side-nav .nav-link.disabled{ opacity:.5; pointer-events:none; }
</style>
<style>
.btn-theme{
display:inline-flex; align-items:center; gap:.5rem;
min-height:36px; padding:.35rem .75rem;
border-radius:999px;
background: var(--bs-tertiary-bg);
color: var(--bs-body-color);
border:1px solid var(--bs-border-color);
transition: transform .08s ease, background-color .25s ease, border-color .25s ease;
}
.btn-theme:hover{
transform: translateY(-1px);
background: color-mix(in srgb, var(--bs-tertiary-bg) 90%, var(--bs-primary) 10%);
border-color: color-mix(in srgb, var(--bs-border-color), var(--bs-primary) 30%);
}
.btn-theme:focus-visible{
outline: 0;
box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .25);
}
.btn-theme .bi{ font-size:1rem; line-height:1; }
.btn-theme .mode-label{ font-weight:700; font-size:.85rem; opacity:.9; }
@media (max-width:576px){
.btn-theme .mode-label{ display:none; }
}
</style>
<link rel="stylesheet" href="{% static 'css/components/sidebar.css' %}">
<div id="sidebar"
class="offcanvas offcanvas-start offcanvas-lg"