Add administration submenu and refine controls and toast states
This commit is contained in:
1 parent
cd821abb51
commit
aece8e59cd
125 files changed
+898
-57
No files matched your search
+18
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
Меню аккаунта содержит только Аккаунт, доступную по роли Панель управления, Сменить аккаунт и Выйти из SSO. Настройки и приложения доступны через навигацию личного кабинета.
|
||||
|
||||
Навигация Dock: выбранный пункт сохраняет цвет при наведении. Переход по меню сохраняет раскрытую панель и режим открытия (hover или закрепление); Escape, подложка и уход мыши из hover-меню закрывают её.
|
||||
Навигация Dock: выбранный пункт сохраняет цвет при наведении. «Администрирование» — disclosure-группа с SSH-консолью и логами. aria-expanded и aria-controls описывают её состояние; закрытые дети inert и aria-hidden. В узком Dock видна только иконка раздела. Переход на дочернюю страницу сохраняет раскрытие Dock и группы, повторный клик не пересоздаёт рабочую область. Enter/Space переключают группу, Right открывает и фокусирует первый пункт, Left закрывает, Up/Down перемещают фокус внутри группы. Escape сначала закрывает подменю, затем Dock; модифицированные стрелки сохраняют браузерное поведение. Переход по меню сохраняет раскрытую панель и режим открытия (hover или закрепление); Escape, подложка и уход мыши из hover-меню закрывают её.
|
||||
|
||||
Иконки: только icons/icons.js, SVG 24×24 со stroke 1.5 и круглыми окончаниями. В Dock ось значка совпадает с центром подложки и аватара; при раскрытии значок не сдвигается. Клавиатурный фокус внутри панели рисуется с inset 2px. Табличные checkbox центрируются по высоте строки; disabled-кнопки не получают hover-фон.
|
||||
|
||||
@@ -12,6 +12,23 @@
|
||||
|
||||
Рабочие области: SSH — xterm.js, black surface, resize, управляющие коды, history/completion, clipboard, поиск, fullscreen и Keyboard Lock с fallback. Перехват действует только в активном терминале; Ctrl+Shift+M возвращает фокус панели, выключенный ввод не перехватывает Tab. Log reader — текст/level/source-фильтры, пауза с очередью, follow, ограниченные окна строк, детали JSON, безопасное чтение файлов и экспорт. Контракт транспорта, ограничения браузера и cleanup описаны в patterns/WORKSPACES.md.
|
||||
|
||||
Поля: readonly остаётся фокусируемым и позволяет выделение/копирование, но не редактирование. Программный фокус #content не рисует рамку вокруг всей страницы. В sample-control-row зазор 12px и общая высота контролов; на мобильном они стоят друг под другом.
|
||||
|
||||
Choice pill: подписанные checkbox/radio помещаются внутрь label.choice-pill со span текста. Вся капсула кликабельна; native input сохраняет поведение и клавиатуру. Контрол и подпись центрированы, checked меняет фон/рамку/цвет, focus-visible обводит капсулу; минимальная высота 40px, на мобильном 44px. Табличные checkbox остаются компактными.
|
||||
|
||||
Тосты: createNotifier из toast.js, типы success/info/warning/error. Иконка, заголовок, текст, семантический акцент и закрытие. Таймеры: 4/5/8 секунд, ошибка без автоматического скрытия. Hover и фокус приостанавливают таймер. Повторный вызов заменяет активное уведомление. Error использует role=alert/assertive; остальные status/polite. Текст вставляется через textContent. Тост помещается в активный dialog и показывается в верхнем слое: затемнение не перекрывает его, закрытие доступно мышью и клавиатурой, фокус возвращается инициатору.
|
||||
|
||||
```js
|
||||
import { createNotifier } from "./components/toast.js";
|
||||
const notify = createNotifier(document.querySelector("#toast"), {
|
||||
t: (ru, en) => ru,
|
||||
});
|
||||
notify("Изменения сохранены", { type: "success" });
|
||||
notify("Проверьте соединение", { type: "warning", title: "Нет ответа" });
|
||||
notify("Операция завершилась ошибкой", { type: "error" });
|
||||
notify.dismiss();
|
||||
```
|
||||
|
||||
Исполняемые образцы: экран Components; таблица и фильтры — Users; вкладки — Settings; вход — Authentication. Основная стилизация в `system.css`.
|
||||
|
||||
| Компонент | Состояния и взаимодействия |
|
||||
|
||||
@@ -105,6 +105,7 @@ export async function exportSystem(
|
||||
"icons/anidev-dock-icons.zip",
|
||||
...iconNames.map((name) => `icons/svg/${name}.svg`),
|
||||
"components/system.css",
|
||||
"components/toast.js",
|
||||
"components/workspaces.css",
|
||||
"components/ssh-console.js",
|
||||
"components/log-reader.js",
|
||||
|
||||
+267
-10
@@ -974,25 +974,88 @@ dialog > p {
|
||||
background: var(--color-accent);
|
||||
color: var(--color-on-accent);
|
||||
}
|
||||
#toast {
|
||||
:is(#toast, .anidev-toast) {
|
||||
--toast-tone: var(--color-accent);
|
||||
position: fixed;
|
||||
inset: auto;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
bottom: 25px;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--color-text);
|
||||
color: var(--color-bg);
|
||||
padding: 12px 20px;
|
||||
width: min(420px, calc(100% - 32px));
|
||||
max-width: calc(100% - 32px);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--toast-tone) 30%, var(--color-border));
|
||||
border-left: 3px solid var(--toast-tone);
|
||||
border-radius: var(--radius-control);
|
||||
font-size: 14px;
|
||||
box-shadow: 0 8px 32px #0003;
|
||||
padding: 14px;
|
||||
font-size: 13px;
|
||||
z-index: 100;
|
||||
display: none;
|
||||
max-width: calc(100% - 32px);
|
||||
}
|
||||
#toast:popover-open {
|
||||
display: block;
|
||||
:is(#toast, .anidev-toast)[data-type="success"] {
|
||||
--toast-tone: var(--color-success);
|
||||
}
|
||||
:is(#toast, .anidev-toast)[data-type="warning"] {
|
||||
--toast-tone: var(--color-warning);
|
||||
}
|
||||
:is(#toast, .anidev-toast)[data-type="error"] {
|
||||
--toast-tone: var(--color-danger);
|
||||
}
|
||||
:is(#toast, .anidev-toast):popover-open {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
animation: toast-enter 180ms ease-out;
|
||||
}
|
||||
.toast-symbol {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
background: color-mix(in srgb, var(--toast-tone) 12%, var(--color-surface));
|
||||
color: var(--toast-tone);
|
||||
}
|
||||
.toast-content {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.toast-title {
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.toast-message {
|
||||
line-height: 1.5;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
:is(#toast, .anidev-toast) .toast-dismiss {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 28px;
|
||||
min-height: 28px;
|
||||
padding: 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
@keyframes toast-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
translate: 0 6px;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
translate: 0 0;
|
||||
}
|
||||
}
|
||||
.skip {
|
||||
position: fixed;
|
||||
@@ -2585,3 +2648,197 @@ body[data-concept="dock"] .nav-links button {
|
||||
background-color 120ms ease-out,
|
||||
color 120ms ease-out;
|
||||
}
|
||||
|
||||
#content:focus {
|
||||
outline: none;
|
||||
}
|
||||
.sample-control-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
max-width: 440px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.sample-control-row > :is(input, select) {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: calc(var(--size-control) + 8px);
|
||||
}
|
||||
input[readonly] {
|
||||
cursor: default;
|
||||
background: color-mix(in srgb, var(--color-muted) 6%, var(--color-surface));
|
||||
}
|
||||
.choice-pill,
|
||||
.form-row .choice-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
flex: 0 1 auto;
|
||||
min-height: 40px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 999px;
|
||||
background: var(--color-surface);
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.choice-pill > :is(input[type="checkbox"], input[type="radio"]) {
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.choice-pill > span {
|
||||
line-height: 20px;
|
||||
}
|
||||
.choice-pill:hover {
|
||||
background: var(--color-row-hover);
|
||||
}
|
||||
.choice-pill:has(input:checked) {
|
||||
background: var(--color-row-active);
|
||||
border-color: var(--color-accent);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
.choice-pill:has(input:focus-visible) {
|
||||
outline: 2px solid var(--color-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.choice-pill > input:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.choice-pill:has(input:disabled) {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
body[data-concept="dock"] .navigation {
|
||||
--nav-icon-track: 50px;
|
||||
}
|
||||
body[data-concept="dock"] .navigation > .dock-brand,
|
||||
body[data-concept="dock"] .dock-account-area {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
body[data-concept="dock"] .navigation > .nav-links {
|
||||
min-height: 0;
|
||||
flex: 1 1 auto;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
body[data-concept="dock"]:not(.dock-open) .navigation > .nav-links {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
body[data-concept="dock"] .nav-links > button,
|
||||
.nav-group {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.nav-group {
|
||||
min-width: 0;
|
||||
}
|
||||
.nav-group-label {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding-right: 24px;
|
||||
}
|
||||
.nav-chevron {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
translate: 0 -50%;
|
||||
transition: transform 160ms ease;
|
||||
}
|
||||
.nav-group.is-expanded .nav-chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.nav-submenu-container {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
opacity: 0;
|
||||
transition:
|
||||
grid-template-rows 180ms ease,
|
||||
opacity 140ms ease;
|
||||
}
|
||||
.nav-group.is-expanded .nav-submenu-container {
|
||||
grid-template-rows: 1fr;
|
||||
opacity: 1;
|
||||
}
|
||||
.nav-submenu-clip {
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.nav-submenu-list {
|
||||
margin: 4px 0 4px 25px;
|
||||
padding: 0 0 0 14px;
|
||||
border-left: 1px solid var(--color-border);
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
body[data-concept="dock"] .nav-submenu-list button {
|
||||
grid-template-columns: 24px minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
padding: 8px 8px 8px 0;
|
||||
min-height: 40px;
|
||||
font-size: 13px;
|
||||
}
|
||||
body[data-concept="dock"] .nav-submenu-list .nav-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
body[data-concept="dock"] .nav-group-toggle[data-active="true"] {
|
||||
background: var(--color-row-active);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
body[data-concept="dock"]
|
||||
.nav-links
|
||||
.nav-group-toggle[data-active="true"]:is(:hover, :focus-visible) {
|
||||
background: var(--color-row-active);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.sample-control-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.choice-pill,
|
||||
.form-row .choice-pill {
|
||||
min-height: 44px;
|
||||
}
|
||||
body[data-concept="dock"] .nav-submenu-list button {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
.selection-specimen fieldset {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.selection-specimen legend {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body[data-concept="dock"] .navigation .wordmark > span {
|
||||
text-align: left;
|
||||
}
|
||||
body[data-concept="dock"].dock-open
|
||||
.nav-links
|
||||
.nav-group-toggle[data-active="true"] {
|
||||
background: transparent;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
body[data-concept="dock"].dock-open
|
||||
.nav-links
|
||||
.nav-group-toggle[data-active="true"]:is(:hover, :focus-visible) {
|
||||
background: var(--color-row-hover);
|
||||
color: var(--color-text);
|
||||
}
|
||||
:is(#toast, .anidev-toast) .toast-dismiss:hover:not(:disabled) {
|
||||
background: var(--color-row-hover);
|
||||
color: var(--color-text);
|
||||
}
|
||||
.choice-pill:has(input:disabled) > input {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { iconSvg } from "../icons/icons.js";
|
||||
const types = {
|
||||
success: { icon: "check", ru: "Готово", en: "Success", duration: 4000 },
|
||||
info: { icon: "info", ru: "Информация", en: "Information", duration: 5000 },
|
||||
warning: { icon: "warning", ru: "Внимание", en: "Warning", duration: 8000 },
|
||||
error: { icon: "error", ru: "Ошибка", en: "Error", duration: 0 },
|
||||
};
|
||||
export function createNotifier(element, { t = (ru) => ru } = {}) {
|
||||
element.classList.add("anidev-toast");
|
||||
let timer,
|
||||
remaining = 0,
|
||||
started = 0,
|
||||
active = false,
|
||||
invoker = null;
|
||||
function hide() {
|
||||
clearTimeout(timer);
|
||||
active = false;
|
||||
if (element.isConnected && element.matches(":popover-open"))
|
||||
element.hidePopover();
|
||||
}
|
||||
function resume() {
|
||||
if (!active || !remaining) return;
|
||||
clearTimeout(timer);
|
||||
started = performance.now();
|
||||
timer = setTimeout(hide, remaining);
|
||||
}
|
||||
function pause() {
|
||||
if (!active || !remaining) return;
|
||||
clearTimeout(timer);
|
||||
remaining = Math.max(1, remaining - (performance.now() - started));
|
||||
}
|
||||
element.addEventListener("pointerenter", pause);
|
||||
element.addEventListener("pointerleave", () => {
|
||||
if (!element.contains(document.activeElement)) resume();
|
||||
});
|
||||
element.addEventListener("focusin", pause);
|
||||
element.addEventListener("focusout", (event) => {
|
||||
if (!element.contains(event.relatedTarget) && !element.matches(":hover"))
|
||||
resume();
|
||||
});
|
||||
element.addEventListener("click", (event) => {
|
||||
if (event.target.closest("[data-toast-dismiss]")) {
|
||||
const restore = element.contains(document.activeElement);
|
||||
hide();
|
||||
if (
|
||||
restore &&
|
||||
invoker?.isConnected &&
|
||||
!invoker.closest("[inert]") &&
|
||||
invoker.getClientRects().length
|
||||
)
|
||||
invoker.focus({ preventScroll: true });
|
||||
}
|
||||
});
|
||||
// A modal makes outside elements inert: put the toast inside it, then use the top layer.
|
||||
document.addEventListener(
|
||||
"close",
|
||||
(event) => {
|
||||
if (
|
||||
event.target instanceof HTMLDialogElement &&
|
||||
event.target.contains(element)
|
||||
) {
|
||||
hide();
|
||||
document.body.append(element);
|
||||
}
|
||||
},
|
||||
{ capture: true },
|
||||
);
|
||||
function notify(message, { type = "info", title, duration } = {}) {
|
||||
type = Object.hasOwn(types, type) ? type : "info";
|
||||
const config = types[type];
|
||||
if (!element.contains(document.activeElement))
|
||||
invoker = document.activeElement;
|
||||
hide();
|
||||
const modal = [...document.querySelectorAll("dialog[open]")].at(-1);
|
||||
if (element.parentElement !== (modal || document.body))
|
||||
(modal || document.body).append(element);
|
||||
element.popover = "manual";
|
||||
element.dataset.type = type;
|
||||
element.setAttribute("role", type === "error" ? "alert" : "status");
|
||||
element.setAttribute(
|
||||
"aria-live",
|
||||
type === "error" ? "assertive" : "polite",
|
||||
);
|
||||
element.setAttribute("aria-atomic", "true");
|
||||
element.innerHTML = `<span class="toast-symbol">${iconSvg(config.icon, { size: 20 })}</span><div class="toast-content"><strong class="toast-title"></strong><span class="toast-message"></span></div><button type="button" class="toast-dismiss" data-toast-dismiss aria-label="${t("Закрыть уведомление", "Dismiss notification")}">${iconSvg("close", { size: 16 })}</button>`;
|
||||
element.querySelector(".toast-title").textContent =
|
||||
title || t(config.ru, config.en);
|
||||
element.querySelector(".toast-message").textContent = String(message);
|
||||
active = true;
|
||||
remaining =
|
||||
Number.isFinite(duration) && duration >= 0 ? duration : config.duration;
|
||||
element.showPopover();
|
||||
started = performance.now();
|
||||
if (!element.matches(":hover") && !element.contains(document.activeElement))
|
||||
resume();
|
||||
}
|
||||
notify.dismiss = hide;
|
||||
return notify;
|
||||
}
|
||||
Reference in new issue
Block a user