Skip to content

Commit aedc87d

Browse files
authored
Feature/26111903 shared demo accessibility gaps (#1396)
* fix(demo): Close shared demo accessibility gaps (26111903) - Name the EmptyLayout social links and hide their icons - Darken low-contrast Prism tokens in the light and dark themes - Use emphasis colors for the library action buttons in dark mode - Add a site-wide 2px focus outline, including btn-check toggles - Make the code copy control a native button with an announced result - Drop role="button" from DocsLink and hide its icon * docs: Fix dead demo-site links (QF-26112001) Demo routes moved under /demos, so 445 links across 55 docs pages returned 404. Add the /demos prefix, correct the checkbox input route, serve the screenshot images from the RCL _content path, and update five anchors that pointed to renamed or moved sections. * feat(preload): Enhance accessibility features and documentation for screen readers * fix(preload): Make the loading text meet WCAG contrast The Preload loading text took the spinner color over a 50% backdrop, so the default light text was 3.74:1 on a light page and colored text was about 1.1:1. The overlay's text is now always light, the page-loading backdrop is 0.6 opacity, and SpinnerColor colors only the spinner. That keeps the text at least 4.5:1 over any page in light and dark mode. - blazor.bootstrap.css: set --bs-modal-color to --bs-light on .modal-page-loading, and --bs-backdrop-opacity to 0.6 on its backdrop - Preload.razor: move the spinner color class onto the spinner - Docs: describe the contrast behavior and the spinner-only guidance Custom ChildContent inherits the light text unless it sets its own color.
1 parent 82e912b commit aedc87d

67 files changed

Lines changed: 723 additions & 483 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,26 @@
4444

4545
<ul class="navbar-nav flex-row flex-wrap ms-md-auto">
4646
<li class="nav-item col-6 col-lg-auto">
47-
<a class="nav-link py-2 px-0 px-lg-2" href="@githubUrl" target="_blank" rel="noopener">
48-
<i class="bi bi-github"></i>
47+
<a class="nav-link py-2 px-0 px-lg-2" href="@githubUrl" target="_blank" rel="noopener" aria-label="GitHub">
48+
<i class="bi bi-github" aria-hidden="true"></i>
4949
<small class="d-lg-none ms-2">GitHub</small>
5050
</a>
5151
</li>
5252
<li class="nav-item col-6 col-lg-auto">
53-
<a class="nav-link py-2 px-0 px-lg-2" href="@twitterUrl" target="_blank" rel="noopener">
54-
<i class="bi bi-twitter-x"></i>
55-
<small class="d-lg-none ms-2">Twitter</small>
53+
<a class="nav-link py-2 px-0 px-lg-2" href="@twitterUrl" target="_blank" rel="noopener" aria-label="Blazor Bootstrap on X">
54+
<i class="bi bi-twitter-x" aria-hidden="true"></i>
55+
<small class="d-lg-none ms-2">X</small>
5656
</a>
5757
</li>
5858
<li class="nav-item col-6 col-lg-auto">
59-
<a class="nav-link py-2 px-0 px-lg-2" href="@linkedInUrl" target="_blank" rel="noopener">
60-
<i class="bi bi-linkedin"></i>
59+
<a class="nav-link py-2 px-0 px-lg-2" href="@linkedInUrl" target="_blank" rel="noopener" aria-label="LinkedIn">
60+
<i class="bi bi-linkedin" aria-hidden="true"></i>
6161
<small class="d-lg-none ms-2">LinkedIn</small>
6262
</a>
6363
</li>
6464
<li class="nav-item col-6 col-lg-auto">
65-
<a class="nav-link py-2 px-0 px-lg-2" href="@openCollectiveUrl" target="_blank" rel="noopener">
66-
<i class="bi bi-opencollective"></i>
65+
<a class="nav-link py-2 px-0 px-lg-2" href="@openCollectiveUrl" target="_blank" rel="noopener" aria-label="Open Collective">
66+
<i class="bi bi-opencollective" aria-hidden="true"></i>
6767
<small class="d-lg-none ms-2">Open Collective</small>
6868
</a>
6969
</li>

‎BlazorBootstrap.Demo.RCL/Components/Pages/Demos/Preload/PreloadDocumentation.razor‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@
3636
<Section Size="HeadingSize.H2" Name="Change spinner color" PageUrl="@pageUrl" Link="change-spinner-color">
3737
<div class="mb-3">
3838
Change the default spinner color by passing the <code>SpinnerColor</code> enum to the <code>Show(...)</code> method.
39+
The color applies to the spinner only; the loading text stays light so it remains readable.
3940
In the below example, we are using a <a href="@($"{pageUrl}#global-preload-service-for-the-application")">global preload service</a>, as shown in the above section.
4041
</div>
4142
<Demo Type="typeof(Preload_Demo_03_Change_Spinner_Color)" />
4243
</Section>
4344

45+
<Section Size="HeadingSize.H2" Name="Accessibility" PageUrl="@pageUrl" Link="accessibility">
46+
<div class="mb-3">
47+
<ul>
48+
<li>When the preload shows, screen readers announce it as a status message, without moving focus. They hear the text passed to <code>Show(...)</code>, otherwise <code>LoadingText</code>, otherwise <code>VisuallyHiddenText</code> (default "Loading..."), which you can set to localize it. A new text passed to <code>Show(...)</code> while the preload is shown is announced again.</li>
49+
<li>While the preload is shown, the page behind it can't be reached with the keyboard or by assistive technology, just as the backdrop stops mouse clicks. When it hides, focus returns to the element that had it.</li>
50+
<li>If you pass your own <code>ChildContent</code>, its text is what screen readers announce, so include visible text such as "Uploading files...".</li>
51+
<li>The loading text is always light, and the backdrop dims the page enough for the text to stay readable over any page, in light and dark mode. Custom content gets the same light text unless it sets its own color. A colored spinner shown without loading text may not stand out enough from the page, so add loading text or use <code>SpinnerColor.Light</code>.</li>
52+
</ul>
53+
</div>
54+
</Section>
55+
4456
@code {
4557
private const string pageUrl = DemoRouteConstants.Demos_URL_Preload;
4658
private const string pageTitle = "Blazor Preload";

‎BlazorBootstrap.Demo.RCL/Components/Shared/Demo.razor‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
<div class="d-flex align-items-center highlight-toolbar px-4 py-2 border">
88
<small class="font-monospace text-body-secondary text-uppercase">@LanguageCode.ToLanguageCodeString()</small>
99
<div class="d-flex ms-auto">
10-
<Tooltip Title="@clipboardTooltipTitle" role="button" @onclick="CopyToClipboardAsync">
11-
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" />
10+
<Tooltip Title="@clipboardTooltipTitle">
11+
<button type="button" class="bd-demo-copy" aria-label="Copy to clipboard" @onclick="CopyToClipboardAsync">
12+
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" aria-hidden="true" />
13+
</button>
1214
</Tooltip>
15+
<span class="visually-hidden" role="status">@copyStatus</span>
1316
</div>
1417
</div>
1518
<div class="highlight border border-top-0">
@@ -33,9 +36,12 @@ else if (!Tabs)
3336
<div class="d-flex align-items-center highlight-toolbar px-4 py-2 border border-top-0">
3437
<small class="font-monospace text-body-secondary text-uppercase">@LanguageCode.ToLanguageCodeString()</small>
3538
<div class="d-flex ms-auto">
36-
<Tooltip Title="@clipboardTooltipTitle" role="button" @onclick="CopyToClipboardAsync">
37-
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" />
39+
<Tooltip Title="@clipboardTooltipTitle">
40+
<button type="button" class="bd-demo-copy" aria-label="Copy to clipboard" @onclick="CopyToClipboardAsync">
41+
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" aria-hidden="true" />
42+
</button>
3843
</Tooltip>
44+
<span class="visually-hidden" role="status">@copyStatus</span>
3945
</div>
4046
</div>
4147
<div class="highlight border border-top-0">
@@ -69,9 +75,12 @@ else // Tabs = true
6975
</TitleTemplate>
7076
<Content>
7177
<div class="position-relative d-block float-end mt-3 me-3 me-sm-4">
72-
<Tooltip Title="@clipboardTooltipTitle" role="button" @onclick="CopyToClipboardAsync">
73-
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" />
78+
<Tooltip Title="@clipboardTooltipTitle">
79+
<button type="button" class="bd-demo-copy" aria-label="Copy to clipboard" @onclick="CopyToClipboardAsync">
80+
<Icon Name="@clipboardTooltipIconName" Color="@clipboardTooltipIconColor" aria-hidden="true" />
81+
</button>
7482
</Tooltip>
83+
<span class="visually-hidden" role="status">@copyStatus</span>
7584
</div>
7685
<div class="highlight border border-top-0">
7786
<pre class="mt-0 me-4">

‎BlazorBootstrap.Demo.RCL/Components/Shared/Demo.razor.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public partial class Demo : BlazorBootstrapComponentBase
1010

1111
private string? clipboardTooltipTitle = "Copy to clipboard";
1212

13+
/// <summary>
14+
/// The copy result announced to assistive technology through the status region; empty when there is nothing to announce.
15+
/// </summary>
16+
private string copyStatus = string.Empty;
17+
1318
/// <summary>
1419
/// A reference to this component instance for use in JavaScript calls.
1520
/// </summary>
@@ -68,7 +73,9 @@ protected override async Task OnParametersSetAsync()
6873
[JSInvokable]
6974
public void OnCopyFailJS(string errorMessage)
7075
{
71-
// TODO: show message
76+
copyStatus = "Couldn't copy. Select the code to copy it.";
77+
78+
StateHasChanged();
7279
}
7380

7481
/// <summary>
@@ -80,6 +87,7 @@ public void OnCopySuccessJS()
8087
clipboardTooltipTitle = "Copied!";
8188
clipboardTooltipIconName = IconName.Check2;
8289
clipboardTooltipIconColor = IconColor.Success;
90+
copyStatus = "Copied to clipboard";
8391

8492
StateHasChanged();
8593
}
@@ -93,6 +101,7 @@ public void ResetCopyStatusJS()
93101
clipboardTooltipTitle = "Copy to clipboard";
94102
clipboardTooltipIconName = IconName.Clipboard;
95103
clipboardTooltipIconColor = IconColor.None;
104+
copyStatus = string.Empty;
96105

97106
StateHasChanged();
98107
}

