Skip to content

feat: add Table#730

Merged
kurtdoherty merged 1 commit intomainfrom
feat-add-table
Aug 29, 2025
Merged

feat: add Table#730
kurtdoherty merged 1 commit intomainfrom
feat-add-table

Conversation

@kurtdoherty
Copy link
Contributor

Context

This PR

  • Adds Table. This component ties all the other atoms together, defining the CSS grid layout that the rows/columns align to.
  • Updates the column alignment approach. We now use justify-items and a CSS variable that other table atoms reference.
Screenshot 2025-08-29 at 3 50 03 pm Screenshot 2025-08-29 at 3 50 12 pm Screenshot 2025-08-29 at 3 50 18 pm

@rpt-uk-github
Copy link

rpt-uk-github commented Aug 29, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

@kurtdoherty kurtdoherty marked this pull request as ready for review August 29, 2025 05:52
placement: ChildPlacement,
columns: string = '1fr 1fr 1fr min-content',
): FC<{ children: ReactNode }> {
return ({ children }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: no longer need these inline styles as our "real" Table component takes care of all this.

/** Simple factory that returns a component that renders valid table DOM hierarchy around its children */
export function buildTableWrapper(placement: ChildPlacement): FC<{ children: ReactNode }> {
export function buildTableWrapper(
placement: ChildPlacement,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: added a new columns option to this factory so that some stories can build a table wrapper with specifically sized columns.

@@ -172,12 +172,13 @@ export const Overflow: Story = {
),
},
decorators: [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: switch around how the truncation was happening, so we're more correctly demonstrating the behaviour of the body cell, rather than the intermediate div. The div now wraps the whole table, so it's not interfering with layout concerns.

justifyContent: 'end',
justifySelf: 'end',
},
decorators: [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: same deal as above.

@@ -228,15 +229,16 @@ export const EmptyCells: Story = {
export const Alignment: Story = {
args: {
...DoubleLineLayout.args,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: because we switched to using justify-items, we now use justify-self to uniquely justify the content of cells

align-items: center;
justify-content: inherit;

${font('sm', 'regular')}
Copy link
Contributor Author

@kurtdoherty kurtdoherty Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: matching the adjustment made to the header cell.

padding: var(--spacing-2);

overflow: hidden;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: when a custom justification is applied to a cell, that cell and its descendants will have the overridden value for the new CSS variable.

@@ -86,7 +86,7 @@ function buildRows(type: 'single-line' | 'double-line') {
return (
<>
<TableBodyRow>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: scouting some TS errors here... scope is no longer accepted (its auto-applied; see #723)

@@ -91,7 +91,7 @@ export const Clipping: Story = {
},
decorators: [
(Story) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: small scout to make the clipping more obvious

@@ -79,6 +81,39 @@ export const Sortable: Story = {
decorators: [useTableDecorator('header-cell')],
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: added a new story showing truncation for a header cell...though ideally header cells will never truncate.

padding: var(--spacing-2);

${font('2xs', 'bold')}
color: var(--colour-text-secondary);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: th elements in the table's head come with user-agent styles for text-align. We use the new CSS variable set by the table to override this default style so that it matches the chosen justification.

@@ -16,7 +17,7 @@ interface TableRowMoreActionsButtonProps extends Omit<ButtonHTMLAttributes<HTMLB
* is preferred when the button should still be focusable while it's disabled; for example, to allow
* a tooltip to be displayed that explains why the button is disabled.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: small scout to make these props optional

@@ -67,6 +68,7 @@ export function TableRowMoreActionsButton({
className={cx(elTableRowMoreActionsButton, className)}
disabled={disabled}
onClick={handleClick}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: small scout to pin the more actions trigger button to be a button, never a submit.

@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 71bab0f1 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (71bab0f) Report Missing Report Missing Report Missing
Head commit (4f55f9e) 8591 7952 92.56%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#730) 48 48 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@kurtdoherty kurtdoherty merged commit 9d1c633 into main Aug 29, 2025
6 checks passed
@kurtdoherty kurtdoherty deleted the feat-add-table branch August 29, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants