Mobile sidebar nav (burger, overlay, Esc), bigger bolder accordion arrow, text/arrow centering, nav active on both menus

This commit is contained in:
2026-10-02 22:52:58 +03:00
parent 476cb4d91a
commit 1c5c5651c7
11 changed files with 161 additions and 71 deletions

View File

@@ -194,52 +194,6 @@ p { margin-top: 0; }
.toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; } .toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stat-value { margin: 0.5rem 0 0; font-size: 1.875rem; font-weight: 600; } .stat-value { margin: 0.5rem 0 0; font-size: 1.875rem; font-weight: 600; }
.stat-title { font-size: 0.875rem; color: var(--c-text-muted); margin: 0; } .stat-title { font-size: 0.875rem; color: var(--c-text-muted); margin: 0; }
/* ---- Utilities: плоские классы поверх компонентов (в духе Bootstrap) ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.w-260 { width: 260px; }
.overflow-x-auto { overflow-x: auto; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--c-text-muted); }
.text-strong { font-weight: 600; color: var(--c-text); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-break { overflow-wrap: anywhere; }
.font-mono { font-family: monospace; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.opacity-30 { opacity: 0.3; }
.offscreen { position: fixed; top: -1000px; left: 0; }
/* Badges — «этикетки»: строгая рамка, разрядка капсом; только индикаторы статуса */ /* Badges — «этикетки»: строгая рамка, разрядка капсом; только индикаторы статуса */
.badge { .badge {
display: inline-flex; align-items: center; display: inline-flex; align-items: center;
@@ -535,7 +489,7 @@ dialog.modal.modal-lg .modal-body { max-height: 88vh; min-height: 62vh; }
background: none; cursor: pointer; color: var(--c-text-muted); background: none; cursor: pointer; color: var(--c-text-muted);
} }
.sub-toggle:hover { color: var(--c-text); } .sub-toggle:hover { color: var(--c-text); }
.sub-arrow .ico { width: 0.75rem; height: 0.75rem; } .sub-arrow .ico { width: 1rem; height: 1rem; }
.sub-arrow { transform: rotate(0deg); transition: transform 0.2s; } .sub-arrow { transform: rotate(0deg); transition: transform 0.2s; }
.sub-acc.collapsed .sub-arrow { transform: rotate(0deg); } .sub-acc.collapsed .sub-arrow { transform: rotate(0deg); }
.sub-acc:not(.collapsed) .sub-arrow { transform: rotate(180deg); } .sub-acc:not(.collapsed) .sub-arrow { transform: rotate(180deg); }
@@ -729,3 +683,74 @@ th.th-filterable { padding-bottom: 0.35rem; }
} }
.md-video-figure { margin: 1rem 0; text-align: center; } .md-video-figure { margin: 1rem 0; text-align: center; }
.md-video { width: 100%; max-width: 100%; border-radius: var(--radius); background: #000; } .md-video { width: 100%; max-width: 100%; border-radius: var(--radius); background: #000; }
/* ---- Utilities: плоские классы поверх компонентов (в духе Bootstrap) ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.w-260 { width: 260px; }
.overflow-x-auto { overflow-x: auto; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--c-text-muted); }
.text-strong { font-weight: 600; color: var(--c-text); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-break { overflow-wrap: anywhere; }
.font-mono { font-family: monospace; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.opacity-30 { opacity: 0.3; }
.offscreen { position: fixed; top: -1000px; left: 0; }
/* ---- Мобильное меню: бургер в хэдере, ссылки в выезжающем сайдбаре ---- */
.nav-burger { display: none; }
.mobile-nav { display: none; }
.mobile-nav-overlay { display: none; }
@media (max-width: 720px) {
.nav { display: none; }
.page-header .user { display: none; }
.nav-burger { display: inline-flex; }
.mobile-nav {
display: flex; flex-direction: column; gap: 1rem;
position: fixed; top: 0; left: 0; bottom: 0; width: 17rem; max-width: 86vw;
z-index: 120; background: var(--c-surface); border-right: 1px solid var(--c-border);
padding: 1rem; overflow-y: auto;
transform: translateX(-100%); transition: transform 0.2s;
}
.mobile-nav.open { transform: none; }
.mobile-nav-overlay { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(0, 0, 0, 0.45); }
.mobile-nav-head { display: flex; align-items: center; justify-content: space-between; }
.mobile-nav-links { display: flex; flex-direction: column; gap: 0.25rem; }
.mobile-nav-links .nav-link { padding: 0.5rem 0.25rem; font-size: 1rem; }
.mobile-nav-user { display: flex; flex-direction: column; gap: 0.75rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--c-border); }
}
html.nav-open, html.nav-open body { overflow: hidden; }

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" 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"/></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View File

