[CL-1130] Fix a11y and storybook errors in UIF-owned code (#19921)

This commit is contained in:
Vicki League
2026-04-21 14:16:48 -04:00
committed by GitHub
parent 47e5d3af09
commit ea58682714
44 changed files with 297 additions and 96 deletions

View File

@@ -28,7 +28,10 @@ const preview: Preview = {
],
parameters: {
a11y: {
context: "#storybook-root",
context: {
include: ["#storybook-root", ".cdk-overlay-container"],
exclude: [".cdk-visually-hidden"],
},
},
controls: {
matchers: {

View File

@@ -16,7 +16,10 @@ const testRunnerConfig: TestRunnerConfig = {
page,
// context
"#storybook-root",
{
include: ["#storybook-root", ".cdk-overlay-container"],
exclude: [".cdk-visually-hidden"],
},
// axeOptions, see https://www.deque.com/axe/core-documentation/api-documentation/#parameters-axerun
{

View File

@@ -6286,5 +6286,19 @@
},
"downloadFailed": {
"message": "Failed to download."
},
"sideNavigation": {
"message": "Side navigation"
},
"skipLink": {
"message": "Skip link"
},
"callout": {
"message": "Callout",
"description": "'Callout' is a noun. It is the name of a page component that displays at the top of a page and contains information like an alert or notification. This string will be used to label the callout for a screenreader when multiple callouts are on a page, like 'Callout 1' and 'Callout 2'."
},
"progressBar": {
"message": "Progress bar",
"description": "This is the name of a page component that displays progress to the user. This string will be used to label the progress bar for a screenreader when multiple progress bars are on a page, like 'Progress bar 1' and 'Progress bar 2'."
}
}

View File

@@ -78,6 +78,7 @@ export default {
learnMore: "Learn more",
danger: "error",
close: "Close",
callout: "Callout",
}),
},
{

View File

@@ -70,7 +70,7 @@ class ExtensionPoppedContainerComponent {}
selector: "vault-placeholder",
template: /*html*/ `
<bit-section>
<bit-item-group aria-label="Mock Vault Items">
<bit-item-group>
<bit-item *ngFor="let item of data; index as i">
<button type="button" bit-item-content>
<i slot="start" class="bwi bwi-globe tw-text-3xl tw-text-muted" aria-hidden="true"></i>
@@ -519,57 +519,83 @@ export const PopupPageWithFooter: Story = {
}),
};
export const CompactMode: Story = {
export const RegularMode: Story = {
render: (args) => ({
props: args,
template: /* HTML */ `
<div class="tw-flex tw-gap-6 tw-text-main">
<div id="regular-example">
<p>Relaxed</p>
<p class="example-label"></p>
<extension-container>
<mock-vault-subpage></mock-vault-subpage>
</extension-container>
</div>
<div id="compact-example" class="tw-bit-compact">
<p>Compact</p>
<p class="example-label"></p>
<extension-container>
<mock-vault-subpage></mock-vault-subpage>
</extension-container>
</div>
<div id="regular-example">
<p>Relaxed</p>
<p class="example-label"></p>
<extension-container>
<mock-vault-subpage></mock-vault-subpage>
</extension-container>
</div>
`,
}),
play: async (context) => {
const canvasEl = context.canvasElement;
const updateLabel = (containerId: string) => {
const compact = canvasEl.querySelector(
`#${containerId} [data-testid=popup-layout-scroll-region]`,
);
const example = canvasEl.querySelector(
`#regular-example [data-testid=popup-layout-scroll-region]`,
);
if (!compact) {
// eslint-disable-next-line
console.error(`#${containerId} [data-testid=popup-layout-scroll-region] not found`);
return;
}
if (!example) {
// eslint-disable-next-line
console.error(`#regular-example [data-testid=popup-layout-scroll-region] not found`);
return;
}
const label = canvasEl.querySelector(`#${containerId} .example-label`);
const label = canvasEl.querySelector(`#regular-example .example-label`);
if (!label) {
// eslint-disable-next-line
console.error(`#${containerId} .example-label not found`);
return;
}
if (!label) {
// eslint-disable-next-line
console.error(`#regular-example .example-label not found`);
return;
}
const percentVisible =
100 -
Math.round((100 * (compact.scrollHeight - compact.clientHeight)) / compact.scrollHeight);
label.textContent = `${percentVisible}% above the fold`;
};
updateLabel("compact-example");
updateLabel("regular-example");
const percentVisible =
100 -
Math.round((100 * (example.scrollHeight - example.clientHeight)) / example.scrollHeight);
label.textContent = `${percentVisible}% above the fold`;
},
};
export const CompactMode: Story = {
render: (args) => ({
props: args,
template: /* HTML */ `
<div id="compact-example" class="tw-bit-compact">
<p>Compact</p>
<p class="example-label"></p>
<extension-container>
<mock-vault-subpage></mock-vault-subpage>
</extension-container>
</div>
`,
}),
play: async (context) => {
const canvasEl = context.canvasElement;
const example = canvasEl.querySelector(
`#compact-example [data-testid=popup-layout-scroll-region]`,
);
if (!example) {
// eslint-disable-next-line
console.error(`#compact-example [data-testid=popup-layout-scroll-region] not found`);
return;
}
const label = canvasEl.querySelector(`#compact-example .example-label`);
if (!label) {
// eslint-disable-next-line
console.error(`#compact-example .example-label not found`);
return;
}
const percentVisible =
100 -
Math.round((100 * (example.scrollHeight - example.clientHeight)) / example.scrollHeight);
label.textContent = `${percentVisible}% above the fold`;
},
};
@@ -672,23 +698,34 @@ export const Notice: Story = {
}),
};
export const WidthOptions: Story = {
export const NarrowWidth: Story = {
render: (args) => ({
props: args,
template: /* HTML */ `
<div class="tw-flex tw-flex-col tw-gap-4 tw-text-main">
<div>Default:</div>
<div class="tw-h-[640px] tw-w-[480px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
<div>Wide:</div>
<div class="tw-h-[640px] tw-w-[480px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
<div>Extra wide:</div>
<div class="tw-h-[640px] tw-w-[600px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
<div class="tw-h-[640px] tw-w-[380px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
`,
}),
};
export const DefaultWidth: Story = {
render: (args) => ({
props: args,
template: /* HTML */ `
<div class="tw-h-[640px] tw-w-[480px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
`,
}),
};
export const WideWidth: Story = {
render: (args) => ({
props: args,
template: /* HTML */ `
<div class="tw-h-[640px] tw-w-[600px] tw-border tw-border-solid tw-border-secondary-300">
<mock-vault-page></mock-vault-page>
</div>
`,
}),
@@ -704,7 +741,7 @@ export const WithVirtualScrollChild: Story = {
<mock-search slot="above-scroll-area"></mock-search>
<bit-section>
@defer (on immediate) {
<bit-item-group aria-label="Mock Vault Items">
<bit-item-group>
<cdk-virtual-scroll-viewport itemSize="59" bitScrollLayout>
<bit-item *cdkVirtualFor="let item of data; index as i">
<button type="button" bit-item-content>

View File

@@ -33,6 +33,7 @@
!disablePadding(),
}"
bitScrollLayoutHost
[tabindex]="hideOverflow() ? null : '0'"
>
<ng-content></ng-content>
</div>

View File

@@ -1,4 +1,4 @@
<div class="tw-h-full tw-overflow-y-auto [&>*]:tw-h-full [&>*]:tw-overflow-y-auto">
<div class="tw-h-full tw-overflow-y-auto [&>*]:tw-h-full [&>*]:tw-overflow-y-auto" tabindex="0">
<ng-content></ng-content>
</div>
<footer class="tw-bg-background tw-border-0 tw-border-t tw-border-secondary-300 tw-border-solid">

View File

@@ -4938,5 +4938,19 @@
"saveSendEditsFailed": {
"message": "Saving Send edits failed",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"sideNavigation": {
"message": "Side navigation"
},
"skipLink": {
"message": "Skip link"
},
"callout": {
"message": "Callout",
"description": "'Callout' is a noun. It is the name of a page component that displays at the top of a page and contains information like an alert or notification. This string will be used to label the callout for a screenreader when multiple callouts are on a page, like 'Callout 1' and 'Callout 2'."
},
"progressBar": {
"message": "Progress bar",
"description": "This is the name of a page component that displays progress to the user. This string will be used to label the progress bar for a screenreader when multiple progress bars are on a page, like 'Progress bar 1' and 'Progress bar 2'."
}
}

View File

@@ -131,6 +131,8 @@ const translations: Record<string, string> = {
toggleCollapse: "toggle collapse",
close: "Close",
loading: "Loading",
sideNavigation: "Side navigation",
skipLink: "Skip link",
};
export default {

View File

@@ -13401,7 +13401,21 @@
"message": "Saving Send edits failed",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"export": {
"export": {
"message": "Export"
},
"sideNavigation": {
"message": "Side navigation"
},
"skipLink": {
"message": "Skip link"
},
"callout": {
"message": "Callout",
"description": "'Callout' is a noun. It is the name of a page component that displays at the top of a page and contains information like an alert or notification. This string will be used to label the callout for a screenreader when multiple callouts are on a page, like 'Callout 1' and 'Callout 2'."
},
"progressBar": {
"message": "Progress bar",
"description": "This is the name of a page component that displays progress to the user. This string will be used to label the progress bar for a screenreader when multiple progress bars are on a page, like 'Progress bar 1' and 'Progress bar 2'."
}
}

View File

@@ -19,6 +19,7 @@ export function createAccessIntelligenceI18nMock(): I18nMockService {
return new I18nMockService({
// --- Shared ---
loading: "Loading",
progressBar: "Progress bar",
// --- Shared table / search ---
search: "Search",

View File

@@ -31,6 +31,7 @@ export default {
good: "Good",
strong: "Strong",
close: "Close",
callout: "Callout",
});
},
},

View File

@@ -1,11 +1,12 @@
@let title = titleComputed();
@let icon = iconComputed();
<aside
class="tw-mb-4 tw-border tw-border-solid tw-rounded-xl tw-ps-4 tw-pe-2 tw-flex tw-flex-col tw-relative"
[class]="calloutClass()"
[attr.aria-labelledby]="titleId"
[attr.aria-labelledby]="title ? titleId : null"
[attr.aria-label]="!title ? accessibleLandmarkName() : null"
>
@let title = titleComputed();
@let icon = iconComputed();
<ng-template #contentTpl>
<div bitTypography="body2" class="tw-pr-4">
<ng-content />

View File

@@ -21,6 +21,7 @@ describe("Callout", () => {
warning: "Warning",
error: "Error",
close: "Close",
callout: "Callout",
}),
},
],

View File

@@ -47,9 +47,13 @@ export class CalloutComponent implements OnInit {
readonly icon = input<BitwardenIcon | null>();
/** The title of the callout. If not provided, a default title will be used if callout type is `warning | danger`. Pass in `null` to not display a title. */
readonly title = input<string | null>();
/** If a title is not supplied, provide a screenreader-accessible unique name for this callout */
readonly accessibleName = input<string>();
readonly closeLabel = this.i18nService.t("close");
private readonly calloutId = nextId++;
private readonly dismiss$ = new Subject<void>();
readonly dismiss = outputFromObservable(this.dismiss$);
protected readonly isDismissible = signal(false);
@@ -84,7 +88,7 @@ export class CalloutComponent implements OnInit {
return title;
});
protected readonly titleId = `bit-callout-title-${nextId++}`;
protected readonly titleId = `bit-callout-title-${this.calloutId}`;
constructor(private readonly i18nService: I18nService) {}
@@ -129,4 +133,11 @@ export class CalloutComponent implements OnInit {
protected readonly paddingTopClass = computed(() => {
return this.isDismissible() ? "tw-pt-1.5" : undefined;
});
protected readonly accessibleLandmarkName = computed(() => {
return (
this.accessibleName() ??
`${this.i18nService.t("callout")} ${this.calloutId + 1}, ${this.type()}`
);
});
}

View File

@@ -93,7 +93,8 @@ callout type. To avoid displaying any icon, pass in `null`.
## No Title
Pass in `null` to not display a title. If no title is provided, a default title will be used if
callout type is `warning | danger`.
callout type is `warning | danger`. See Accessibility notes for guidelines on what to do if no title
is provided to variants that don't have a default title.
<Canvas of={stories.NoTitle} />
@@ -105,6 +106,13 @@ A close button will be displayed when binding to the `(dismiss)` output.
## Accessibility
Callouts use the `aside` landmark under the hood. Landmarks must have a unique accessible name if
there is more than one instance of a given landmark on a page
([see Deque University Axe rule](https://dequeuniversity.com/rules/axe/4.10/landmark-unique?application=axeAPI)).
If the callout does not have a visible title, an accessible name should still be provided via the
`accessibleName` input on the callout. If neither title or accessible name is provided, the callout
will default to "callout \{number\}, \{type\}" as its unique accessible name.
Ensure color contrast remains WCAG compliant with the callout's background. This is especially
important when adding `bit-link` or `bit-button` to the content area since the callout background is
colored. Currently only the `info` and `default` callouts are WCAG compliant for the `primary`

View File

@@ -22,6 +22,7 @@ export default {
error: "Error",
close: "Close",
loading: "Loading",
callout: "Callout",
});
},
},
@@ -44,7 +45,7 @@ const calloutContent =
export const Base: Story = {
render: (args) => ({
props: args,
template: `
template: /*html*/ `
<bit-callout [type]="type" [icon]="icon" [title]="title">${calloutContent}</bit-callout>
`,
}),
@@ -56,7 +57,7 @@ export const Base: Story = {
export const AllVariants: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-flex tw-flex-col tw-gap-4">
<bit-callout type="info" title="Info">${calloutContent}</bit-callout>
<bit-callout type="success" title="Success">${calloutContent}</bit-callout>
@@ -70,7 +71,7 @@ export const AllVariants: Story = {
export const CustomIcon: Story = {
render: () => ({
template: `
template: /*html*/ `
<bit-callout title="${calloutTitle}" icon="bwi-star">${calloutContent}</bit-callout>
`,
}),
@@ -78,15 +79,26 @@ export const CustomIcon: Story = {
export const NoTitle: Story = {
render: () => ({
template: `
<bit-callout [title]="null">${calloutContent}</bit-callout>
template: /*html*/ `
<bit-callout [title]="null" accessibleName="Success callout">${calloutContent}</bit-callout>
`,
}),
};
export const WithAccessibleNameFallback: Story = {
render: () => ({
template: /*html*/ `
<div class="tw-flex tw-flex-col tw-gap-4">
<bit-callout type="info">${calloutContent}</bit-callout>
<bit-callout type="success">${calloutContent}</bit-callout>
</div>
`,
}),
};
export const NoIcon: Story = {
render: () => ({
template: `
template: /*html*/ `
<bit-callout title="${calloutTitle}" [icon]="null">${calloutContent}</bit-callout>
`,
}),
@@ -94,8 +106,8 @@ export const NoIcon: Story = {
export const WithInlineLink: Story = {
render: () => ({
template: `
<bit-callout>
template: /*html*/ `
<bit-callout accessibleName="Success callout">
${calloutContent}
<a bitLink endIcon="bwi-angle-right" class="tw-ml-2">Visit the help center</a>
</bit-callout>
@@ -105,7 +117,7 @@ export const WithInlineLink: Story = {
export const WithFooterButtons: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-flex tw-flex-col tw-gap-4">
<bit-callout title="${calloutTitle}">
${calloutContent}
@@ -124,9 +136,9 @@ export const WithFooterButtons: Story = {
export const WithCloseButton: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-flex tw-flex-col tw-gap-4">
<bit-callout (dismiss)="onDismiss($event)">
<bit-callout (dismiss)="onDismiss($event)" accessibleName="Success callout">
${calloutContent}
</bit-callout>
<bit-callout title="${calloutTitle}" (dismiss)="onDismiss($event)">

View File

@@ -234,6 +234,8 @@ export default {
yes: "Yes",
no: "No",
loading: "Loading",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},

View File

@@ -74,6 +74,7 @@
'tw-invisible tw-overflow-y-hidden': loading(),
'tw-py-4': background() === 'alt',
}"
tabindex="0"
>
<ng-content select="[bitDialogContent]"></ng-content>
<div #scrollBottom></div>

View File

@@ -170,6 +170,7 @@ export default {
accept: "Accept",
decline: "Decline",
close: "Close",
callout: "Callout",
});
},
},

View File

@@ -19,7 +19,10 @@
<ng-content select="[bitDialogTitle]"></ng-content>
</h1>
</div>
<div class="tw-overflow-y-auto tw-px-6 tw-mb-6 tw-text-center tw-text-base tw-break-words">
<div
class="tw-overflow-y-auto tw-px-6 tw-mb-6 tw-text-center tw-text-base tw-break-words"
tabindex="0"
>
<ng-content select="[bitDialogContent]"></ng-content>
</div>
<div class="tw-flex tw-flex-col tw-gap-2 tw-px-6">

View File

@@ -14,6 +14,7 @@ import { BitwardenIcon } from "../shared/icon";
"[class]": "classList()",
"[attr.aria-hidden]": "ariaLabel() ? null : true",
"[attr.aria-label]": "ariaLabel()",
"[attr.role]": "ariaLabel() ? 'img' : 'presentation'",
},
template: ``,
changeDetection: ChangeDetectionStrategy.OnPush,

View File

@@ -54,6 +54,8 @@ export default {
submenu: "submenu",
toggleCollapse: "toggle collapse",
loading: "Loading",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},
@@ -204,7 +206,7 @@ export const TextOverflowWrap: Story = {
};
const multipleActionListTemplate = /*html*/ `
<bit-item-group aria-label="Multiple Action List">
<bit-item-group>
<bit-item>
<button type="button" bit-item-content>
<i slot="start" class="bwi bwi-globe tw-text-2xl tw-text-muted" aria-hidden="true"></i>
@@ -333,7 +335,7 @@ export const SingleActionList: Story = {
render: (args) => ({
props: args,
template: /*html*/ `
<bit-item-group aria-label="Single Action List">
<bit-item-group>
<bit-item>
<a bit-item-content href="#">
Foobar
@@ -379,7 +381,7 @@ export const SingleActionWithBadge: Story = {
render: (args) => ({
props: args,
template: /*html*/ `
<bit-item-group aria-label="Single Action With Badge">
<bit-item-group>
<bit-item>
<a bit-item-content href="#">
Foobar
@@ -417,7 +419,7 @@ export const VirtualScrolling: Story = {
},
template: /*html*/ `
<cdk-virtual-scroll-viewport [itemSize]="54" class="tw-h-[500px]">
<bit-item-group aria-label="Virtual Scrolling">
<bit-item-group>
<bit-item *cdkVirtualFor="let item of data">
<button type="button" bit-item-content>
<i slot="start" class="bwi bwi-globe tw-text-2xl tw-text-muted" aria-hidden="true"></i>

View File

@@ -1,10 +1,15 @@
import { ActivatedRoute } from "@angular/router";
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
import { ClientType } from "@bitwarden/common/enums";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ButtonModule } from "../button";
import { I18nMockService } from "../utils";
import { LandingFooterComponent } from "./landing-footer.component";
import { LandingHeaderComponent } from "./landing-header.component";
import { LandingLayoutComponent } from "./landing-layout.component";
class MockPlatformUtilsService implements Partial<PlatformUtilsService> {
@@ -22,12 +27,23 @@ export default {
component: LandingLayoutComponent,
decorators: [
moduleMetadata({
imports: [ButtonModule],
imports: [ButtonModule, LandingFooterComponent, LandingHeaderComponent],
providers: [
{
provide: PlatformUtilsService,
useClass: MockPlatformUtilsService,
},
{
provide: ActivatedRoute,
useValue: () => {},
},
{
provide: I18nService,
useFactory: () =>
new I18nMockService({
appLogoLabel: "logo label",
}),
},
],
}),
],

View File

@@ -10,7 +10,10 @@
<div
class="tw-fixed tw-z-50 tw-w-full tw-flex tw-justify-center tw-opacity-0 focus-within:tw-opacity-100 tw-pointer-events-none focus-within:tw-pointer-events-auto"
>
<nav class="tw-bg-background-alt3 tw-rounded-md tw-rounded-t-none tw-py-2 tw-text-alt2">
<nav
class="tw-bg-background-alt3 tw-rounded-md tw-rounded-t-none tw-py-2 tw-text-alt2"
[attr.aria-label]="'skipLink' | i18n"
>
<a
#skipLink
bitLink
@@ -19,8 +22,9 @@
[routerLink]="[]"
(click)="focusMainContent()"
linkType="light"
>{{ "skipToContent" | i18n }}</a
>
{{ "skipToContent" | i18n }}
</a>
</nav>
</div>

View File

@@ -7,4 +7,7 @@ export const mockLayoutI18n = {
loading: "Loading",
resizeSideNavigation: "Resize side navigation",
close: "Close",
sideNavigation: "Side navigation",
skipLink: "Skip Link",
callout: "Callout",
};

View File

@@ -6,6 +6,7 @@
[attr.aria-label]="ariaLabel()"
cdkTrapFocus
[cdkTrapFocusAutoCapture]="ariaRole() === 'dialog'"
tabindex="0"
>
<ng-content></ng-content>
</div>

View File

@@ -50,6 +50,8 @@ export default {
skipToContent: "Skip to content",
loading: "Loading",
resizeSideNavigation: "Resize side navigation",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},

View File

@@ -36,6 +36,8 @@ export default {
skipToContent: "Skip to content",
loading: "Loading",
resizeSideNavigation: "Resize side navigation",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},

View File

@@ -34,6 +34,8 @@ export default {
skipToContent: "Skip to content",
loading: "Loading",
resizeSideNavigation: "Resize side navigation",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},

View File

@@ -1,7 +1,13 @@
@let open = sideNavService.open();
@let isOverlay = sideNavService.isOverlay();
<div class="tw-relative tw-h-full">
<div
class="tw-relative tw-h-full"
[attr.role]="isOverlay ? 'dialog' : null"
[attr.aria-modal]="isOverlay ? 'true' : null"
[cdkTrapFocus]="isOverlay"
[attr.aria-label]="isOverlay ? ('sideNavigation' | i18n) : null"
>
<nav
id="bit-side-nav"
class="tw-sticky tw-inset-y-0 tw-left-0 tw-z-30 tw-flex tw-h-full tw-flex-col tw-overflow-hidden tw-bg-bg-nav tw-text-fg-nav tw-outline-none"
@@ -11,10 +17,8 @@
? '--color-nav-fg-primary: var(--color-nav-fg-secondary); --color-nav-bg-primary: var(--color-nav-bg-secondary); --color-nav-bg-primary-strong: var(--color-nav-bg-secondary-strong); --color-nav-bg-primary-hover: var(--color-nav-bg-secondary-hover); --color-nav-bg-primary-hover-strong: var(--color-nav-bg-secondary-hover-strong); --color-nav-border-primary-focus: var(--color-nav-border-secondary-focus); --color-nav-border-primary: var(--color-nav-border-secondary);'
: ''
"
[cdkTrapFocus]="isOverlay"
[attr.role]="isOverlay ? 'dialog' : null"
[attr.aria-modal]="isOverlay ? 'true' : null"
(keydown)="handleKeyDown($event)"
[attr.aria-label]="'sideNavigation' | i18n"
>
<div
class="tw-flex-1 tw-min-h-0 tw-overflow-auto tw-overscroll-none"

View File

@@ -25,6 +25,7 @@ export default {
useFactory: () => {
return new I18nMockService({
percentageCompleted: "__$1__% complete",
progressBar: "Progress bar",
});
},
},

View File

@@ -1,6 +1,8 @@
<div class="tw-flex tw-flex-col">
<div [id]="labelId" class="!tw-mb-1 empty:tw-hidden" bitTypography="h5">
<ng-content select="[slot='label']" />
<div [id]="labelId" class="!tw-mb-0 has-[[slot='label']]:!tw-mb-1" bitTypography="h5">
<ng-content select="[slot='label']">
<span class="tw-sr-only">{{ accessibleNameComputed() }}</span>
</ng-content>
</div>
<div class="tw-overflow-hidden tw-rounded tw-bg-secondary-100 tw-h-2 tw-my-1">
<div

View File

@@ -45,12 +45,20 @@ export class ProgressBarComponent {
readonly ariaValueText = input<string>();
/** The ID of the progress bar element, used for attaching `aria-describedby` attributes. */
readonly progressBarId = input<string>(`bit-progress-bar-${this.id}`);
/**
* If a label is not supplied, provide a screenreader-accessible unique name for this progress bar
*/
readonly accessibleName = input<string>();
private readonly i18nService = inject(I18nService);
// Necessary for `aria-labelledby` to point to the label element
protected readonly labelId = `bit-progress-bar-label-${this.id}`;
protected readonly accessibleNameComputed = computed(() => {
return this.accessibleName() ?? `${this.i18nService.t("progressBar")} ${this.id + 1}`;
});
protected readonly clampedValue = computed(() => Math.max(0, Math.min(100, this.value())));
protected readonly defaultStartText = computed(() => {

View File

@@ -73,6 +73,11 @@ For a strength indicator use the following variants:
## Accessibility
Progress bars must have a unique accessible name. If the progress does not have a label passed to
the `label` slot, an accessible name should still be provided via the `accessibleName` input. If
neither label or accessible name is provided, the progress bar will default to "progress bar
\{number\}" as its unique accessible name.
In the case of a password strength indicator; `aria-describedby` is used on the password field and
points to the `id` of the progress bar. This results in the screen reader reading the password
strength to the user after they finish typing.

View File

@@ -20,6 +20,7 @@ export default {
useFactory: () => {
return new I18nMockService({
percentageCompleted: "__$1__% complete",
progressBar: "Progress bar",
});
},
},
@@ -35,6 +36,7 @@ export default {
args: {
variant: "primary",
value: "50",
accessibleName: "Upload progress",
},
} as Meta;
@@ -45,7 +47,7 @@ export const Base: Story = {
props: {
...args,
},
template: `
template: /*html*/ `
<div class="tw-w-[552px]">
<bit-progress-bar ${formatArgsForCodeSnippet<ProgressBarComponent>(args)} />
</div>
@@ -55,7 +57,7 @@ export const Base: Story = {
export const AllVariants: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-flex tw-flex-col tw-w-[552px] tw-gap-4">
<bit-progress-bar variant="primary" [value]="20" [hideStartHint]="true">
<bit-label slot="label">primary</bit-label>
@@ -79,7 +81,7 @@ export const AllVariants: Story = {
export const WithLabelAndHelperHint: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-w-[552px]">
<bit-progress-bar [value]="50">
<bit-label slot="label">File name</bit-label>
@@ -93,7 +95,7 @@ export const WithLabelAndHelperHint: Story = {
export const StartHint: Story = {
render: () => ({
template: `
template: /*html*/ `
<div class="tw-w-[552px] tw-mb-8">
<bit-progress-bar [value]="10">
<bit-label slot="label">Default</bit-label>
@@ -125,3 +127,10 @@ export const StartHint: Story = {
`,
}),
};
export const WithAccessibleNameFallback: Story = {
...Base,
args: {
accessibleName: undefined,
},
};

View File

@@ -7,7 +7,8 @@ import { KitchenSinkSharedModule } from "../kitchen-sink-shared.module";
selector: "bit-kitchen-sink-empty",
imports: [KitchenSinkSharedModule],
template: `
<div class="tw-flex tw-items-center tw-justify-center tw-min-h-96">
<div class="tw-flex tw-items-center tw-justify-center tw-min-h-96 tw-flex-col">
<h2 bitTypography="h2">A Page with Content</h2>
<bit-no-items>
<ng-container slot="icon">
<bit-icon name="bwi-grid" aria-hidden="true"></bit-icon>

View File

@@ -33,6 +33,7 @@ import { KitchenSinkSharedModule } from "../kitchen-sink-shared.module";
required: "required",
selectPlaceholder: "-- Select --",
toggleVisibility: "Toggle visibility",
progressBar: "Progress bar",
});
},
},

View File

@@ -78,6 +78,8 @@ export default {
no: "No",
loading: "Loading",
resizeSideNavigation: "Resize side navigation",
sideNavigation: "Side navigation",
skipLink: "Skip link",
});
},
},

View File

@@ -10,6 +10,7 @@ import { BitSvg, isBitSvg } from "@bitwarden/assets/svg";
"[attr.aria-label]": "ariaLabel()",
"[innerHtml]": "innerHtml()",
class: "tw-max-h-full tw-flex tw-justify-center",
"[attr.role]": "ariaLabel() ? 'img' : 'presentation'",
},
template: ``,
changeDetection: ChangeDetectionStrategy.OnPush,

View File

@@ -60,6 +60,7 @@ export default {
warning: "Warning",
info: "Info",
loading: "Loading",
progressBar: "Progress bar",
});
},
},

View File

@@ -38,6 +38,7 @@ export default {
storageFullDescription: `You have used all ${args[0]} GB of your encrypted storage. To continue storing files, add more storage.`,
addStorage: "Add storage",
removeStorage: "Remove storage",
progressBar: "Progress bar",
};
return translations[key] || key;
},

View File

@@ -84,6 +84,7 @@ export default {
secretsManager: "Secrets Manager",
additionalStorageGb: "Additional storage (GB)",
additionalServiceAccountsV2: "Additional machine accounts",
callout: "Callout",
};
return translations[key] || key;
},

View File

@@ -33,7 +33,7 @@
"build-storybook": "ng run components:build-storybook",
"build-storybook:ci": "ng run components:build-storybook --webpack-stats-json",
"build-storybook:autofill:ci": "cd apps/browser/src/autofill/content/components && npm run storybook:build-lit:ci",
"test-stories": "test-storybook --url http://localhost:6006",
"test-stories": "test-storybook --url http://localhost:6006 --maxWorkers=2 --testTimeout=100000 --failOnConsole",
"test-stories:watch": "test-stories --watch",
"icons:build": "ts-node scripts/material-icons/build-with-bwi-names.ts",
"icons:migrate": "ts-node scripts/material-icons/migrate-icon-names.ts",