diff --git a/README.md b/README.md index ce61305..3a85406 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ A section is any routable component. A table with search and sorting: | Navigation | Sections with icons and live counters, captions, account menu, language switch. | | Listings | Server or in-memory data, filters, selection, live reload, loading, empty and error states. | | Forms and dialogs | Side and bottom sheets, validation, field errors, unsaved-changes guard. | -| Blocks | Figures with change, line and bar charts, rankings, meters, tabs, timeline, facts. | +| Blocks | Figures with change, line and bar charts, rankings, meters, tabs, timeline, facts, [expandable catalogs](https://github.com/Echways/Enfilade/blob/main/docs/en/components.md#catalogs). | | Errors | Readable messages for your own exceptions, contained failures, retry. | | Access | Host authentication, roles and policies, per-section visibility. | | Formatting | Numbers, sizes, durations, ICU plurals, the viewer's time zone. | @@ -113,7 +113,7 @@ A section is any routable component. A table with search and sorting: | [Actions](https://github.com/Echways/Enfilade/blob/main/docs/en/actions.md) | `Button`, `Act`, `CurrentPage` | | [Listings](https://github.com/Echways/Enfilade/blob/main/docs/en/listings.md) | Tables, filters, selection | | [Dialogs and forms](https://github.com/Echways/Enfilade/blob/main/docs/en/forms.md) | Sheets, `Form`, `Field` | -| [Components](https://github.com/Echways/Enfilade/blob/main/docs/en/components.md) | Figures, charts, tabs and the rest | +| [Components](https://github.com/Echways/Enfilade/blob/main/docs/en/components.md) | Figures, charts, tabs and catalogs | | [Error messages](https://github.com/Echways/Enfilade/blob/main/docs/en/errors.md) | What users see on failure | | [Formatting](https://github.com/Echways/Enfilade/blob/main/docs/en/formatting.md) | `Words`, `ViewerTime` | | [Styling](https://github.com/Echways/Enfilade/blob/main/docs/en/styling.md) | Themes, accent, tokens | diff --git a/README.ru.md b/README.ru.md index 4c35675..2a16125 100644 --- a/README.ru.md +++ b/README.ru.md @@ -96,7 +96,7 @@ app.Run(); | Навигация | Разделы с иконками и живыми счётчиками, заголовки групп, меню аккаунта, переключатель языка. | | Списки | Данные с сервера или из памяти, фильтры, выбор строк, живое обновление, состояния загрузки, пустоты и ошибки. | | Формы и диалоги | Боковые и нижние панели, валидация, ошибки у полей, защита от потери изменений. | -| Блоки | Показатели с динамикой, линейные и столбчатые графики, рейтинги, шкалы, вкладки, хронология, карточки фактов. | +| Блоки | Показатели с динамикой, линейные и столбчатые графики, рейтинги, шкалы, вкладки, хронология, карточки фактов, [раскрываемые каталоги](https://github.com/Echways/Enfilade/blob/main/docs/ru/components.md#каталоги). | | Ошибки | Понятные сообщения для ваших исключений, локализованные сбои, повтор. | | Доступ | Аутентификация хоста, роли и политики, видимость разделов. | | Форматирование | Числа, размеры, длительности, ICU-множественные, часовой пояс зрителя. | @@ -113,7 +113,7 @@ app.Run(); | [Действия](https://github.com/Echways/Enfilade/blob/main/docs/ru/actions.md) | `Button`, `Act`, `CurrentPage` | | [Списки](https://github.com/Echways/Enfilade/blob/main/docs/ru/listings.md) | Таблицы, фильтры, выбор строк | | [Диалоги и формы](https://github.com/Echways/Enfilade/blob/main/docs/ru/forms.md) | Панели, `Form`, `Field` | -| [Компоненты](https://github.com/Echways/Enfilade/blob/main/docs/ru/components.md) | Показатели, графики, вкладки и остальное | +| [Компоненты](https://github.com/Echways/Enfilade/blob/main/docs/ru/components.md) | Показатели, графики, вкладки и каталоги | | [Сообщения об ошибках](https://github.com/Echways/Enfilade/blob/main/docs/ru/errors.md) | Что видит пользователь при сбое | | [Форматирование](https://github.com/Echways/Enfilade/blob/main/docs/ru/formatting.md) | `Words`, `ViewerTime` | | [Оформление](https://github.com/Echways/Enfilade/blob/main/docs/ru/styling.md) | Темы, акцентный цвет, токены | diff --git a/docs/en/README.md b/docs/en/README.md index d60581e..b5c7e31 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -18,7 +18,7 @@ Enfilade is a Blazor Server shell for admin panels. These pages describe every p | [Actions](actions.md) | `Button` and `Act`: confirmation, busy state, readable errors, refreshing the page. | | [Listings](listings.md) | Tables over any store: sorting, paging, filters, selection, live reload, address state. | | [Dialogs and forms](forms.md) | Side sheets, forms from data annotations, unsaved changes. | -| [Components](components.md) | Figures, charts, rankings, tabs, timeline, facts, panes and the rest. | +| [Components](components.md) | Figures, charts, tabs, timeline, facts, panes and [expandable catalogs](components.md#catalogs). | | [Error messages](errors.md) | What the user sees when something fails, and how to control it. | ## Around the page diff --git a/docs/en/actions.md b/docs/en/actions.md index c8451ea..14d8282 100644 --- a/docs/en/actions.md +++ b/docs/en/actions.md @@ -43,7 +43,7 @@ if (result is ActResult.Done) | Parameter | Description | | ----------------- | ------------------------------------------------------------------------ | -| `Kind` | `Primary` (default), `Danger` or `Quiet`. | +| `Kind` | `Primary` (default) for the main action, `Danger` for destructive actions, `Quiet` for secondary actions. | | `OnClick` | The action. The button is disabled and shows that it is busy until it ends. | | `Confirm` | `Confirm(Question, Message, Yes, Danger)` asked before the action. | | `Done` | Message shown after success. | diff --git a/docs/en/components.md b/docs/en/components.md index c9c83b5..e470d55 100644 --- a/docs/en/components.md +++ b/docs/en/components.md @@ -14,6 +14,7 @@ | `Steps` | A vertical progress of a process from `Step(Title, State, Detail)`; `State` is `Pending`, `Current`, `Done` or `Failed`. | | `Wizard`, `WizardStep` | A multi-step flow: `Steps` and the open `WizardStep` (`Title`, `Detail`, `OnLeave`) with Back, Next and Finish. `@bind-Current`, `OnFinish`, `Done`, `Confirm`. See below. | | `Tabs`, `Tab` | Tabs whose choice lives in the address (`tab=`, or `Name`). A `Tab` has `Title` and optional `Name`; only the open tab renders. | +| `Catalog` | An [expandable group](#catalogs) with a title, an optional count and an actions slot. | | `Timeline` | Events from `TimelineEntry(At, Text, Who, Tone)`, newest first, in the viewer's time zone. | | `Pane` | A titled section of a page with `Hint` and `Actions`. | | `Setting` | A settings row: `Title`, `Hint` and the control on the right. Group rows in `
`. | @@ -135,6 +136,49 @@ A `Menu` is a "⋯" button for the actions of one row. Put it in a `Slot`; click `Label` names the button for screen readers (default "Row actions"). For a link, use `MudMenuItem Href`. +## Catalogs + +`Catalog` displays an expandable group on the current page. Several catalogs can be open at once. Content is mounted on expansion and disposed on collapse. + +![The Clients page with Group 124 expanded and Group 134 collapsed](../screenshots/catalogs.png) + +[View the same page on a phone](../screenshots/catalogs-mobile.png). + +```razor +@inject IDialogService Dialogs + + + + + + + +@foreach (var group in Groups) +{ + + + + + + + + +} + +@code { + private async Task CreateGroupAsync() + { + if (await Dialogs.ShowFormAsync("New catalog") is not null) + Groups = await Store.GroupsAsync(); + } +} +``` + +`NewClientGroup` is a [form in a sheet](forms.md) with a required name field. Save the group in the form's `OnSubmit` handler. `ShowFormAsync` returns the draft when the save succeeds. Reload the groups at that point. The `@key` preserves the expanded groups across that update. + +Put a [menu](#row-menu) in the catalog's `Actions` slot for actions such as rename and delete. Give each nested `Listing` a distinct `Name` to keep its paging and filters independent. For concurrent EF Core loads, give each request its own context. + ## Wizard A `Wizard` shows `Steps` next to the open step and the buttons that move between them. Only the open `WizardStep` renders. `Current` is the index of the open step; bind it with `@bind-Current` to read or set it, or leave it out and the wizard keeps it itself. diff --git a/docs/en/forms.md b/docs/en/forms.md index 65e410e..5034b53 100644 --- a/docs/en/forms.md +++ b/docs/en/forms.md @@ -38,7 +38,9 @@ For a plain confirmation before an action, `Button` with `Confirm` is shorter; s var order = await Dialogs.ShowFormAsync("New order"); ``` -![A form in a side sheet](../screenshots/sheet.png) +![New order form with a rounded Create button in a side sheet](../screenshots/sheet.png) + +The [Catalogs](components.md#catalogs) example shows how to open a form and refresh the groups after saving. `Form` validates with data annotations, shows a busy submit button and submits once on Enter. On success it reports `Done`, reloads the page's blocks, and inside a sheet closes it with the model, which `ShowFormAsync` returns; a closed sheet returns `null`. diff --git a/docs/en/styling.md b/docs/en/styling.md index ed4e42c..c819332 100644 --- a/docs/en/styling.md +++ b/docs/en/styling.md @@ -36,7 +36,8 @@ Use the tokens in your own stylesheets and they follow the theme: | --------------------------------------------- | ------------------------------------------------ | | `btn-k pigment` | Primary button. | | `btn-danger` | Destructive button. | -| `link` | Quiet text button. | +| `btn-quiet` | Secondary button with a hover background. | +| `link` | Inline text action. | | `tbl`, `tbl dense` | On `MudTable`. Add `num` to numeric columns. | | `empty` | Empty state; `EmptyState` renders it. | | `block`, `lead` | Titled section further down a page; `Pane` replaces them. | diff --git a/docs/ru/README.md b/docs/ru/README.md index 5b0175f..2654e37 100644 --- a/docs/ru/README.md +++ b/docs/ru/README.md @@ -18,7 +18,7 @@ Enfilade — оболочка для админ-панелей на Blazor Serve | [Действия](actions.md) | `Button` и `Act`: подтверждение, состояние занятости, понятные ошибки, обновление страницы. | | [Списки](listings.md) | Таблицы над любым хранилищем: сортировка, страницы, фильтры, выбор строк, живое обновление, состояние в адресе. | | [Диалоги и формы](forms.md) | Боковые панели, формы из атрибутов данных, несохранённые изменения. | -| [Компоненты](components.md) | Показатели, графики, рейтинги, вкладки, хронология, блоки и остальное. | +| [Компоненты](components.md) | Показатели, графики, вкладки, хронология, блоки и [раскрываемые каталоги](components.md#каталоги). | | [Сообщения об ошибках](errors.md) | Что видит пользователь, когда что-то не получилось, и как этим управлять. | ## Вокруг страницы diff --git a/docs/ru/actions.md b/docs/ru/actions.md index 2f27cb8..d72e90c 100644 --- a/docs/ru/actions.md +++ b/docs/ru/actions.md @@ -43,7 +43,7 @@ if (result is ActResult.Done) | Параметр | Описание | | ----------------- | ------------------------------------------------------------------------ | -| `Kind` | `Primary` (по умолчанию), `Danger` или `Quiet`. | +| `Kind` | `Primary` (по умолчанию) для основного действия, `Danger` для опасного, `Quiet` для второстепенного. | | `OnClick` | Действие. Пока оно идёт, кнопка отключена и показывает занятость. | | `Confirm` | `Confirm(Question, Message, Yes, Danger)` — вопрос перед действием. | | `Done` | Сообщение после успеха. | diff --git a/docs/ru/components.md b/docs/ru/components.md index df63a65..df5c5c6 100644 --- a/docs/ru/components.md +++ b/docs/ru/components.md @@ -14,6 +14,7 @@ | `Steps` | Вертикальный ход процесса из `Step(Title, State, Detail)`; `State` — `Pending`, `Current`, `Done` или `Failed`. | | `Wizard`, `WizardStep` | Многошаговый сценарий: `Steps` и открытый `WizardStep` (`Title`, `Detail`, `OnLeave`) с кнопками «Назад», «Далее» и «Готово». `@bind-Current`, `OnFinish`, `Done`, `Confirm`. См. ниже. | | `Tabs`, `Tab` | Вкладки, выбор которых хранится в адресе (`tab=` или `Name`). У `Tab` есть `Title` и необязательный `Name`; рендерится только открытая вкладка. | +| `Catalog` | [Раскрываемая группа](#каталоги) с названием, необязательным счётчиком и слотом действий. | | `Timeline` | События из `TimelineEntry(At, Text, Who, Tone)`, новые сверху, в часовом поясе зрителя. | | `Pane` | Блок страницы с заголовком, `Hint` и `Actions`. | | `Setting` | Строка настроек: `Title`, `Hint` и элемент управления справа. Строки группируются в `
`. | @@ -135,6 +136,49 @@ `Label` называет кнопку для скринридера (по умолчанию «Действия со строкой»). Для ссылки используйте `MudMenuItem Href`. +## Каталоги + +`Catalog` показывает раскрываемую группу на текущей странице. Несколько каталогов можно открыть одновременно. Содержимое создаётся при раскрытии и освобождается при сворачивании. + +![Страница клиентов с раскрытой группой 124 и свёрнутой группой 134](../screenshots/catalogs.png) + +[Та же страница на телефоне](../screenshots/catalogs-mobile.png). + +```razor +@inject IDialogService Dialogs + + + + + + + +@foreach (var group in Groups) +{ + + + + + + + + +} + +@code { + private async Task CreateGroupAsync() + { + if (await Dialogs.ShowFormAsync("Новый каталог") is not null) + Groups = await Store.GroupsAsync(); + } +} +``` + +`NewClientGroup` — это [форма в панели](forms.md) с обязательным полем «Название». Сохраняйте группу в обработчике `OnSubmit`. После успешного сохранения `ShowFormAsync` вернёт модель, и можно перечитать группы. Ключ `@key` сохраняет раскрытые группы при таком обновлении. + +Поместите [меню](#меню-строки) в слот `Actions` каталога, чтобы добавить переименование или удаление. Укажите отдельный `Name` для каждого вложенного `Listing`, чтобы страницы и фильтры групп были независимы. Для параллельных загрузок через EF Core используйте отдельный контекст на каждый запрос. + ## Wizard `Wizard` показывает `Steps` рядом с открытым шагом и кнопки перехода между шагами. Рисуется только открытый `WizardStep`. `Current` — номер открытого шага: привяжите его через `@bind-Current`, чтобы читать или задавать, или не указывайте, и мастер сам его хранит. diff --git a/docs/ru/forms.md b/docs/ru/forms.md index 698156d..f2800fa 100644 --- a/docs/ru/forms.md +++ b/docs/ru/forms.md @@ -38,7 +38,9 @@ var result = await sheet.Result; var order = await Dialogs.ShowFormAsync("New order"); ``` -![A form in a side sheet](../screenshots/sheet.png) +![Форма нового заказа со скруглённой кнопкой создания в боковой панели](../screenshots/sheet.png) + +В разделе [Каталоги](components.md#каталоги) показано, как открыть форму и обновить группы после сохранения. `Form` проверяет модель по атрибутам данных, показывает занятую кнопку отправки и отправляет один раз по Enter. После успеха он сообщает `Done`, перезагружает блоки страницы, а внутри панели закрывает её и возвращает модель, которую отдаёт `ShowFormAsync`; закрытая панель возвращает `null`. diff --git a/docs/ru/styling.md b/docs/ru/styling.md index e137adb..29c9f3b 100644 --- a/docs/ru/styling.md +++ b/docs/ru/styling.md @@ -36,7 +36,8 @@ builder.Services.AddEnfilade(shell => | --------------------------------------------- | ------------------------------------------------ | | `btn-k pigment` | Основная кнопка. | | `btn-danger` | Кнопка разрушающего действия. | -| `link` | Тихая текстовая кнопка. | +| `btn-quiet` | Второстепенная кнопка с фоном при наведении. | +| `link` | Действие в виде текста. | | `tbl`, `tbl dense` | На `MudTable`. `num` добавляется числовым колонкам. | | `empty` | Пустое состояние; его рисует `EmptyState`. | | `block`, `lead` | Блок с заголовком ниже по странице; заменяются `Pane`. | diff --git a/docs/screenshots/catalogs-mobile.png b/docs/screenshots/catalogs-mobile.png new file mode 100644 index 0000000..e38f9f8 Binary files /dev/null and b/docs/screenshots/catalogs-mobile.png differ diff --git a/docs/screenshots/catalogs.png b/docs/screenshots/catalogs.png new file mode 100644 index 0000000..8be9f25 Binary files /dev/null and b/docs/screenshots/catalogs.png differ diff --git a/docs/screenshots/order.png b/docs/screenshots/order.png index a684dae..5b1c309 100644 Binary files a/docs/screenshots/order.png and b/docs/screenshots/order.png differ diff --git a/docs/screenshots/orders.png b/docs/screenshots/orders.png index 1c771ab..a4037fa 100644 Binary files a/docs/screenshots/orders.png and b/docs/screenshots/orders.png differ diff --git a/docs/screenshots/overview-dark.png b/docs/screenshots/overview-dark.png index d4b6435..9d4e92e 100644 Binary files a/docs/screenshots/overview-dark.png and b/docs/screenshots/overview-dark.png differ diff --git a/docs/screenshots/overview-light.png b/docs/screenshots/overview-light.png index 75f6d3e..4f2e70b 100644 Binary files a/docs/screenshots/overview-light.png and b/docs/screenshots/overview-light.png differ diff --git a/docs/screenshots/sheet.png b/docs/screenshots/sheet.png index 039a701..58f8652 100644 Binary files a/docs/screenshots/sheet.png and b/docs/screenshots/sheet.png differ diff --git a/src/Enfilade/Components/Button.razor b/src/Enfilade/Components/Button.razor index 87020b9..c36e32c 100644 --- a/src/Enfilade/Components/Button.razor +++ b/src/Enfilade/Components/Button.razor @@ -6,6 +6,7 @@ @ChildContent @if (Working) { + @EnfiladeText.Working } @@ -50,7 +51,7 @@ Kind switch { ButtonKind.Danger => "btn-danger", - ButtonKind.Quiet => "link", + ButtonKind.Quiet => "link btn-quiet", _ => "btn-k pigment", }, Working ? "busy" : null, diff --git a/src/Enfilade/Components/Catalog.razor b/src/Enfilade/Components/Catalog.razor new file mode 100644 index 0000000..5c9b600 --- /dev/null +++ b/src/Enfilade/Components/Catalog.razor @@ -0,0 +1,45 @@ +@namespace Enfilade + +
+
+ + @if (Actions is not null) + { +
@Actions
+ } +
+ +
+ +@code { + private readonly string _panel = ElementId.New("catalog"); + private bool _expanded; + + [Parameter, EditorRequired] + public string Title { get; set; } = ""; + + [Parameter] + public long? Count { get; set; } + + [Parameter] + public RenderFragment? Actions { get; set; } + + [Parameter, EditorRequired] + public RenderFragment ChildContent { get; set; } = default!; + + private void Toggle() => _expanded = !_expanded; +} diff --git a/src/Enfilade/Components/ConfirmDialog.razor b/src/Enfilade/Components/ConfirmDialog.razor index 0e184e7..0234db2 100644 --- a/src/Enfilade/Components/ConfirmDialog.razor +++ b/src/Enfilade/Components/ConfirmDialog.razor @@ -7,7 +7,7 @@

@Message

- + diff --git a/src/Enfilade/Components/Wizard.razor b/src/Enfilade/Components/Wizard.razor index ff442fa..f1aea0e 100644 --- a/src/Enfilade/Components/Wizard.razor +++ b/src/Enfilade/Components/Wizard.razor @@ -9,7 +9,7 @@
@if (Index > 0) { - + } @if (Last) { diff --git a/src/Enfilade/wwwroot/enfilade.css b/src/Enfilade/wwwroot/enfilade.css index d26ea8e..d8e3623 100644 --- a/src/Enfilade/wwwroot/enfilade.css +++ b/src/Enfilade/wwwroot/enfilade.css @@ -212,7 +212,7 @@ code, .code { border-radius: inherit; } -.pigment > * { +.pigment > :where(:not(.sr)) { position: relative; z-index: 1; } @@ -233,7 +233,7 @@ button.link, .link { transition: color 0.3s var(--spring); } -button.link:hover, .link:hover { +button.link:hover:not(:disabled), .link:hover:not(:disabled) { color: var(--light); } @@ -488,7 +488,7 @@ button.link:hover, .link:hover { color: inherit; background: none; border: 0; - border-radius: 2px; + border-radius: var(--round); cursor: pointer; transition: background-color 0.4s var(--spring), color 0.4s var(--spring); } @@ -629,24 +629,76 @@ button.link:hover, .link:hover { } } -.btn-k { +.btn-k, .btn-danger, button.btn-quiet { display: inline-block; + box-sizing: border-box; + min-height: 40px; font: 600 13px/20px var(--sans); - padding: 10px 20px; - border-radius: 2px; + padding: 9px 19px; + border: 1px solid transparent; + border-radius: var(--round); + text-align: center; white-space: nowrap; text-decoration: none; cursor: pointer; - box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); - transition: filter 0.4s var(--spring), transform 0.4s var(--spring); + transition: background-color 0.25s var(--spring), color 0.25s var(--spring), filter 0.25s var(--spring); +} + +.btn-k { + border-color: rgba(255, 255, 255, 0.12); +} + +.btn-k:hover:not(:disabled) { + filter: brightness(1.12); +} + +.btn-k:active:not(:disabled), .signin button:active:not(:disabled) { + filter: brightness(0.96); +} + +.btn-danger { + color: var(--vermilion); + border-color: color-mix(in oklab, var(--vermilion) 55%, transparent); + background: color-mix(in oklab, var(--vermilion) 6%, transparent); +} + +.btn-danger:hover:not(:disabled) { + background: color-mix(in oklab, var(--vermilion) 13%, transparent); +} + +.btn-danger:active:not(:disabled) { + background: color-mix(in oklab, var(--vermilion) 20%, transparent); +} + +button.btn-quiet { + padding-inline: 13px; + color: var(--mist); + background: transparent; +} + +button.btn-quiet:hover:not(:disabled) { + color: var(--light); + background: var(--wash); +} + +button.btn-quiet:active:not(:disabled) { + background: var(--rule); +} + +:is(.btn-k, .btn-danger, .btn-quiet, .signin button):disabled { + opacity: 0.45; + cursor: not-allowed; } -.btn-k:hover { - filter: brightness(1.16); +:is(.btn-k, .btn-danger, .btn-quiet).busy:disabled { + opacity: 0.72; + cursor: progress; } -.btn-k:active, .btn-danger:active, .signin button:active { - transform: scale(0.97); +@media (pointer: coarse) { + .btn-k, .btn-danger, button.btn-quiet { + min-height: 44px; + } } .note, .nothing { @@ -911,6 +963,116 @@ button.link:hover, .link:hover { gap: 18px; } +.catalog { + min-width: 0; + padding-block: 4px; + border-bottom: 1px solid var(--rule); +} + +.catalog-head { + display: flex; + align-items: center; + gap: 4px; + border-radius: var(--round); +} + +.catalog-head:has(.catalog-toggle[aria-expanded="true"]) { + background: var(--wash); +} + +.catalog-toggle { + flex: 1; + display: flex; + align-items: center; + gap: 10px; + min-width: 0; + min-height: 44px; + padding: 10px 12px; + border: 0; + border-radius: var(--round); + background: transparent; + color: var(--light); + font: 500 14px/22px var(--sans); + text-align: start; + cursor: pointer; + transition: background-color 0.2s var(--spring); +} + +.catalog-toggle:hover { + background: var(--wash); +} + +.catalog-chevron { + flex: none; + width: 7px; + height: 7px; + margin-inline: 1px 4px; + border-right: 1px solid currentColor; + border-bottom: 1px solid currentColor; + color: var(--mist); + transform: rotate(-45deg); + transition: color 0.2s var(--spring), transform 0.2s var(--spring); +} + +.catalog-toggle[aria-expanded="true"] .catalog-chevron { + color: var(--light); + transform: rotate(45deg); +} + +.catalog-toggle .catalog-icon { + flex: none; + width: 18px; + height: 18px; + color: var(--mist); +} + +.catalog-title { + flex: 1; + min-width: 0; + overflow-wrap: anywhere; +} + +.catalog-count { + flex: none; + color: var(--mist); + font: 500 12px/18px var(--sans); +} + +.catalog-actions { + flex: none; + padding-inline-end: 8px; +} + +.catalog-actions .more .mud-button-root { + min-width: 44px; + width: 44px; + height: 44px; +} + +.catalog-body { + padding-block: 16px 20px; + padding-inline: 62px 12px; +} + +@media (prefers-reduced-motion: no-preference) { + .catalog-body:not([hidden]) { + animation: catalog-in 0.18s var(--spring); + } +} + +@keyframes catalog-in { + from { + opacity: 0; + transform: translateY(-3px); + } +} + +@media (max-width: 599.98px) { + .catalog-body { + padding-inline-start: 12px; + } +} + .listing { display: grid; gap: 20px; @@ -1004,20 +1166,28 @@ button.link:hover, .link:hover { flex-wrap: wrap; align-items: center; justify-content: flex-end; - gap: 8px 20px; + gap: 8px 12px; font: 500 13px/20px var(--sans); color: var(--mist); font-variant-numeric: tabular-nums; } .pager .link { - min-width: 32px; - min-height: 32px; + min-width: 36px; + min-height: 36px; + border: 1px solid var(--rule); + border-radius: var(--round); font-size: 17px; + transition: color 0.25s var(--spring), background-color 0.25s var(--spring); +} + +.pager .link:hover:not(:disabled) { + background-color: var(--wash); } .pager .link:disabled { opacity: 0.35; + color: var(--mist); cursor: default; } @@ -1421,34 +1591,16 @@ body:has(.mud-overlay-dialog) .mud-popover:has(.mud-menu-list) { display: flex; justify-content: flex-end; align-items: center; - gap: 28px; + gap: 12px; padding: 28px; } -.btn-k:disabled { - opacity: 0.4; - filter: none; - cursor: not-allowed; -} - -button.btn-k { - border: 0; -} - -.busy, .btn-k.busy:disabled { - cursor: progress; -} - -.btn-k.busy:disabled { - opacity: 0.7; -} - -.busy::after { - content: ""; +.button-spinner { display: inline-block; + box-sizing: border-box; width: 10px; height: 10px; - margin-left: 10px; + margin-inline-start: 8px; vertical-align: -1px; border: 1.5px solid currentColor; border-right-color: transparent; @@ -1456,7 +1608,7 @@ button.btn-k { } @media (prefers-reduced-motion: no-preference) { - .busy::after { + .button-spinner { animation: turn 0.8s linear infinite; } } @@ -1467,21 +1619,6 @@ button.btn-k { } } -.btn-danger { - font: 600 13px/20px var(--sans); - color: var(--vermilion); - background: none; - border: 1px solid var(--vermilion); - padding: 9px 19px; - border-radius: 2px; - cursor: pointer; - transition: background-color 0.4s var(--spring), transform 0.4s var(--spring); -} - -.btn-danger:hover { - background: rgba(255, 90, 60, 0.1); -} - .mud-dialog .fixed.pointer-events-none:focus, .mud-focus-trap:focus, .mud-focus-trap-child-container:focus, @@ -1658,13 +1795,12 @@ button.btn-k { .confirm-foot.mud-dialog-actions { flex-direction: column-reverse; align-items: stretch; - gap: 4px; + gap: 8px; padding: 24px 20px 20px; } - .confirm-foot :is(.btn-k, .btn-danger, .link) { - padding-block: 13px; - text-align: center; + .confirm-foot :is(.btn-k, .btn-danger, .btn-quiet) { + min-height: 46px; } .confirm-head.mud-dialog-title { @@ -2238,10 +2374,10 @@ a.crumb:hover { border-radius: var(--round); cursor: pointer; box-shadow: 0 14px 34px -16px rgba(0, 4, 40, 0.9); - transition: background-color 0.3s var(--spring), transform 0.4s var(--spring); + transition: background-color 0.25s var(--spring), filter 0.25s var(--spring); } -.signin button:hover { +.signin button:hover:not(:disabled) { background: #E8ECFA; } @@ -2448,11 +2584,16 @@ a.crumb:hover { } @media (pointer: coarse) { - button.link, a.link, .crumb-off, .stamp { + .pager .link { + min-width: 44px; + min-height: 44px; + } + + button.link:not(.btn-quiet, .pager .link), a.link, .crumb-off, .stamp { position: relative; } - button.link::before, a.link::before, .crumb-off::before, .stamp::before { + button.link:not(.btn-quiet, .pager .link)::before, a.link::before, .crumb-off::before, .stamp::before { content: ""; position: absolute; inset: -12px -8px; diff --git a/tests/Enfilade.Tests/CatalogTests.cs b/tests/Enfilade.Tests/CatalogTests.cs new file mode 100644 index 0000000..333a1f1 --- /dev/null +++ b/tests/Enfilade.Tests/CatalogTests.cs @@ -0,0 +1,60 @@ +using Microsoft.AspNetCore.Components; + +namespace Enfilade.Tests; + +public class CatalogTests : PanelContext +{ + [Fact] + public void Catalog_renders_its_contents_only_while_expanded() + { + var catalog = Render(parameters => parameters + .Add(catalog => catalog.Title, "Группа 124") + .Add(catalog => catalog.ChildContent, "

Анна

")); + + var toggle = catalog.Find("button"); + var panelId = toggle.GetAttribute("aria-controls"); + Assert.False(string.IsNullOrWhiteSpace(panelId)); + Assert.Equal("false", toggle.GetAttribute("aria-expanded")); + Assert.True(catalog.Find($"#{panelId}").HasAttribute("hidden")); + Assert.Empty(catalog.FindAll("p")); + + toggle.Click(); + + Assert.Equal("true", catalog.Find("button").GetAttribute("aria-expanded")); + Assert.False(catalog.Find($"#{panelId}").HasAttribute("hidden")); + Assert.Equal("Анна", catalog.Find($"#{panelId} p").TextContent); + + catalog.Find("button").Click(); + + Assert.Equal("false", catalog.Find("button").GetAttribute("aria-expanded")); + Assert.True(catalog.Find($"#{panelId}").HasAttribute("hidden")); + Assert.Empty(catalog.FindAll("p")); + } + + [Fact] + public void Catalog_actions_are_separate_from_the_disclosure() + { + var clicks = 0; + RenderFragment actions = builder => + { + builder.OpenElement(0, "button"); + builder.AddAttribute(1, "onclick", EventCallback.Factory.Create(this, () => clicks++)); + builder.AddContent(2, "Переименовать"); + builder.CloseElement(); + }; + var catalog = Render(parameters => parameters + .Add(catalog => catalog.Title, "Группа 134") + .Add(catalog => catalog.Count, 0L) + .Add(catalog => catalog.Actions, actions) + .Add(catalog => catalog.ChildContent, "

Клиентов пока нет

")); + + var toggle = catalog.Find("button[aria-expanded]"); + Assert.Equal("0", toggle.QuerySelector(".catalog-count")?.TextContent); + Assert.Empty(toggle.QuerySelectorAll("button")); + + catalog.Find(".catalog-actions button").Click(); + + Assert.Equal(1, clicks); + Assert.Equal("false", catalog.Find("button[aria-expanded]").GetAttribute("aria-expanded")); + } +}