-
Notifications
You must be signed in to change notification settings - Fork 12
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
va-table: add sorting variation #1358
Conversation
I have a couple concerns:
|
I believe those will need to be wrapped in a |
@@ -47,6 +47,22 @@ export class VaTableInner { | |||
*/ | |||
@Prop() stacked?: boolean = false; | |||
|
|||
@Prop() sortdir?: string = null; | |||
|
|||
@Prop() sortindex?: number = null; |
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.
If sortdir
and sortindex
are public properties, can we add documentation comments for them to explain how they work? Would it also be valuable to add a story that demonstrates them?
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.
@jamigibbs - good call - they don't need to be props, I have handled this using data- attrs and State in a refactor
composed: true, | ||
bubbles: true, | ||
}) | ||
sortTable: EventEmitter; |
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.
Is this event just for internal component use? Or do we think there's a reason that a team would want to be listening for this event so they could do something with it?
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.
@jamigibbs it should only be useful internally
@@ -0,0 +1,12 @@ | |||
import { CompareFuncReturn } from "./utils"; | |||
|
|||
export function alphaSort(sortdir: string): CompareFuncReturn { |
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.
What does this function do? Could we add some documenting comments?
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.
@jamigibbs fixed!
@@ -0,0 +1,37 @@ | |||
export const months = { | |||
"january": 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.
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.
@jamigibbs I wondered this too - I moved the constants to higher level utils folder because there is a chance of some other component using them
return month ? month : new Date(string).getTime(); | ||
} | ||
|
||
export function dateSort(sortdir: string): CompareFuncReturn { |
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.
Can we add a small comment about what this function is doing?
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.
@jamigibbs - fixed!
@@ -33,6 +45,14 @@ caption { | |||
margin-bottom: .75rem; | |||
} | |||
|
|||
.th-sort-header { | |||
background-color: var(--vads-color-primary-alt-light) !important; |
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.
Are there any specific USWDS classes from their table module that could be used instead of custom CSS? Same question for the .sorted-data
class below too.
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.
@jamigibbs - yes there are! fixed!
@powellkerry Is what you're describing the same thing as this issue? |
…fairs/component-library into sortable-table
@powellkerry @jamigibbs good call on the disappearing headers; I pushed a commit so that they don't disappear for a sortable table |
…fairs/component-library into sortable-table
@rsmithadhoc instead of a button I used a span with a |
@it-harrison It should be okay functionality-wise, Andrew ran into issues recently with linting and explicitly defining a I'll give my approval, I also have department-of-veterans-affairs/vets-design-system-documentation#2772 to give it a full a11y review as well. |
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.
Good updates so far, Ian! I have just a few more observations/questions:
} | ||
return ( | ||
<span | ||
role="button" |
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 think USWDS is using a button
with styling classes. Can we do that too here instead of using a span
?
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.
@jamigibbs - I switched to button but had to style it since the styles from uswds diverge from ours here
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.
@department-of-veterans-affairs/platform-design-system-designers Are we aware that there is a design divergence between USWDS table and our Figma for the header buttons?
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.
@jamigibbs - I have keyed Dan into this and he will be working on a solution going forward
/** | ||
* Is the table sortable | ||
*/ | ||
@Prop() sortable: boolean = false; |
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.
Have we tested how this behaves with pagination?
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.
@jamigibbs there was a bug (not actually related to pagination but revealed in the pagination example) that is now fixed
@rsmithadhoc heads up - I went with buttons in the table header ths. |
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.
Excellent work, @it-harrison!
If there is any time to add tests for the sort utility methods, there might be an opportunity to do that similar to how va-telephone has unit tests.
And with there being visual changes, let's try and have a design approval before merging too. 🙏🏼
@jamigibbs sorting utils tests added. reaching out to design for review |
@danbrady @LWWright7 @babsdenney as per a suggestion from @jamigibbs this PR will wait to merge until one of you has had time to review it for visual changes - thanks! |
Sorry for the delay in review, @it-harrison. I'm a bit swamped. Quick question on something I notice... How come the sorted icons are different between USWDS and VADS? |
@danbrady no worries and good call - I used |
I see why you did that, Ian. That makes sense to me. Maybe the USWDS uses that slim arrow instead because it looks closer to the default sort icon. Whereas the Material/VADS arrows are downright chonky. However, the USWDS should probably include those slim arrows in their icon set. Here's three possible ideas for a way forward:
@humancompanion-usds, your thoughts? @it-harrison The rest of the design looks good. I don't think it's necessary to stop merging this based on the icon alone. We can create a follow up ticket, if needed. Thanks! |
Chromatic
https://sortable-table--65a6e2ed2314f7b8f98609d8.chromatic.com
Description
This PR makes the
va-table
sortable by means of asortable
prop.Key points:
Closes 2771
QA Checklist
Screenshots
Acceptance criteria
Definition of done