feat(theme): upstream router controls and responsive shell fixes
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
namespace ZB.MOM.WW.Theme;
|
||||
|
||||
/// <summary>Bootstrap size modifier for <c>TechButton</c>.</summary>
|
||||
public enum ButtonSize
|
||||
{
|
||||
/// <summary>The theme's standard button size, without a Bootstrap size modifier.</summary>
|
||||
Default,
|
||||
/// <summary>Compact button, using <c>btn-sm</c>.</summary>
|
||||
Small,
|
||||
/// <summary>Large button, using <c>btn-lg</c>.</summary>
|
||||
Large,
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
@namespace ZB.MOM.WW.Theme
|
||||
@* Components/TechButton.razor *@
|
||||
<button @attributes="AdditionalAttributes" type="@Type" class="btn @VariantClass" disabled="@Busy">
|
||||
<button @attributes="AdditionalAttributes" type="@Type" class="@ButtonClass" disabled="@Busy">
|
||||
@if (Busy) { <span class="spinner-border spinner-border-sm me-1" aria-hidden="true"></span> }
|
||||
@ChildContent
|
||||
</button>
|
||||
@@ -12,6 +12,12 @@
|
||||
/// </summary>
|
||||
[Parameter] public ButtonVariant Variant { get; set; } = ButtonVariant.Primary;
|
||||
|
||||
/// <summary>Bootstrap size modifier. Defaults to the theme's standard button size.</summary>
|
||||
[Parameter] public ButtonSize Size { get; set; }
|
||||
|
||||
/// <summary>Additional CSS classes, composed with the variant, size and unmatched class attribute.</summary>
|
||||
[Parameter] public string? Class { get; set; }
|
||||
|
||||
/// <summary>HTML <c>type</c> attribute (<c>button</c>, <c>submit</c>, <c>reset</c>). Defaults to <c>button</c>.</summary>
|
||||
[Parameter] public string Type { get; set; } = "button";
|
||||
|
||||
@@ -30,6 +36,14 @@
|
||||
/// </summary>
|
||||
[Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, object>? AdditionalAttributes { get; set; }
|
||||
|
||||
private string ButtonClass => string.Join(" ", new[]
|
||||
{
|
||||
"btn", VariantClass,
|
||||
Size switch { ButtonSize.Small => "btn-sm", ButtonSize.Large => "btn-lg", _ => null },
|
||||
Class,
|
||||
AdditionalAttributes?.FirstOrDefault(pair => string.Equals(pair.Key, "class", StringComparison.OrdinalIgnoreCase)).Value?.ToString()
|
||||
}.Where(value => !string.IsNullOrWhiteSpace(value)));
|
||||
|
||||
private string VariantClass => Variant switch
|
||||
{
|
||||
ButtonVariant.Secondary => "btn-outline-secondary",
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
@namespace ZB.MOM.WW.Theme
|
||||
@typeparam TRow where TRow : ITreeRow
|
||||
|
||||
@* Stateless preorder tree table. The caller filters Rows and owns collapse state.
|
||||
Shared styles ship once in layout.css, including arbitrary-depth indentation. *@
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>@Head</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (TRow row in Rows)
|
||||
{
|
||||
<tr @key="row.Key" class="tt-d@(row.Depth)">
|
||||
<td class="tt-name" style="@DepthStyle(row)">
|
||||
<button type="button" class="@TwistClass(row)" disabled="@(!row.HasChildren)"
|
||||
aria-expanded="@AriaExpanded(row)" aria-label="@TwistLabel(row)"
|
||||
@onclick="() => OnToggle.InvokeAsync(row.Key)">
|
||||
<i class="@ChevronClass(row)" aria-hidden="true"></i>
|
||||
</button>
|
||||
@Label(row)
|
||||
</td>
|
||||
@Row(row)
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
/// <summary>
|
||||
/// The rows to render, in order — already filtered through
|
||||
/// the caller's visibility policy.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The filtering is the caller's so that this component holds no state at all: the page owns
|
||||
/// <see cref="Collapsed"/>, and what is on screen is a pure function of it.
|
||||
/// </remarks>
|
||||
[Parameter, EditorRequired] public IReadOnlyList<TRow> Rows { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The header cells — every <c><th></c>, including the one over the name column. The
|
||||
/// component supplies the <c><thead></c> and its <c><tr></c>.
|
||||
/// </summary>
|
||||
[Parameter, EditorRequired] public RenderFragment Head { get; set; } = builder => { };
|
||||
|
||||
/// <summary>
|
||||
/// One row's cells <b>after</b> the name cell: the component renders the name column, the
|
||||
/// caller renders the rest.
|
||||
/// </summary>
|
||||
[Parameter, EditorRequired] public RenderFragment<TRow> Row { get; set; } = _ => builder => { };
|
||||
|
||||
/// <summary>The text of a row's name cell, beside its twist.</summary>
|
||||
[Parameter, EditorRequired] public Func<TRow, string> Label { get; set; } = _ => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The keys of the collapsed rows — read only to draw each twist the right way round.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It is the same set the caller filtered <see cref="Rows"/> with, so a row can be collapsed
|
||||
/// and on screen (that is what a shut branch looks like) but never expanded and hidden.
|
||||
/// </remarks>
|
||||
[Parameter] public IReadOnlySet<string> Collapsed { get; set; } = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Raised with a row's <see cref="ITreeRow.Key"/> when its twist is clicked. The caller
|
||||
/// toggles that key in its own collapse set; this component changes nothing itself.
|
||||
/// </summary>
|
||||
[Parameter] public EventCallback<string> OnToggle { get; set; }
|
||||
|
||||
private static string DepthStyle(TRow row)
|
||||
=> "--tt-depth: " + Math.Max(0, row.Depth).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
private bool IsCollapsed(TRow row) => Collapsed.Contains(row.Key);
|
||||
|
||||
private string TwistClass(TRow row) => row.HasChildren ? "tt-twist" : "tt-twist tt-leaf";
|
||||
|
||||
private string ChevronClass(TRow row) => IsCollapsed(row) ? "bi bi-chevron-right" : "bi bi-chevron-down";
|
||||
|
||||
// Null omits the attribute: a leaf's twist is decoration, and announcing it as a collapsed
|
||||
// control would promise a subtree that is not there.
|
||||
private string? AriaExpanded(TRow row)
|
||||
=> !row.HasChildren ? null : IsCollapsed(row) ? "false" : "true";
|
||||
|
||||
private string? TwistLabel(TRow row)
|
||||
=> !row.HasChildren ? null : (IsCollapsed(row) ? "Expand " : "Collapse ") + Label(row);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace ZB.MOM.WW.Theme;
|
||||
|
||||
/// <summary>A row in a preorder flat tree, with each subtree contiguous after its parent.</summary>
|
||||
public interface ITreeRow
|
||||
{
|
||||
/// <summary>Stable identity, unique in the table and used for keyed rendering and collapse state.</summary>
|
||||
string Key { get; }
|
||||
|
||||
/// <summary>Nesting depth, starting at zero for a root.</summary>
|
||||
int Depth { get; }
|
||||
|
||||
/// <summary>Whether this row owns a subtree and offers an expand/collapse toggle.</summary>
|
||||
bool HasChildren { get; }
|
||||
}
|
||||
@@ -11,10 +11,12 @@
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageId>ZB.MOM.WW.Theme</PackageId>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<Description>Shared Technical-Light UI kit (tokens, fonts, side-rail shell, widgets) for the ZB.MOM.WW SCADA family.</Description>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="ZB.MOM.WW.Theme.Tests" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* ZB.MOM.WW.Theme — side-rail + login layout
|
||||
Tokens live in theme.css; this sheet carries only layout + the side rail. */
|
||||
Tokens live in theme.css; this sheet carries application layout and shared controls. */
|
||||
|
||||
/* ── Bootstrap button sizing ─────────────────────────────────────────────────
|
||||
Bootstrap hard-codes --bs-btn-font-size: 1rem, which is oversized against
|
||||
@@ -45,6 +45,12 @@
|
||||
--bs-btn-padding-y: .25rem;
|
||||
--bs-btn-padding-x: .6rem;
|
||||
}
|
||||
.btn-group-lg > .btn,
|
||||
.btn-lg {
|
||||
--bs-btn-font-size: 1rem;
|
||||
--bs-btn-padding-y: .5rem;
|
||||
--bs-btn-padding-x: 1rem;
|
||||
}
|
||||
|
||||
/* ── App shell: side rail + page ─────────────────────────────────────────── */
|
||||
/* The shell is a native <details> disclosure so the narrow-viewport hamburger
|
||||
@@ -59,6 +65,21 @@
|
||||
min-height: calc(100vh - 3.3rem);
|
||||
}
|
||||
|
||||
/* A closed shell must hide navigation only, never the page. Modern Chromium
|
||||
wraps all non-summary children in ::details-content and hides that box while
|
||||
closed. Dissolve it at EVERY width so both children retain the shell's flex
|
||||
layout. The mobile closed-rail rule below owns navigation visibility. */
|
||||
.app-shell::details-content {
|
||||
display: contents;
|
||||
content-visibility: visible;
|
||||
}
|
||||
|
||||
/* Older browsers use a UA display rule on closed disclosure children instead
|
||||
of ::details-content. Author display rules keep the page present there too;
|
||||
an unsupported pseudo-element rule above is simply ignored. */
|
||||
.app-shell > main.page { display: block; }
|
||||
.app-shell > #theme-rail { display: block; }
|
||||
|
||||
.app-shell .page {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
@@ -72,9 +93,8 @@
|
||||
}
|
||||
.app-shell > summary.rail-toggle::-webkit-details-marker { display: none; }
|
||||
|
||||
/* Below lg the native <details> shows/hides #theme-rail via [open]; nothing
|
||||
extra is needed there. On lg+ we force the rail visible (see media query)
|
||||
and keep the toggle hidden via Bootstrap's d-lg-none. */
|
||||
/* The native <details> owns its open state; the mobile rule explicitly hides
|
||||
only #theme-rail when closed. Bootstrap's d-lg-none hides the toggle on lg+. */
|
||||
|
||||
/* ── Side rail ───────────────────────────────────────────────────────────── */
|
||||
.side-rail {
|
||||
@@ -92,20 +112,6 @@
|
||||
and force it shown regardless of the <details> open state (the hamburger
|
||||
toggle is hidden at this width). */
|
||||
@media (min-width: 992px) {
|
||||
/* Chromium >=121 wraps a <details>'s content in a generated ::details-content
|
||||
box that carries content-visibility:hidden while the <details> is closed.
|
||||
Because our app-shell ships closed by default (SSR, no JS) and the toggle
|
||||
is d-lg-none here, that wrapper would (a) hide the rail+page entirely on
|
||||
lg+ and (b) sit between .app-shell and its rail/page children, collapsing
|
||||
the flex-lg-row layout into a vertical stack. Dissolving the wrapper with
|
||||
display:contents removes its box (so content-visibility no longer hides the
|
||||
content AND rail/page become direct flex children of .app-shell again).
|
||||
Browsers that don't support ::details-content treat this as an invalid
|
||||
selector and drop the rule, falling back to the legacy force-show below. */
|
||||
.app-shell::details-content {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
#theme-rail {
|
||||
display: block;
|
||||
position: sticky;
|
||||
@@ -116,10 +122,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* When the side rail is collapsed under <lg viewports (the <details> is closed)
|
||||
the native disclosure hides #theme-rail; when open, restore full width on
|
||||
mobile so the rail spans the viewport. */
|
||||
/* The disclosure toggles navigation while the page remains usable underneath. */
|
||||
@media (max-width: 991.98px) {
|
||||
.app-shell:not([open]) > #theme-rail { display: none; }
|
||||
/* Native disclosure layout can otherwise size the page to a table's
|
||||
min-content width. Bound the page so .table-wrap scrolls internally. */
|
||||
.app-shell > .page {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.side-rail {
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
@@ -323,3 +335,79 @@
|
||||
.login-body { padding: 1.4rem 1.1rem 1.25rem; }
|
||||
.login-error { margin-bottom: 0.85rem; }
|
||||
.field-error { font-size: 0.78rem; margin-top: 0.2rem; }
|
||||
|
||||
/* Shared application presentation, upstreamed from ignitionoee in 0.5.0. */
|
||||
/* ── Page header ─────────────────────────────────────────────────────────────
|
||||
Title left, `.spacer` eating the slack, actions/meta pushed hard right. */
|
||||
.page-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin: 0 0 1rem; }
|
||||
.page-head h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: 0.01em; margin: 0; text-wrap: balance; }
|
||||
.page-head .spacer { flex: 1; }
|
||||
.page-meta { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); }
|
||||
|
||||
/* ── Application sections ────────────────────────────────────────────────────
|
||||
A rule-underlined h2 band; same spacer trick as the page head. */
|
||||
.app-section { margin-bottom: 1.5rem; }
|
||||
.app-head {
|
||||
display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
|
||||
padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule-strong); margin-bottom: 0.75rem;
|
||||
}
|
||||
.app-head h2 { font-size: 1.02rem; font-weight: 600; margin: 0; }
|
||||
.app-head .spacer { flex: 1; }
|
||||
.app-meta { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-faint); }
|
||||
|
||||
/* ── Group header (per-site issue groups) ────────────────────────────────── */
|
||||
.group-head { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
|
||||
.group-name { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); }
|
||||
.group-meta { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); }
|
||||
|
||||
/* ── Per-group count badge ───────────────────────────────────────────────────
|
||||
Red by default (it counts problems); `.warn` for the softer amber case. */
|
||||
.count-badge {
|
||||
display: inline-block; min-width: 1.4rem; text-align: center;
|
||||
font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
|
||||
padding: 0.05rem 0.35rem; border-radius: 999px;
|
||||
color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-border);
|
||||
}
|
||||
.count-badge.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-border); }
|
||||
|
||||
/* ── Inline notice, info variant ─────────────────────────────────────────────
|
||||
Theme 0.3.1 ships `.notice` (amber) but no variants; `.info` re-tints it to
|
||||
the on-palette blue wash. `--info-bg`/`--info-border` come from the theme. */
|
||||
.notice.info { color: var(--accent-deep); background: var(--info-bg); border-color: var(--info-border); }
|
||||
|
||||
/* ── Table row-action cell ─────────────────────────────────────────────────
|
||||
The bare class is what the mockup ships and what a `<span class="row-actions">`
|
||||
still needs. It is NOT enough on its own: every use in this app is a table
|
||||
cell, and Theme 0.3.1's `.data-table th, .data-table td { text-align: left }`
|
||||
is class+element (0-1-1) against this rule's bare class (0-1-0) — specificity
|
||||
beats load order, so the alignment silently lost everywhere. Observed in a
|
||||
browser on 2026-08-05 (every row-action cell left-aligned; `nowrap` applied,
|
||||
`text-align` did not); the cell-level restatement below is the fix.
|
||||
See docs/recipes/router-ui-render-validation.md, Task 1 Defect 2. */
|
||||
.row-actions { text-align: right; white-space: nowrap; }
|
||||
td.row-actions { text-align: right; }
|
||||
|
||||
/* ── Preformatted check/payload block ────────────────────────────────────── */
|
||||
.check-data {
|
||||
margin: 0.35rem 0.9rem 0.6rem; padding: 0.4rem 0.6rem; background: var(--zebra-bg);
|
||||
border: 1px solid var(--rule); border-radius: 4px;
|
||||
font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft); line-height: 1.6;
|
||||
overflow-x: auto; white-space: nowrap;
|
||||
}
|
||||
.check-data b { color: var(--accent-deep); font-weight: 500; }
|
||||
|
||||
/* ── Tree table ──────────────────────────────────────────────────────────────
|
||||
Name-cell depth is a number emitted by TreeTable; it adds to the table's
|
||||
standard 0.8rem cell padding and works at every depth. */
|
||||
.data-table td.tt-name {
|
||||
font-weight: 600;
|
||||
padding-left: calc(0.8rem + var(--tt-depth, 0) * 1.2rem);
|
||||
}
|
||||
.tt-twist {
|
||||
background: none; border: none; padding: 0; margin-right: 0.45rem;
|
||||
color: var(--ink-faint); font-size: 0.75rem; line-height: 1; cursor: pointer;
|
||||
}
|
||||
.tt-twist:hover { color: var(--ink); }
|
||||
.tt-twist:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
/* A hidden leaf control preserves the width of its siblings' toggles. */
|
||||
.tt-leaf { visibility: hidden; }
|
||||
|
||||
Reference in New Issue
Block a user