-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: DataGrid reformatted to table
and aria-sort added
#2998
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 0e23544. ☁️ Nx Cloud last updated this comment at |
This reverts commit e0003aa.
table
and aria-sort added
…to cass-gm-945-i
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.
Preview works and looks great!
VO now recognizes the table as a table and appropriately semantic rows, headers, and cells. Filtering sounds good too. And the aria-sort shows up as well for sorting.
As I was going through the code to get an understanding of the changes, I was wondering about naming conventions — to try and separate out how components could be tied to their semantic HTML counterpart.
Left some thoughts for clean up but functionally, the changes look great :)
@@ -92,7 +108,8 @@ export const Row: DataRow = ({ | |||
} | |||
|
|||
return ( | |||
<ListCol {...colProps}> | |||
// TO-DO: Fix type issues |
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 the type issues fixed?
I don't see any locally.
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.
oop, they are! will remove
return ( | ||
<ListRow expanded={expanded} renderExpanded={renderExpandedContent}> | ||
<ListRow | ||
as="tr" |
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.
Food for thought: since both HeaderRow.tsx
and Row.tsx
are specific to tables, would renaming these components and folder to be table-specific make sense?
e.g. Tables/TableHeader.tsx
and Tables/TableRow.tsx
respectively?
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.
And then maybe move over TableHeader.tsx
?
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.
love it, will change
variant={variant} | ||
scrollable={scrollable} | ||
ref={ref} | ||
as="tr" |
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 HeaderEl be a styled tr
instead? atm it's a styled div
. See:
https://github.com/Codecademy/gamut/blob/cass-gm-945-i/packages/gamut/src/List/elements.tsx
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.
maybe it should be like HeaderRowEl
?
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.
going into a rabbit hole of sorts — so feel free to disregard lol
but headerVariants
seem like it's not used for anything else and only applies a borderBottom to table.
So maybe lump that into the CSS styling and do away with this variant altogether?
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.
great call out, will refactor!
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 found out this is different between DataList v DataTable so keeping the variants as is but refactored to tr
|
||
return ( | ||
<ListHeader> | ||
<TableHeader> | ||
<> |
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 fragment needed anymore?
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.
ill check!
packages/gamut/src/List/elements.tsx
Outdated
header: { | ||
...headerStyles, | ||
}, | ||
// Keeping this within variants for typing purposes, we we use this behaviorally despite it not needing specific styling |
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.
nit: extra "we" in this sentence
</> | ||
); | ||
|
||
const content = | ||
isEmpty || loading ? ( | ||
<Box | ||
as="table" |
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 as
needed? looks like the parent element sets the as
and content seems like it could be other elements
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.
actually, can this Box and the parent Box actually be combined?
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'll test it out! i think we were using it for some positioning reason, but i think i've changed this enough that we don't need it anymore
|
||
export interface RowProps | ||
extends Partial<PublicListProps<ComponentProps<typeof RowEl>>> { | ||
header?: boolean; | ||
/** This is an internal prop that is largely only used for the DataTable 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.
Since RowProps are used for DataRow, used in DataGrid, would be more accurate to say used for the "DataTable and DataList components"?
const { onClick, role, tabIndex, ...rowProps } = rest; | ||
const wrapperProps = | ||
!renderExpanded && !onClick | ||
(!renderExpanded && !onClick) || isTable | ||
? { ...rowConfig, ...rowProps } | ||
: { spacing: keepSpacingWhileExpanded ? rowConfig.spacing : undefined }; | ||
let content = children; | ||
const renderNumbering = isOl && renderExpanded === undefined && !onClick; |
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.
nit: is there a falsy value other than undefined
for renderExpanded
?
If not, maybe !renderExpanded && !onClick
can be a variable, like isNotInterative
?
packages/gamut/src/List/elements.tsx
Outdated
@@ -381,7 +385,7 @@ export const ColEl = styled( | |||
system.layout | |||
); | |||
|
|||
export const StickyColumnWrapper = styled.div( | |||
export const StickyColumnWrapper = styled.th( |
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.
nit: consider renaming to StickyHeaderWrapper? Or StickyHeaderColWrapper?
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.
Working and looking great tho!
🚀 Styleguide deploy preview ready! |
📬Published Alpha Packages:@codecademy/[email protected] |
Overview
Refactors the DataTable + DataList components to properly be semantic HTML tables and adds
aria-sort
to the appropriate controlsPR Checklist
Testing Instructions
PR Links and Envs