Skip to content
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

Mod/10878 dtui table row height and links #204

Merged
merged 13 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ require('../../styles/components/table/_table.scss');
const propTypes = {
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
rows: PropTypes.arrayOf(oneOfType([PropTypes.array, PropTypes.object])),
rowHeight: PropTypes.number,
headerRowHeight: PropTypes.number,
currentSort: shape({
direction: oneOf(['asc', 'desc']),
field: PropTypes.string
Expand Down Expand Up @@ -106,13 +108,14 @@ const Table = (props) => {
<caption className="usa-dt-sr-only">{props.screenReaderCaption}</caption>
)}
<thead className="usda-table__head">
<tr className="usda-table__row">
{props.columns.map((col) => (
<tr className="usda-table__row" style={{ height: props.headerRowHeight }}>
{props.columns.map((col, index) => (
<TableHeader
key={uniqueId()}
currentSort={props.currentSort}
updateSort={props.updateSort}
stickyFirstColumn={props.stickyFirstColumn}
index={index}
{...col} />
))}
</tr>
Expand All @@ -125,13 +128,14 @@ const Table = (props) => {
}
return acc.concat([{ ...col, displayName: '', className: 'empty-subheader' }]);
}, [])
.map((col) => (
.map((col, index) => (
<TableHeader
key={uniqueId()}
className={col?.title ? 'nested-header' : 'empty'}
currentSort={props.currentSort}
updateSort={props.updateSort}
stickyFirstColumn={props.stickyFirstColumn}
index={index}
{...col} />
))}
</tr>
Expand Down
6 changes: 5 additions & 1 deletion components/table/TableData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import TableHeader from './TableHeader';
const propTypes = {
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
rows: PropTypes.arrayOf(oneOfType([PropTypes.array, PropTypes.object])).isRequired,
rowHeight: PropTypes.number,
expandable: PropTypes.bool,
divider: PropTypes.string,
onClickHandler: PropTypes.func,
Expand All @@ -25,6 +26,7 @@ const propTypes = {
const TableData = ({
columns,
rows,
rowHeight,
expandable,
divider,
onClickHandler,
Expand Down Expand Up @@ -84,14 +86,16 @@ const TableData = ({
localClickHandler(row, i);
}
}}
className={`usda-table__row-item usda-table__row${oddClass}`}>
className={`usda-table__row-item usda-table__row${oddClass}`}
style={{ height: rowHeight }}>
{row.map((data, j) => (
columns[j]?.bodyHeader
? (
<TableHeader
className="table-header_body-header"
key={uniqueId()}
stickyFirstColumn={stickyFirstColumn}
index={j}
{...data} />
)
: (
Expand Down
8 changes: 5 additions & 3 deletions components/table/TableHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const propTypes = {
icon: PropTypes.element,
bodyHeader: PropTypes.bool,
stickyFirstColumn: PropTypes.bool,
columnWidth: PropTypes.number
columnWidth: PropTypes.number,
index: PropTypes.number
};

const TableHeaderCell = ({
Expand All @@ -86,7 +87,8 @@ const TableHeaderCell = ({
icon = (<></>),
bodyHeader = false,
stickyFirstColumn = false,
columnWidth
columnWidth,
index
}) => {
const handleClickedSort = (e, sortOn = title) => {
updateSort(sortOn, e.target.value);
Expand All @@ -99,7 +101,7 @@ const TableHeaderCell = ({
};
return (
<th
className={`${className} table-header${bodyHeader ? ' table-header_body-header' : ''} ${stickyFirstColumn === true ? ' stickyColumn' : ''} `}
className={`${className} table-header${bodyHeader ? ' table-header_body-header' : ''} ${stickyFirstColumn && index === 0 ? ' stickyColumn' : ''} `}
style={{ minWidth: columnWidth }}
colSpan={columnWidth ? '' : columnSpan}
rowSpan={rowsSpan()}
Expand Down
2 changes: 1 addition & 1 deletion dist/data-transparency-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/211.758cb3ad.iframe.bundle.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/211.f0bd0c27.iframe.bundle.js

This file was deleted.

2 changes: 0 additions & 2 deletions docs/211.fb7a8e7d.iframe.bundle.js

This file was deleted.

129 changes: 0 additions & 129 deletions docs/211.fb7a8e7d.iframe.bundle.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion docs/229.4b90415ecd5b101f001b.manager.bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/229.6d69ce64.iframe.bundle.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/229.df6775d714abc2d29de0.manager.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/229.f9abf24b.iframe.bundle.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/51.12879e96425c0b128042.manager.bundle.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/51.33304ca29cb8e99bdbad.manager.bundle.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/51.62905199.iframe.bundle.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/51.88af68fd.iframe.bundle.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/551.1ddce1e1.iframe.bundle.js

This file was deleted.

Loading