‎BlazorBootstrap.Demo.RCL/Components/Shared/DocsLink.razor‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
@inherits BlazorBootstrapComponentBase
33

44
<div>
5-
<Button Color="ButtonColor.Info" Type="ButtonType.Link" To="@Href">
5+
@* A plain link: it navigates, so it needs no role="button" (rules.md: native elements first). *@
6+
<a class="btn btn-info" href="@Href">
67
<span>@Text</span>
7-
<Icon Class="ml-1" Name="IconName.BoxArrowUpRight" />
8-
</Button>
8+
<Icon Class="ml-1" Name="IconName.BoxArrowUpRight" aria-hidden="true" />
9+
</a>
910
</div>
1011

1112
@code {

‎BlazorBootstrap.Demo.RCL/wwwroot/css/blazorbootstrap.demo.rcl.css‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ h1:focus-visible {
336336
}
337337

338338
[data-bs-theme=dark] .bd-more-libraries .btn-outline-secondary {
339-
--bs-btn-color: var(--bs-secondary-color);
339+
--bs-btn-color: var(--bs-secondary-text-emphasis);
340+
--bs-btn-border-color: var(--bs-secondary-text-emphasis);
340341
}
341342

342343
.bd-lib-logo {
@@ -347,6 +348,37 @@ h1:focus-visible {
347348

348349
/*** END: home ***/
349350

351+
/*
352+
* Demo-site focus indicator (rules.md): Bootstrap's default focus glow is below 3:1, so keyboard focus
353+
* gets a solid outline in the theme's emphasis color. The selector's specificity (0,2,1) beats
354+
* Bootstrap's .btn:focus-visible (0,2,0), while Showcase sites' scoped focus rules (0,3,0) still win.
355+
*/
356+
html :is(a, button, input, select, textarea, summary, .btn, .form-control, .form-select, .form-check-input, .nav-link, .dropdown-item, .page-link, .accordion-button, .list-group-item-action):focus-visible {
357+
outline: 2px solid var(--bs-emphasis-color);
358+
outline-offset: 2px;
359+
box-shadow: none;
360+
}
361+
362+
/* Button-style toggles hide the real input, so the visible label shows the focus outline instead.
363+
The :checked variant (0,4,1) is needed to beat Bootstrap's .btn-check:checked:focus-visible + .btn glow (0,4,0). */
364+
html .btn-check:focus-visible + .btn,
365+
html .btn-check:checked:focus-visible + .btn {
366+
outline: 2px solid var(--bs-emphasis-color);
367+
outline-offset: 2px;
368+
box-shadow: none;
369+
}
370+
371+
/* Copy-to-clipboard button in demo code snippets: icon-only, at least 24px. */
372+
.bd-demo-copy {
373+
border: 0;
374+
background: transparent;
375+
color: inherit;
376+
padding: .25rem;
377+
line-height: 1;
378+
min-width: 1.5rem;
379+
min-height: 1.5rem;
380+
}
381+
350382
.bb-anchor-link {
351383
font-weight: 400;
352384
color: rgba(13,110,253,0.5);

‎BlazorBootstrap.Demo.RCL/wwwroot/css/prism-vs.min.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pre[class*=language-] {
5454
}
5555

5656
.prism-token.prism-boolean, .prism-token.prism-constant, .prism-token.prism-inserted, .prism-token.prism-number, .prism-token.prism-symbol, .prism-token.prism-url, .prism-token.prism-variable {
57-
color: #36acaa
57+
color: #007672
5858
}
5959

6060
.language-autohotkey .prism-token.prism-selector, .prism-language-json .prism-token.prism-boolean, .prism-language-json .prism-token.prism-number, .prism-token.prism-atrule, .prism-token.prism-attr-value, .prism-token.prism-keyword, code[class*=language-css] {
@@ -86,15 +86,15 @@ pre[class*=language-] {
8686
}
8787

8888
.language-json .prism-token.prism-property, .prism-token.prism-class-name {
89-
color: #2b91af
89+
color: #1a6f8a
9090
}
9191

9292
.prism-token.prism-selector, .prism-token.prism-tag {
9393
color: maroon
9494
}
9595

9696
.prism-token.prism-attr-name, .prism-token.prism-entity, .prism-token.prism-property, .prism-token.prism-regex {
97-
color: red
97+
color: #d00000
9898
}
9999

100100
.prism-token.prism-directive.prism-tag .prism-tag {

‎BlazorBootstrap.Demo.RCL/wwwroot/css/prism-vsc-dark-plus.min.css‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ pre[class*=language-] {
174174
}
175175

176176
.prism-token.prism-tag .prism-token.prism-punctuation {
177-
color: grey
177+
color: #999999
178178
}
179179

180180
.prism-token.prism-cdata {
181-
color: grey
181+
color: #999999
182182
}
183183

184184
.prism-token.prism-attr-name {

‎blazorbootstrap/Components/Preload/Preload.razor‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
}
1212
else
1313
{
14-
<div class="text-center @spinnerColor">
15-
<div class="spinner-border" role="status">
14+
<div class="text-center">
15+
<div class="spinner-border @spinnerColor" aria-hidden="true">
1616
<span class="visually-hidden">Loading...</span>
1717
</div>
1818
@if (!string.IsNullOrWhiteSpace(loadingText))
@@ -28,6 +28,8 @@
2828
</div>
2929
</div>
3030
</div>
31+
@* Filled by blazor.bootstrap.js after the overlay shows, so screen readers announce it (see Preload.OnAfterRenderAsync). *@
32+
<div class="visually-hidden" role="status"></div>
3133
</div>
3234

3335
@if (showBackdrop)

0 commit comments

Comments
 (0)