Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<h4>Try it: tab through the controls below</h4>

<div class="playground">
<button type="button" [attr.aria-expanded]="expanded()" (click)="toggle()">Settings</button>
<button shButton class="primary raised" [attr.aria-expanded]="expanded()" (click)="toggle()">Settings</button>

<label>
<input type="checkbox" checked />
<sh-checkbox class="primary">
<input type="checkbox" [formField]="termsForm" />
Accept terms
</label>
</sh-checkbox>

<label>
Email
<input type="email" required aria-invalid="true" value="foo" />
</label>
<sh-form-field>
<label>Email</label>
<input type="email" [formField]="emailForm" [attr.aria-required]="true" [attr.aria-invalid]="emailInvalid()" />
</sh-form-field>

<div role="listbox" aria-label="Fruit">
<div role="option" aria-selected="false" tabindex="0">Pears</div>
<div role="option" aria-selected="true" tabindex="0">Apples</div>
<div role="option" aria-selected="false" tabindex="0">Plums</div>
</div>
<sh-list class="primary" listRole="listbox" label="Fruit" [(value)]="fruit">
<button value="pears">Pears</button>
<button value="apples">Apples</button>
<button value="plums">Plums</button>
</sh-list>

<button type="button" (click)="save()">Save draft (live region)</button>
<button shButton class="primary" (click)="save()">Save draft (live region)</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@
align-items: flex-start;
gap: 0.75rem;

[role='listbox'] {
display: flex;
sh-list {
flex-direction: row;
gap: 0.5rem;

[role='option'] {
padding: 0.25rem 0.75rem;
border: 1px solid var(--base-5);
border-radius: var(--shape-1);
cursor: pointer;

&[aria-selected='true'] {
background: var(--base-3);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Component, inject, signal } from '@angular/core';
import { Component, computed, inject, signal } from '@angular/core';
import { form, FormField, required } from '@angular/forms/signals';
import { ShipScreenreader } from '@ship-ui/core/ship-screenreader';
import { ShipA11yAnnouncerService } from '@ship-ui/core/ship-a11y-announcer';
import { ShipButton } from '@ship-ui/core/ship-button';
import { ShipCheckbox } from '@ship-ui/core/ship-checkbox';
import { ShipFormField } from '@ship-ui/core/ship-form-field';
import { ShipList } from '@ship-ui/core/ship-list';

@Component({
selector: 'basic-screenreader-example',
standalone: true,
imports: [ShipScreenreader],
imports: [ShipScreenreader, ShipButton, ShipCheckbox, ShipFormField, ShipList, FormField],
templateUrl: './basic-screenreader.html',
styleUrl: './basic-screenreader.scss',
})
Expand All @@ -15,6 +20,19 @@ export class BasicScreenreader {
expanded = signal(false);
saved = signal(0);

// Signal forms drive the checkbox and email field; the simulator announces
// the states these produce (checked, required, invalid …).
terms = signal(true);
termsForm = form(this.terms);

email = signal('foo');
emailForm = form(this.email, (path) => {
required(path);
});
emailInvalid = computed(() => !this.email().includes('@'));

fruit = signal('apples');

toggle() {
this.expanded.update((value) => !value);
}
Expand Down