-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs(sort): add initial sorting docs #5513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,19 @@ | |||
To add sorting behavior and styling to a set of table headers, add the `<md-sort-header>` component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overview should be structured like
- Single sentence that summarizes the components, e.g.: "The
mdSort
andmd-sort-header
are used, respectively, to add sorting state and display to tabular data." - overview example
- Basic use
- Additional sections on configuration, alternate behaviors, etc.
- Accessibility notes for this component
@@ -0,0 +1,3 @@ | |||
.mat-sort-header-container { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be an additional example of the sort directives being applied to an md-table
.
(we can re-use the same example for both the table and sortable pages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some message about it; can add example when table-docs PR is merged
let valueA = isNaN(+propertyA) ? propertyA : +propertyA; | ||
let valueB = isNaN(+propertyB) ? propertyB : +propertyB; | ||
|
||
return (valueA < valueB ? -1 : 1) * (sort.direction == 'asc' ? 1 : -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this sort function is more complicated than needed for this example. Instead of baking all of the columns into the comparator, just have a compareNumber
and compareString
function and use the appropriate one based on the selected column?
src/lib/sort/sort.md
Outdated
@@ -0,0 +1,31 @@ | |||
The `mdSort` and `md-sort-header` are used, respectively, to add sorting behavior, state, and display | |||
to tabular data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say "behavior", since the components don't actually do any sorting. The directives only capture the state and the display.
src/lib/sort/sort.md
Outdated
To reverse the sort order for all headers, set the `mdSortStart` to `desc` on the `mdSort` directive. | ||
To reverse the order only for a specific header, set the `start` input only on the header instead. | ||
|
||
To prevent the user from removing sort altogether after it is applied, set `mdSortDisableClear` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"To prevent the user from clearing the sort state from an already sorted column"
src/lib/sort/sort.md
Outdated
|
||
<!-- example(sort-overview) --> | ||
|
||
# Adding sort to table headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start with h3 (###
) and go from there
Changes made, ready for another review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
8f5e140
to
dd89ed6
Compare
* docs(sort): add initial sorting docs * add newlines * update * minor * rebase, add table example
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.