@@ -84,17 +84,20 @@
/* Активный пункт меню */ /* Активный пункт меню */
function initNavActive() { function initNavActive() {
var path = window.location.pathname; var path = window.location.pathname;
var links = [].slice.call(document.querySelectorAll('#top-nav .nav-link')); var links = [].slice.call(document.querySelectorAll('#top-nav .nav-link, #mobile-nav .nav-link'));
var best = null; var bestHref = null;
var bestLen = -1; var bestLen = -1;
links.forEach(function (a) { links.forEach(function (a) {
var href = a.getAttribute('href') || ''; var href = a.getAttribute('href') || '';
if (href === '/') return; if (href === '/') return;
if (path === href || path.indexOf(href + '/') === 0) { if (path === href || path.indexOf(href + '/') === 0) {
if (href.length > bestLen) { best = a; bestLen = href.length; } if (href.length > bestLen) { bestHref = href; bestLen = href.length; }
} }
}); });
if (best) best.classList.add('active'); if (!bestHref) return;
links.forEach(function (a) {
if (a.getAttribute('href') === bestHref) a.classList.add('active');
});
} }
/* Серверные уведомления: автоскрытие и кнопка закрытия */ /* Серверные уведомления: автоскрытие и кнопка закрытия */
@@ -238,6 +241,34 @@
else if (kind === 'comment-add' && typeof window.csRow === 'function') window.csRow('', 'neutral'); else if (kind === 'comment-add' && typeof window.csRow === 'function') window.csRow('', 'neutral');
}); });
/* Мобильное меню */
function openMobileNav() {
var n = document.getElementById('mobile-nav');
var o = document.getElementById('mobile-nav-overlay');
var b = document.getElementById('nav-burger');
if (n) n.classList.add('open');
if (o) o.hidden = false;
if (b) b.setAttribute('aria-expanded', 'true');
document.documentElement.classList.add('nav-open');
}
function closeMobileNav() {
var n = document.getElementById('mobile-nav');
var o = document.getElementById('mobile-nav-overlay');
var b = document.getElementById('nav-burger');
if (n) n.classList.remove('open');
if (o) o.hidden = true;
if (b) b.setAttribute('aria-expanded', 'false');
document.documentElement.classList.remove('nav-open');
}
document.addEventListener('click', function (e) {
if (e.target.closest('#nav-burger')) { openMobileNav(); return; }
if (e.target.closest('#mobile-nav-overlay') || e.target.closest('.mobile-nav-close')) { closeMobileNav(); return; }
if (e.target.closest('.mobile-nav a')) { closeMobileNav(); return; }
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') closeMobileNav();
});
/* Изменение полей: автоотправка форм (data-auto-submit), /* Изменение полей: автоотправка форм (data-auto-submit),
подтверждение занятия занятого варианта (select.js-variant-select) */ подтверждение занятия занятого варианта (select.js-variant-select) */
document.addEventListener('change', function (e) { document.addEventListener('change', function (e) {

View File

@@ -344,7 +344,7 @@
<div class="modal-body" id="assign-modal-body"></div> <div class="modal-body" id="assign-modal-body"></div>
</dialog> </dialog>
<script th:src="@{/js/admin-group.js(v='13')}" defer></script> <script th:src="@{/js/admin-group.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -196,7 +196,7 @@
</dialog> </dialog>
</th:block> </th:block>
</div> </div>
<script th:src="@{/js/admin-lab.js(v='13')}" defer></script> <script th:src="@{/js/admin-lab.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -15,17 +15,17 @@
</noscript> </noscript>
<link rel="icon" type="image/svg+xml" th:href="@{/favicon.svg(v='2')}"> <link rel="icon" type="image/svg+xml" th:href="@{/favicon.svg(v='2')}">
<!-- v=4: сброс кэша стилей после редизайна; при изменении css поднимать версию --> <!-- v=4: сброс кэша стилей после редизайна; при изменении css поднимать версию -->
<link rel="stylesheet" th:href="@{/css/app.css(v='13')}"> <link rel="stylesheet" th:href="@{/css/app.css(v='14')}">
<link id="hljs-light" rel="stylesheet" th:href="@{/css/hljs-github.css(v='13')}"> <link id="hljs-light" rel="stylesheet" th:href="@{/css/hljs-github.css(v='14')}">
<link id="hljs-dark" rel="stylesheet" th:href="@{/css/hljs-github-dark.css(v='13')}" disabled> <link id="hljs-dark" rel="stylesheet" th:href="@{/css/hljs-github-dark.css(v='14')}" disabled>
<script th:src="@{/js/highlight.min.js(v='13')}" defer></script> <script th:src="@{/js/highlight.min.js(v='14')}" defer></script>
<script th:src="@{/js/table-scroll.js(v='13')}" defer></script> <script th:src="@{/js/table-scroll.js(v='14')}" defer></script>
<script th:src="@{/js/tablekit.js(v='13')}" defer></script> <script th:src="@{/js/tablekit.js(v='14')}" defer></script>
<script th:src="@{/js/theme-init.js(v='13')}"></script> <script th:src="@{/js/theme-init.js(v='14')}"></script>
<script th:src="@{/js/app.js(v='13')}" defer></script> <script th:src="@{/js/app.js(v='14')}" defer></script>
<script th:src="@{/js/ui-state.js(v='13')}" defer></script> <script th:src="@{/js/ui-state.js(v='14')}" defer></script>
<script th:src="@{/js/md-content.js(v='13')}" defer></script> <script th:src="@{/js/md-content.js(v='14')}" defer></script>
<script th:src="@{/js/submit-guard.js(v='13')}" defer></script> <script th:src="@{/js/submit-guard.js(v='14')}" defer></script>
</head> </head>
<body> <body>
<div class="page"> <div class="page">
@@ -41,6 +41,10 @@
<a th:href="@{/change-password}" class="nav-link">Смена пароля</a> <a th:href="@{/change-password}" class="nav-link">Смена пароля</a>
</th:block> </th:block>
</nav> </nav>
<button type="button" id="nav-burger" class="btn btn-secondary btn-sm nav-burger"
aria-label="Меню" aria-expanded="false">
<span class="ico ico-menu"></span>
</button>
<div class="user"> <div class="user">
<th:block th:if="${currentUser != null}"> <th:block th:if="${currentUser != null}">
<a th:href="@{/admin}" th:if="${currentUser.admin}" class="nav-user" th:text="${currentUser.name}" title="Личный кабинет">—</a> <a th:href="@{/admin}" th:if="${currentUser.admin}" class="nav-user" th:text="${currentUser.name}" title="Личный кабинет">—</a>
@@ -58,6 +62,36 @@
</div> </div>
</div> </div>
</header> </header>
<div id="mobile-nav-overlay" class="mobile-nav-overlay" hidden></div>
<nav id="mobile-nav" class="mobile-nav" aria-label="Меню">
<div class="mobile-nav-head">
<span class="logo">LMS<b>.</b></span>
<button class="modal-close mobile-nav-close" type="button" aria-label="Закрыть меню">✕</button>
</div>
<div class="mobile-nav-links nav">
<th:block th:if="${currentUser != null}">
<a th:if="${currentUser.admin}" th:href="@{/admin/groups}" class="nav-link">Группы</a>
<a th:if="${currentUser.admin}" th:href="@{/admin/users}" class="nav-link">Пользователи</a>
<a th:if="${currentUser.admin}" th:href="@{/admin/labs}" class="nav-link">Лабораторные</a>
<a th:unless="${currentUser.admin}" th:href="@{/student/labs}" class="nav-link">Лабораторные</a>
<a th:href="@{/change-password}" class="nav-link">Смена пароля</a>
</th:block>
</div>
<div class="mobile-nav-user">
<th:block th:if="${currentUser != null}">
<a th:href="@{/admin}" th:if="${currentUser.admin}" class="nav-user" th:text="${currentUser.name}" title="Личный кабинет">—</a>
<a th:href="@{/student}" th:unless="${currentUser.admin}" class="nav-user" th:text="${currentUser.name}" title="Личный кабинет">—</a>
</th:block>
<button type="button" class="btn btn-secondary btn-sm theme-btn" aria-label="Сменить тему" title="Сменить тему">
<span class="ico ico-theme"></span>
</button>
<form th:if="${currentUser != null}" th:action="@{/logout}" method="post">
<button class="btn btn-secondary btn-sm" type="submit">Выйти</button>
<input type="hidden" name="_csrf" th:value="${csrfToken}">
</form>
</div>
</nav>
<main class="page-main"> <main class="page-main">
<th:block th:replace="${content}" /> <th:block th:replace="${content}" />
</main> </main>

View File

@@ -124,7 +124,7 @@
</div> </div>
<script th:src="@{/js/mdeditor.js(v='13')}" defer></script> <script th:src="@{/js/mdeditor.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -183,7 +183,7 @@
</div> </div>
</dialog> </dialog>
<script th:src="@{/js/content-sort.js(v='13')}" defer></script> <script th:src="@{/js/content-sort.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -232,8 +232,8 @@
</div> </div>
</dialog> </dialog>
<script th:src="@{/js/mdeditor.js(v='13')}" defer></script> <script th:src="@{/js/mdeditor.js(v='14')}" defer></script>
<script th:src="@{/js/content-sort.js(v='13')}" defer></script> <script th:src="@{/js/content-sort.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -143,7 +143,7 @@
</div> </div>
</dialog> </dialog>
<script th:src="@{/js/content-sort.js(v='13')}" defer></script> <script th:src="@{/js/content-sort.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -107,7 +107,7 @@
<p class="text-sm text-muted">Ожидайте преподавателя с проверкой.</p> <p class="text-sm text-muted">Ожидайте преподавателя с проверкой.</p>
</div> </div>
</div> </div>
<script th:src="@{/js/defense-timer.js(v='13')}" defer></script> <script th:src="@{/js/defense-timer.js(v='14')}" defer></script>
</div> </div>
</body> </body>
</html> </html>