Skip to content

Commit

Permalink
doc(table): Add sort alphabetic example
Browse files Browse the repository at this point in the history
Co-authored-by: Iris Benoit <iris.benoit@pix.fr>
  • Loading branch information
Jeremiejade and Eithliu committed Dec 12, 2024
1 parent 8c23b43 commit 4882591
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
16 changes: 12 additions & 4 deletions app/stories/pix-table-column.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ Une colonne d'un [PixTable](/docs/data-display-table--docs), gère l'affichage d
```html
<PixTable @data={{this.data}} @caption={{this.caption}}>
<:columns as |row context|>
<PixTableColumn @context={{context}}>
<PixTableColumn
@context={{context}}
@onSort={{this.sortAz}}
@sortOrder={{this.sortOrderAz}}
@ariaLabelDefaultSort={{this.ariaLabelDefaultSort}}
@ariaLabelSortAsc={{this.ariaLabelSortAsc}}
@ariaLabelSortDesc={{this.ariaLabelSortDesc}}
>
<:header>
Nom
</:header>
Expand All @@ -57,9 +64,10 @@ Une colonne d'un [PixTable](/docs/data-display-table--docs), gère l'affichage d
</PixTableColumn>
<PixTableColumn
@context={{context}}
@onSort={{this.onNumSort}}
@sortOrder={{this.sortOrder}}
@ariaLabelDefaultSort={{this.otherArialLabelDefaultSort}}
@type="number"
@onSort={{this.sortNum}}
@sortOrder={{this.sortOrderNum}}
@ariaLabelDefaultSort={{this.ariaLabelDefaultSort}}
@ariaLabelSortAsc={{this.ariaLabelSortAsc}}
@ariaLabelSortDesc={{this.ariaLabelSortDesc}}
>
Expand Down
16 changes: 11 additions & 5 deletions app/stories/pix-table-column.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ const TemplateSort = (args) => {
return {
template: hbs`<PixTable @data={{this.data}} @caption={{this.caption}}>
<:columns as |row context|>
<PixTableColumn @context={{context}}>
<PixTableColumn
@context={{context}}
@onSort={{this.sort}}
@sortOrder={{this.sortOrder}}
@ariaLabelDefaultSort={{this.ariaLabelDefaultSort}}
@ariaLabelSortAsc={{this.ariaLabelSortAsc}}
@ariaLabelSortDesc={{this.ariaLabelSortDesc}}
>
<:header>
Nom
</:header>
Expand All @@ -126,7 +133,8 @@ const TemplateSort = (args) => {
</PixTableColumn>
<PixTableColumn
@context={{context}}
@onSort={{this.sortNum}}
@type="number"
@onSort={{this.sort}}
@sortOrder={{this.sortOrder}}
@ariaLabelDefaultSort={{this.ariaLabelDefaultSort}}
@ariaLabelSortAsc={{this.ariaLabelSortAsc}}
Expand Down Expand Up @@ -158,9 +166,7 @@ Sorted.args = {
age: 25,
},
],
sortNum(a, b) {
return a.age - b.age;
},
sort() {},
sortOrder: 'asc',
ariaLabelDefaultSort: 'click pour trier',
ariaLabelSortAsc: 'click pour trier en ordre ascendant',
Expand Down

0 comments on commit 4882591

Please sign in to comment.