-
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.
- Loading branch information
1 parent
4c515aa
commit c91b1d6
Showing
16 changed files
with
864 additions
and
7 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
angular/demo/src/app/samples/accordion/customHeaders.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 |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import {Component} from '@angular/core'; | ||
import {NgIf} from '@angular/common'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, NgIf], | ||
template: ` | ||
<div auAccordion #accordion="auAccordion"> | ||
<div au-accordion-item> | ||
<ng-template auAccordionItemStructure let-state="state" let-widget="widget"> | ||
<div | ||
class="{{ state.itemHeaderClass }} accordion-button accordion-header custom-header justify-content-between" | ||
[class.collapsed]="state.itemCollapsed" | ||
role="heading" | ||
aria-level="2" | ||
> | ||
<p class="m-0">First panel - {{ state.itemCollapsed ? 'collapsed' : 'opened' }}</p> | ||
<button | ||
type="button" | ||
id="{{ state.itemId }}-toggle" | ||
(click)="widget.actions.click()" | ||
class="btn btn-link p-0 {{ state.itemButtonClass }}" | ||
[class.collapsed]="state.itemCollapsed" | ||
[disabled]="state.itemDisabled" | ||
attr.aria-controls="{{ state.itemId }}-collapse" | ||
[attr.aria-disabled]="state.itemDisabled" | ||
[attr.aria-expanded]="!state.itemCollapsed" | ||
> | ||
Toggle first | ||
</button> | ||
</div> | ||
<div | ||
*ngIf="state!.shouldBeInDOM" | ||
[auUse]="widget!.directives.collapseDirective" | ||
attr.aria-labelledby="{{ state!.itemId }}-toggle" | ||
id="{{ state!.itemId }}-collapse" | ||
class="accordion-collapse {{ state!.itemCollapseClass }}" | ||
> | ||
<div class="accordion-body {{ state!.itemBodyClass }}"> | ||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat | ||
skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid | ||
single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente | ||
ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you | ||
probably haven't heard of them accusamus labore sustainable VHS. | ||
</div> | ||
</div> | ||
</ng-template> | ||
</div> | ||
<div au-accordion-item> | ||
<ng-template auAccordionItemStructure let-state="state" let-widget="widget"> | ||
<div | ||
class="{{ state.itemHeaderClass }} accordion-button accordion-header custom-header justify-content-between" | ||
[class.collapsed]="state.itemCollapsed" | ||
role="heading" | ||
aria-level="2" | ||
> | ||
<p class="m-0">Second panel</p> | ||
<div> | ||
<button | ||
type="button" | ||
class="btn btn-sm btn-outline-primary me-2 {{ state.itemButtonClass }}" | ||
[class.collapsed]="state.itemCollapsed" | ||
id="{{ state.itemId }}-toggle" | ||
(click)="widget.actions.click()" | ||
[disabled]="state.itemDisabled" | ||
[attr.aria-disabled]="state.itemDisabled" | ||
[attr.aria-expanded]="!state.itemCollapsed" | ||
attr.aria-controls="{{ state.itemId }}-collapse" | ||
> | ||
Toggle second | ||
</button> | ||
<button type="button" class="btn btn-sm btn-outline-secondary me-2" (click)="thirdDisabled = !thirdDisabled"> | ||
{{ thirdDisabled ? 'En' : 'Dis' }}able third | ||
</button> | ||
<button type="button" class="btn btn-sm btn-outline-danger me-2" (click)="accordion.api.collapseAll()">Collapse all</button> | ||
</div> | ||
</div> | ||
<div | ||
*ngIf="state!.shouldBeInDOM" | ||
[auUse]="widget!.directives.collapseDirective" | ||
attr.aria-labelledby="{{ state!.itemId }}-toggle" | ||
id="{{ state!.itemId }}-collapse" | ||
class="accordion-collapse {{ state!.itemCollapseClass }}" | ||
> | ||
<div class="accordion-body {{ state!.itemBodyClass }}"> | ||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat | ||
skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid | ||
single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente | ||
ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you | ||
probably haven't heard of them accusamus labore sustainable VHS. | ||
</div> | ||
</div> | ||
</ng-template> | ||
</div> | ||
<div au-accordion-item [itemDisabled]="thirdDisabled"> | ||
<ng-template auAccordionItemStructure let-state="state" let-widget="widget"> | ||
<div | ||
class="{{ state.itemHeaderClass }} accordion-button accordion-header custom-header justify-content-between" | ||
[class.collapsed]="state.itemCollapsed" | ||
role="heading" | ||
aria-level="2" | ||
> | ||
<button | ||
type="button" | ||
class="p-0 btn btn-link container-fluid text-start {{ state.itemButtonClass }}" | ||
[class.collapsed]="state.itemCollapsed" | ||
id="{{ state.itemId }}-toggle" | ||
(click)="widget.actions.click()" | ||
[disabled]="state.itemDisabled" | ||
[attr.aria-disabled]="state.itemDisabled" | ||
attr.aria-controls="{{ state.itemId }}-collapse" | ||
[attr.aria-expanded]="!state.itemCollapsed" | ||
> | ||
Third panel | ||
</button> | ||
<p *ngIf="thirdDisabled" class="text-muted m-0 small">[I'm disabled]</p> | ||
</div> | ||
<div | ||
*ngIf="state!.shouldBeInDOM" | ||
[auUse]="widget!.directives.collapseDirective" | ||
attr.aria-labelledby="{{ state!.itemId }}-toggle" | ||
id="{{ state!.itemId }}-collapse" | ||
class="accordion-collapse {{ state!.itemCollapseClass }}" | ||
> | ||
<div class="accordion-body {{ state!.itemBodyClass }}"> | ||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat | ||
skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid | ||
single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente | ||
ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you | ||
probably haven't heard of them accusamus labore sustainable VHS. | ||
</div> | ||
</div> | ||
</ng-template> | ||
</div> | ||
</div> | ||
`, | ||
styles: [ | ||
` | ||
.custom-header::after { | ||
content: none !important; | ||
} | ||
`, | ||
], | ||
}) | ||
export default class AccordionComponent { | ||
thirdDisabled = false; | ||
} |
38 changes: 38 additions & 0 deletions
38
angular/demo/src/app/samples/accordion/togglePanels.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import {Component} from '@angular/core'; | ||
import {NgFor} from '@angular/common'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, NgFor], | ||
template: ` | ||
<div auAccordion #accordion="auAccordion"> | ||
<div au-accordion-item [itemId]="'first'"> | ||
<ng-template auAccordionItemHeader>First panel</ng-template> | ||
<ng-template auAccordionItemBody | ||
>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat | ||
skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid | ||
single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea | ||
proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably | ||
haven't heard of them accusamus labore sustainable VHS. | ||
</ng-template> | ||
</div> | ||
<div au-accordion-item [itemId]="'second'" #itemTwo> | ||
<ng-template auAccordionItemHeader>Second panel</ng-template> | ||
<ng-template auAccordionItemBody | ||
>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat | ||
skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid | ||
single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea | ||
proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably | ||
haven't heard of them accusamus labore sustainable VHS. | ||
</ng-template> | ||
</div> | ||
</div> | ||
<hr /> | ||
<button class="btn btn-sm btn-outline-primary me-2" (click)="accordion.api.toggle('first')">Toggle first</button> | ||
<button class="btn btn-sm btn-outline-primary me-2" (click)="itemTwo.api.toggle()">Toggle second</button> | ||
<button class="btn btn-sm btn-outline-primary me-2" (click)="accordion.api.expandAll()">Expand all</button> | ||
<button class="btn btn-sm btn-outline-primary me-2" (click)="accordion.api.collapseAll()">Collapse all</button> | ||
`, | ||
}) | ||
export default class AccordionComponent {} |
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
9 changes: 7 additions & 2 deletions
9
demo/src/routes/[framework]/components/accordion/examples/+page.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,13 +1,18 @@ | ||
<script lang="ts"> | ||
import Sample from '../../../../../lib/layout/Sample.svelte'; | ||
import sampleDefault from '@agnos-ui/samples/accordion/default'; | ||
import togglePanels from '@agnos-ui/samples/accordion/togglePanels'; | ||
import customHeaders from '@agnos-ui/samples/accordion/customHeaders'; | ||
import LinkHeading from '$lib/link-heading/LinkHeading.svelte'; | ||
</script> | ||
|
||
<LinkHeading label="Default" id="default" level={2} /> | ||
<LinkHeading label="Default Accordion" id="default" level={2} /> | ||
<Sample title="Default example" sample={sampleDefault} height={395} /> | ||
<LinkHeading label="Toggle panels" id="togglePanels" level={2} /> | ||
<Sample title="Toggle panels" sample={togglePanels} height={395} /> | ||
<LinkHeading label="Custom Headers" id="customHeaders" level={2} /> | ||
<Sample title="Custom Headers" sample={customHeaders} height={395} /> | ||
|
||
<LinkHeading label="Accessibility" id="accessibility" level={2} /> | ||
<p> | ||
The accordion properly sets up <strong>aria-controls</strong> and <strong>aria-expanded</strong> on the collapsable items. | ||
</p> |
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
Oops, something went wrong.