-
Notifications
You must be signed in to change notification settings - Fork 2
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
Custom table elemets #141
Custom table elemets #141
Changes from 5 commits
ade9863
beec11d
7a2dcb6
33bddd7
3a29488
8ae0002
e9c150b
90c76dc
da00827
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,11 @@ export const Table = <TData extends object>({ | |
|
||
return ( | ||
<TableContainer className={className}> | ||
<TableContainerInner withFilters={withFilters} withTabs={withTabs}> | ||
<TableContainerInner | ||
withFilters={withFilters} | ||
withTabs={withTabs} | ||
withSideBorders={withSideBorders} | ||
> | ||
<TableStyled withSideBorders={withSideBorders}> | ||
{withHeaders && ( | ||
<TableHead> | ||
|
@@ -131,48 +135,57 @@ export const Table = <TData extends object>({ | |
{headerGroup.headers.map((header) => { | ||
const canSort = enableSorting && header.column.getCanSort(); | ||
const isCustomHeader = header.column.columnDef.meta?.customHeader; | ||
const tableHeaderProps = { | ||
key: header.id, | ||
colSpan: header.colSpan, | ||
width: header.getSize(), | ||
sorted: header.column.getIsSorted(), | ||
canSort, | ||
}; | ||
|
||
const headerContents = header.isPlaceholder | ||
? null | ||
: flexRender(header.column.columnDef.header, header.getContext()); | ||
: flexRender(header.column.columnDef.header, { | ||
...tableHeaderProps, | ||
...header.getContext(), | ||
}); | ||
|
||
const { | ||
activeTab = '', | ||
handleTabs = () => {}, | ||
tabs = [], | ||
} = header.column.columnDef.meta?.columnTabs || {}; | ||
|
||
return ( | ||
<TableHeader | ||
key={header.id} | ||
colSpan={header.colSpan} | ||
width={header.getSize()} | ||
sorted={header.column.getIsSorted()} | ||
canSort={canSort} | ||
> | ||
{!!tabs.length && ( | ||
<TableTabs activeTab={activeTab} handleTabs={handleTabs} tabs={tabs} /> | ||
)} | ||
<SortButton | ||
canSort={canSort} | ||
onClick={header.column.getToggleSortingHandler()} | ||
> | ||
{isCustomHeader ? ( | ||
headerContents | ||
) : ( | ||
<TableHeaderWrapper>{headerContents}</TableHeaderWrapper> | ||
if (isCustomHeader) { | ||
return headerContents; | ||
} else { | ||
return ( | ||
<TableHeader {...tableHeaderProps}> | ||
{!!tabs.length && ( | ||
<TableTabs activeTab={activeTab} handleTabs={handleTabs} tabs={tabs} /> | ||
)} | ||
<SortButton | ||
canSort={canSort} | ||
onClick={header.column.getToggleSortingHandler()} | ||
> | ||
{isCustomHeader ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this ever be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch, looks like this will always be falsey. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I follow this thread, but we were talking about that That line there is the one that would give a truthy value to What am I missing for what you guys are agreeing on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aah! I see it now! yep!! copy pasta |
||
headerContents | ||
) : ( | ||
<TableHeaderWrapper>{headerContents}</TableHeaderWrapper> | ||
)} | ||
</SortButton> | ||
{header.column.getCanResize() && ( | ||
<Resizer | ||
onMouseDown={header.getResizeHandler()} | ||
onTouchStart={header.getResizeHandler()} | ||
className={`resizer ${ | ||
header.column.getIsResizing() ? 'isResizing' : '' | ||
}`} | ||
/> | ||
)} | ||
</SortButton> | ||
{header.column.getCanResize() && ( | ||
<Resizer | ||
onMouseDown={header.getResizeHandler()} | ||
onTouchStart={header.getResizeHandler()} | ||
className={`resizer ${ | ||
header.column.getIsResizing() ? 'isResizing' : '' | ||
}`} | ||
/> | ||
)} | ||
</TableHeader> | ||
); | ||
</TableHeader> | ||
); | ||
} | ||
})} | ||
</TableRow> | ||
))} | ||
|
@@ -190,14 +203,22 @@ export const Table = <TData extends object>({ | |
> | ||
{row.getVisibleCells().map((cell) => { | ||
const isCustomCell = cell.column.columnDef.meta?.customCell; | ||
const cellContents = flexRender(cell.column.columnDef.cell, cell.getContext()); | ||
return ( | ||
<TableCell key={cell.id} width={cell.column.getSize()}> | ||
{isCustomCell ? ( | ||
cellContents | ||
) : ( | ||
<TableCellWrapper>{cellContents}</TableCellWrapper> | ||
)} | ||
|
||
const tableCellProps = { | ||
key: cell.id, | ||
width: cell.column.getSize(), | ||
}; | ||
|
||
const cellContents = flexRender(cell.column.columnDef.cell, { | ||
...tableCellProps, | ||
...cell.getContext(), | ||
}); | ||
|
||
return isCustomCell ? ( | ||
cellContents | ||
) : ( | ||
<TableCell {...tableCellProps}> | ||
<TableCellWrapper>{cellContents}</TableCellWrapper> | ||
</TableCell> | ||
); | ||
})} | ||
|
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.
Do you have link/docs related to what's changing here just for my education?
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.
We use the TTypescript to apply absolute path handling in the "build" script, which OG TS doesn't do.
Removing this dependency would mean we cannot use absolute paths in UIKit.
ttsc is just ttypescript's tsc, which applies the patches.
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 we wanted to use an alternative approach to this, in Arranger I prepatch TS itself, rather than using TTS.
That may solve whatever issues @ciaranschutte is finding in his local env.
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 see, and from their Github, it's deprecated. Thanks!
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.
oh, that bit I hadn't realised. we'll have to update UIKit to account for that (different scope, unless this is a blocker 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.
putting back in ttsc for build