From cf2373f4a961834c2ba428a5c26cc2c1024e32d9 Mon Sep 17 00:00:00 2001 From: Server <10.9.8.250@reg.snw.su> Date: Sun, 9 Aug 2026 23:47:39 +0000 Subject: [PATCH] Compact desktop layout and navigation styling --- README.md | 4 +-- docslib/templates/client.css | 68 ++++++++++++++++++++---------------- docslib/templates/client.js | 17 ++++----- docslib/templates/index.html | 37 +++++++++++--------- tests/test_server.py | 10 +++++- 5 files changed, 79 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index e3536eb..0c33706 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ SharedDocsLib — небольшой Python-фреймворк для докум - `index.zip`, содержащий только `index.html`; - live-preview с перекомпиляцией изменившегося Python-модуля. -UI не содержит языко-зависимых служебных подписей. Базовый шрифт — `system-ui 16px`, а UTF-8-пиктограммы используют Arial. AMOLED-тема включена по умолчанию и сохраняется локально после переключения. +UI не содержит языко-зависимых служебных подписей. Базовый шрифт — `system-ui 16px`; служебные UTF-8-пиктограммы используют Arial, а навигационные стрелки остаются в `system-ui`. AMOLED-тема включена по умолчанию и сохраняется локально после переключения. -На десктопе слева постоянно видны header-кнопки и дерево страниц. Поисковый placeholder печатает первые слова случайных названий, а при вводе поле раскрывает ранжированные результаты вниз. Кнопка `⟳` вращается во время проверки manifest; при наведении она заменяет поиск и тему, показывая ISO-дату и короткий `revision`, а при нажатии синхронизирует manifest и перезагружает страницу. +На десктопе компактный header содержит полное название документации и search/theme/refresh, а слева постоянно видны header-кнопки и дерево страниц. Поисковый placeholder медленно печатает первые слова случайного названия, добавляет троеточие только в конце и сохраняет готовый текст 10 секунд; при вводе поле раскрывает ранжированные результаты вниз. Кнопка `⟳` вращается во время проверки manifest; при наведении она заменяет поиск и тему, показывая ISO-дату и короткий `revision`, а при нажатии синхронизирует manifest и перезагружает страницу. На мобильных устройствах используется viewport `100dvh` и нижний dock. Кнопка `☰` заменяет содержимое страницы копией desktop-sidebar. Ввод в нижний поиск заменяет содержимое результатами, расположенными снизу вверх по релевантности. Тема и обновление на мобильном скрыты. diff --git a/docslib/templates/client.css b/docslib/templates/client.css index ba280ad..f201762 100644 --- a/docslib/templates/client.css +++ b/docslib/templates/client.css @@ -8,6 +8,7 @@ --muted: #6d6d6d; --faint: #9a9a9a; --border: #c9c9c9; + --tree-line: #c5c5c5; --shadow: 0 24px 70px rgba(0, 0, 0, .16); color-scheme: light; } @@ -22,6 +23,7 @@ --muted: #a5a5a5; --faint: #747474; --border: #333333; + --tree-line: #2c2c2c; --shadow: 0 28px 80px rgba(0, 0, 0, .72); color-scheme: dark; } @@ -34,61 +36,66 @@ body { margin: 0; color: var(--text); background: var(--shell); font-family: sys button, input { font: inherit; } button, a { -webkit-tap-highlight-color: transparent; } button { color: inherit; } -.glyph-button, .refresh-glyph, .nav-arrow { font-family: Arial, sans-serif; } +.glyph-button, .refresh-glyph { font-family: Arial, sans-serif; } +.nav-arrow { font-family: system-ui; } -.app-shell { display: grid; width: 100%; height: 100%; grid-template-columns: clamp(280px, 20vw, 370px) minmax(0, 1fr); overflow: hidden; background: var(--shell); } -.desktop-sidebar { display: flex; min-width: 0; height: 100%; flex-direction: column; overflow: hidden; padding: 40px 34px 26px; background: var(--shell); } -.site-title { overflow: hidden; flex: 0 0 auto; margin: 0 0 30px; font-size: clamp(1.8rem, 2.35vw, 3rem); font-weight: 400; line-height: 1.08; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; } -.sidebar-header-buttons { display: flex; flex: 0 0 auto; flex-direction: column; gap: 6px; margin-bottom: 42px; } -.header-link { display: block; width: 100%; padding: 8px 15px; border: 1px solid transparent; border-radius: 24px; color: var(--text); background: transparent; text-decoration: none; line-height: 1.25; transition: background .16s ease, border-color .16s ease; } +.app-shell { --desktop-sidebar-width: clamp(230px, 18vw, 310px); display: flex; width: 100%; height: 100%; flex-direction: column; overflow: hidden; background: var(--shell); } +.desktop-header { position: relative; z-index: 20; display: grid; min-height: 76px; flex: 0 0 76px; grid-template-columns: minmax(260px, 1fr) auto; align-items: center; gap: 18px; padding: 12px 20px; background: var(--shell); } +.desktop-title { overflow: hidden; margin: 0; font-size: 1.55rem; font-weight: 450; line-height: 1.1; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; } +.header-link { display: block; width: 100%; padding: 6px 12px; border: 1px solid transparent; border-radius: 20px; color: var(--text); background: transparent; text-decoration: none; line-height: 1.2; transition: background .16s ease, border-color .16s ease; } .header-link:hover { background: var(--control); } .header-link.active { color: var(--text); background: var(--active); } .header-link:not(.active):not(:hover) { border-color: var(--border); } -.sidebar-header-buttons .header-link:not(.active):first-child { border-color: transparent; } + +.desktop-main { display: flex; min-width: 0; min-height: 0; flex: 1; overflow: hidden; } +.desktop-sidebar { display: flex; width: var(--desktop-sidebar-width); min-width: 0; height: 100%; flex: 0 0 var(--desktop-sidebar-width); flex-direction: column; overflow: hidden; padding: 20px 18px 22px; background: var(--shell); } +.sidebar-header-buttons { display: flex; flex: 0 0 auto; flex-direction: column; gap: 4px; margin-bottom: 24px; } .page-tree { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; } -.desktop-sidebar > .page-tree { flex: 1; padding: 0 2px 34px; } +.desktop-sidebar > .page-tree { flex: 1; padding: 0 2px 24px; } .tree-group { margin: 2px 0; } -.tree-children { margin-left: 19px; padding-left: 12px; border-left: 1px solid var(--muted); } -.tree-link { display: flex; width: 100%; min-height: 36px; align-items: baseline; gap: 5px; padding: 6px 13px; border: 0; border-radius: 22px; color: var(--text); background: transparent; cursor: pointer; text-align: left; transition: background .15s ease; } +.tree-children { margin-left: 17px; padding-left: 10px; border-left: 1px solid var(--tree-line); } +.tree-link { display: flex; width: 100%; min-height: 32px; align-items: baseline; gap: 5px; padding: 4px 10px; border: 0; border-radius: 18px; color: var(--text); background: transparent; cursor: pointer; text-align: left; transition: background .15s ease, color .15s ease; } .tree-link:hover { background: var(--control); } .tree-link.active { background: var(--active); } +.sidebar-header-buttons .header-link.active, .desktop-sidebar .tree-link.active { color: #050505; background: #f0f0f0; } +.desktop-sidebar .tree-link.active .tree-number { color: #555; } .tree-number { flex: 0 0 auto; color: var(--muted); } .tree-title { min-width: 0; overflow-wrap: anywhere; } .workspace { display: flex; min-width: 0; height: 100%; min-height: 0; flex-direction: column; overflow: hidden; } -.desktop-toolbar { position: relative; z-index: 20; display: flex; min-height: 128px; flex: 0 0 128px; align-items: center; justify-content: flex-end; gap: 18px; padding: 24px 28px; background: var(--shell); } -.desktop-search-shell { position: relative; width: min(660px, 52vw); max-width: min(660px, 52vw); flex: 0 1 min(660px, 52vw); transition: max-width .24s ease, opacity .16s ease, transform .24s ease; } -.search-control { display: flex; width: 100%; height: 64px; align-items: center; border-radius: 34px; background: var(--control); } -.search-control input, .mobile-search-control input { min-width: 0; flex: 1; height: 100%; padding: 0 10px 0 28px; border: 0; outline: 0; color: var(--text); background: transparent; appearance: none; } +.desktop-toolbar { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 8px; } +.desktop-search-shell { position: relative; width: min(320px, 30vw); max-width: min(320px, 30vw); flex: 0 1 min(320px, 30vw); transition: max-width .24s ease, opacity .16s ease, transform .24s ease; } +.search-control { display: flex; width: 100%; height: 44px; align-items: center; border-radius: 24px; background: var(--control); } +.search-control input, .mobile-search-control input { min-width: 0; flex: 1; height: 100%; padding: 0 8px 0 18px; border: 0; outline: 0; color: var(--text); background: transparent; appearance: none; } .search-control input::placeholder, .mobile-search-control input::placeholder { color: var(--faint); opacity: 1; } .search-control input::-webkit-search-cancel-button, .mobile-search-control input::-webkit-search-cancel-button { display: none; } .glyph-button { display: grid; place-items: center; border: 0; cursor: pointer; } -.search-glyph { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 50%; color: var(--text); background: color-mix(in srgb, var(--control), var(--text) 8%); font-size: 2rem; } -.desktop-search-results { position: absolute; inset: 74px 0 auto; display: flex; max-height: min(540px, calc(100dvh - 154px)); flex-direction: column; gap: 4px; overflow: auto; padding: 10px; border-radius: 28px; background: var(--elevated); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(-10px) scale(.985); transform-origin: top; transition: opacity .16s ease, transform .18s ease; } +.search-glyph { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; color: var(--text); background: color-mix(in srgb, var(--control), var(--text) 8%); font-size: 1.45rem; } +.desktop-search-results { position: absolute; inset: 50px 0 auto; display: flex; max-height: min(460px, calc(100dvh - 98px)); flex-direction: column; gap: 3px; overflow: auto; padding: 8px; border-radius: 20px; background: var(--elevated); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(-8px) scale(.985); transform-origin: top; transition: opacity .16s ease, transform .18s ease; } .desktop-search-shell.open .desktop-search-results { opacity: 1; pointer-events: auto; transform: none; } -.search-result { display: block; width: 100%; padding: 13px 18px; border: 0; border-radius: 22px; color: var(--text); background: transparent; cursor: pointer; text-align: left; } +.search-result { display: block; width: 100%; padding: 10px 13px; border: 0; border-radius: 15px; color: var(--text); background: transparent; cursor: pointer; text-align: left; } .search-result:hover, .search-result:focus-visible { outline: 0; background: var(--active); } -.search-result strong { display: block; overflow: hidden; font-size: 1.08rem; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; } +.search-result strong { display: block; overflow: hidden; font-size: 1rem; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; } .search-result span { display: block; overflow: hidden; margin-top: 1px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; } -.theme-button { width: 64px; height: 64px; max-width: 64px; flex: 0 0 64px; border-radius: 50%; color: var(--text); background: var(--control); font-size: 1.8rem; transition: max-width .24s ease, opacity .16s ease, transform .24s ease; } +.theme-button { width: 44px; height: 44px; max-width: 44px; flex: 0 0 44px; border-radius: 50%; color: var(--text); background: var(--control); font-size: 1.3rem; transition: max-width .24s ease, opacity .16s ease, transform .24s ease; } .theme-button:hover { background: var(--active); } -.refresh-button { display: flex; width: 64px; max-width: min(430px, 44vw); height: 64px; flex: 0 0 auto; align-items: center; justify-content: flex-start; gap: 14px; overflow: hidden; padding: 0; border: 0; border-radius: 34px; color: var(--text); background: var(--control); cursor: pointer; transition: width .26s ease, background .16s ease; } +.refresh-button { display: flex; width: 44px; max-width: min(320px, 38vw); height: 44px; flex: 0 0 auto; align-items: center; justify-content: flex-start; gap: 8px; overflow: hidden; padding: 0; border: 0; border-radius: 24px; color: var(--text); background: var(--control); cursor: pointer; transition: width .26s ease, background .16s ease; } .refresh-button:hover { background: var(--active); } -.refresh-glyph { display: grid; width: 64px; height: 64px; flex: 0 0 64px; place-items: center; font-size: 2rem; } +.refresh-glyph { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; font-size: 1.45rem; } .refresh-button.loading .refresh-glyph { animation: refresh-spin .8s linear infinite; } -.manifest-identity { overflow: hidden; padding-right: 24px; color: var(--text); font-size: .82rem; white-space: nowrap; opacity: 0; transition: opacity .12s ease .03s; } +.manifest-identity { overflow: hidden; padding-right: 15px; color: var(--text); font-size: .75rem; white-space: nowrap; opacity: 0; transition: opacity .12s ease .03s; } .desktop-toolbar.refresh-expanded .desktop-search-shell { max-width: 0; opacity: 0; pointer-events: none; transform: translateX(18px); } .desktop-toolbar.refresh-expanded .theme-button { max-width: 0; opacity: 0; pointer-events: none; transform: scale(.72); } -.desktop-toolbar.refresh-expanded .refresh-button { width: min(430px, 64vw); } +.desktop-toolbar.refresh-expanded .refresh-button { width: min(320px, 52vw); } .desktop-toolbar.refresh-expanded .manifest-identity { opacity: 1; } @keyframes refresh-spin { to { transform: rotate(360deg); } } -.page-surface { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; border-radius: 54px 0 0; background: var(--surface); scroll-behavior: smooth; -webkit-overflow-scrolling: touch; } -.content { width: min(1120px, calc(100% - 120px)); min-height: calc(100dvh - 330px); margin: 0 auto; padding: 68px 0 64px; outline: none; } +.page-surface { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; border-radius: 36px 0 0; background: var(--surface); scroll-behavior: smooth; -webkit-overflow-scrolling: touch; } +.content { width: min(1120px, calc(100% - 72px)); min-height: calc(100dvh - 240px); margin: 0 auto; padding: 42px 0 44px; outline: none; } .content > :first-child { margin-top: 0; } -.content h1 { margin: 0 0 2rem; font-size: clamp(2.35rem, 3.1vw, 4rem); font-weight: 400; line-height: 1.08; letter-spacing: -.035em; } +.content h1 { margin: 0 0 1.5rem; font-size: clamp(2.15rem, 2.7vw, 3.35rem); font-weight: 400; line-height: 1.08; letter-spacing: -.035em; } .content h2 { margin: 2.5rem 0 .9rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); font-size: 1.65rem; font-weight: 500; } .content h3 { margin: 1.9rem 0 .55rem; font-size: 1.25rem; font-weight: 550; } .content p { margin: .8rem 0 1.2rem; font-size: 1.08rem; } @@ -110,8 +117,8 @@ button { color: inherit; } .content table { width: 100%; border-collapse: collapse; } .content th, .content td { padding: 10px 13px; border: 1px solid var(--border); text-align: left; } .content th { background: var(--control); } -.page-navigation { display: flex; width: min(1120px, calc(100% - 120px)); gap: 14px; margin: 0 auto; padding: 0 0 64px; } -.nav-card { display: flex; min-height: 56px; align-items: center; gap: 10px; padding: 9px 20px; border: 0; border-radius: 30px; color: var(--text); background: var(--control); cursor: pointer; } +.page-navigation { display: flex; width: min(1120px, calc(100% - 72px)); gap: 10px; margin: 0 auto; padding: 0 0 42px; } +.nav-card { display: flex; min-height: 48px; align-items: center; gap: 8px; padding: 7px 16px; border: 0; border-radius: 26px; color: var(--text); background: var(--control); cursor: pointer; } .nav-card:hover:not(:disabled) { background: var(--active); } .nav-card:disabled { display: none; } .nav-card small { color: inherit; font-size: 1.3rem; } @@ -122,7 +129,8 @@ button { color: inherit; } @media (max-width: 820px) { .app-shell { display: block; } - .desktop-sidebar, .desktop-toolbar { display: none; } + .desktop-header, .desktop-sidebar { display: none; } + .desktop-main { display: block; width: 100%; height: 100%; } .workspace { width: 100%; height: 100%; } .page-surface { display: block; width: 100%; border-radius: 0; background: var(--shell); } .content { width: 100%; min-height: 0; padding: 52px 28px 28px; } @@ -165,7 +173,7 @@ button { color: inherit; } @media print { html, body { height: auto; max-height: none; overflow: visible; } .app-shell { display: block; } - .desktop-sidebar, .desktop-toolbar, .mobile-dock, .page-navigation { display: none; } + .desktop-header, .desktop-sidebar, .mobile-dock, .page-navigation { display: none; } .workspace, .page-surface { display: block; height: auto; overflow: visible; } .content { width: 100%; padding: 0; } } diff --git a/docslib/templates/client.js b/docslib/templates/client.js index 8862250..9c95573 100644 --- a/docslib/templates/client.js +++ b/docslib/templates/client.js @@ -330,8 +330,8 @@ return words.slice(0, Math.max(1, count)).join(" "); } - function applyPlaceholder(value) { - const display = value ? `${value}…` : ""; + function applyPlaceholder(value, complete = false) { + const display = value ? `${value}${complete ? "…" : ""}` : ""; elements.desktopSearchInput.placeholder = display; elements.mobileSearchInput.placeholder = display; } @@ -347,11 +347,12 @@ if (placeholderPhase === "typing") { placeholderIndex += 1; placeholderText = placeholderTarget.slice(0, placeholderIndex); - applyPlaceholder(placeholderText); + const complete = placeholderIndex >= placeholderTarget.length; + applyPlaceholder(placeholderText, complete); if (placeholderIndex >= placeholderTarget.length) { placeholderPhase = "waiting"; - placeholderTimer = setTimeout(placeholderTick, 1600); - } else placeholderTimer = setTimeout(placeholderTick, 75 + Math.random() * 65); + placeholderTimer = setTimeout(placeholderTick, 10000); + } else placeholderTimer = setTimeout(placeholderTick, 130 + Math.random() * 120); } else if (placeholderPhase === "waiting") { placeholderPhase = "erasing"; placeholderTimer = setTimeout(placeholderTick, 180); @@ -363,7 +364,7 @@ placeholderTarget = choosePlaceholder(); placeholderPhase = "typing"; placeholderTimer = setTimeout(placeholderTick, 420); - } else placeholderTimer = setTimeout(placeholderTick, 36); + } else placeholderTimer = setTimeout(placeholderTick, 55); } } @@ -374,10 +375,10 @@ placeholderIndex = 0; placeholderPhase = "typing"; if (reducedMotion.matches) { - applyPlaceholder(placeholderTarget); + applyPlaceholder(placeholderTarget, true); return; } - placeholderTimer = setTimeout(placeholderTick, 350); + placeholderTimer = setTimeout(placeholderTick, 500); } function applyTheme(theme) { diff --git a/docslib/templates/index.html b/docslib/templates/index.html index 9584a08..199b269 100644 --- a/docslib/templates/index.html +++ b/docslib/templates/index.html @@ -12,14 +12,9 @@
- - -
-
+
+

{{DOCSLIB_TITLE}}

+
@@ -32,7 +27,16 @@ -
+
+ + +
+ + +
@@ -42,14 +46,15 @@
-
-

{{DOCSLIB_TITLE}}

- - -
+
+

{{DOCSLIB_TITLE}}

+ + +
-
-
+
+
+
diff --git a/tests/test_server.py b/tests/test_server.py index ed143c7..5993a9d 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -76,13 +76,21 @@ def test_all_endpoints_and_self_contained_build(tmp_path): assert "overflow-y: auto" in html assert "elements.pageSurface.scrollTo" in html assert "font-family: system-ui; font-size: 16px" in html - assert ".glyph-button, .refresh-glyph, .nav-arrow { font-family: Arial" in html + assert ".glyph-button, .refresh-glyph { font-family: Arial" in html + assert ".nav-arrow { font-family: system-ui; }" in html assert "--shell: #000000" in html assert 'id="desktop-search-input"' in html + assert '
' in html + assert '