-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(collapse): add accessibility elements of the collapse (#982)
* feat(collapse): add accessibility elements of the collapse * fix: small fixes --------- Co-authored-by: Quentin Deroubaix <quentin.deroubaix@amadeus.com>
- Loading branch information
1 parent
fd3cda6
commit 648c8c6
Showing
9 changed files
with
89 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 16 additions & 10 deletions
26
angular/demo/bootstrap/src/app/samples/collapse/default.route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular-bootstrap'; | ||
import {Component} from '@angular/core'; | ||
import {CollapseDirective} from '@agnos-ui/angular-bootstrap'; | ||
import {Component, signal} from '@angular/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule], | ||
imports: [CollapseDirective], | ||
template: ` | ||
<p class="d-inline-flex gap-1"> | ||
<button class="btn btn-primary" type="button" (click)="collapse.api.open()">Open collapse</button> | ||
<button class="btn btn-primary" type="button" (click)="collapse.api.close()">Close collapse</button> | ||
<button class="btn btn-primary" type="button" (click)="collapse.api.toggle()">Toggle collapse</button> | ||
</p> | ||
<div auCollapse #collapse="auCollapse"> | ||
<button class="btn btn-primary mb-2" type="button" aria-controls="auId-0" [attr.aria-expanded]="expanded()" (click)="toggle()"> | ||
Toggle collapse | ||
</button> | ||
<div auCollapse auId="auId-0" [auVisible]="expanded()" (auHidden)="onHidden()"> | ||
<div class="card card-body">Visible content</div> | ||
</div> | ||
`, | ||
}) | ||
export default class DefaultCollapseComponent {} | ||
export default class DefaultCollapseComponent { | ||
readonly expanded = signal(true); | ||
toggle() { | ||
this.expanded.update((expanded) => !expanded); | ||
} | ||
onHidden() { | ||
console.log('Hidden'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 7 additions & 16 deletions
23
react/demo/src/bootstrap/samples/collapse/Default.route.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
svelte/demo/src/bootstrap/samples/collapse/Default.route.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
<script lang="ts"> | ||
import {Collapse} from '@agnos-ui/svelte-bootstrap/components/collapse'; | ||
let collapse: Collapse; | ||
let visible = $state(true); | ||
</script> | ||
|
||
<p class="d-inline-flex gap-1"> | ||
<button class="btn btn-primary" type="button" onclick={() => collapse.api.open()}>Open collapse</button> | ||
<button class="btn btn-primary" type="button" onclick={() => collapse.api.close()}>Close collapse</button> | ||
<button class="btn btn-primary" type="button" onclick={() => collapse.api.toggle()}>Toggle collapse</button> | ||
</p> | ||
<Collapse bind:this={collapse} onHidden={() => console.log('Hidden')}><div class="card card-body">Visible content</div></Collapse> | ||
<button class="btn btn-primary mb-2" type="button" aria-controls="auId-0" aria-expanded={visible} onclick={() => (visible = !visible)} | ||
>Toggle collapse</button | ||
> | ||
<Collapse {visible} onHidden={() => console.log('Hidden')} id="auId-0"><div class="card card-body">Visible content</div></Collapse> |