Skip to content

feat!: create table cell for displaying links (#468)#473

Merged
NoopDog merged 3 commits into
mainfrom
fran/468-dd-links
May 13, 2025
Merged

feat!: create table cell for displaying links (#468)#473
NoopDog merged 3 commits into
mainfrom
fran/468-dd-links

Conversation

@frano-m

@frano-m frano-m commented May 13, 2025

Copy link
Copy Markdown
Contributor

Closes #468.

This pull request introduces a new LinkCell component for rendering links in a table cell, along with supporting utilities, stories, and tests. The changes focus on adding functionality for client-side and external navigation, handling invalid links gracefully, and providing customization options.

New LinkCell Component and Utilities:

  • Added the LinkCell component to render links or fallback to plain text for invalid URLs, with support for client-side navigation using next/link (src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx).
  • Introduced utility functions (getComponent, getRelAttribute, getTargetAttribute) to determine the appropriate link component, rel, and target attributes based on navigation type (src/components/Table/components/TableCell/components/LinkCell/utils.ts).
  • Added type guards (assertAnchorRelAttribute, assertAnchorTargetAttribute) to validate rel and target attributes (src/components/common/Link/typeGuards.ts).

Stories for LinkCell:

  • Created Storybook stories for different use cases of the LinkCell component, including client-side, external, invalid links, and custom styles (src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx).
  • Added reusable arguments for the stories to simplify configuration (src/components/Table/components/TableCell/components/LinkCell/stories/args.ts).

Testing:

  • Added comprehensive unit tests for the LinkCell component to verify rendering behavior for client-side links, external links, invalid links, and custom styles (tests/linkCell.test.tsx).

Styling Enhancements:

  • Updated the MuiLink theme to support a underlineNone style that removes underline on hover (src/theme/common/components.ts).

Dependency Updates:

  • Added @emotion/jest as a development dependency for testing styled components (package.json).

@frano-m frano-m requested a review from Copilot May 13, 2025 00:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a new LinkCell component along with utilities, stories, and tests to support both client-side and external navigation while handling invalid links gracefully.

  • Adds the LinkCell component to render links or fall back to plain text.
  • Implements utility functions and type guards for processing link attributes.
  • Provides comprehensive Storybook stories and unit tests.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/linkCell.test.tsx Unit tests verifying different rendering behaviors of the LinkCell component.
src/theme/common/components.ts Adds an underlineNone style configuration for MuiLink.
src/components/common/Link/typeGuards.ts Introduces assertion functions for validating link attributes.
src/components/Table/components/TableCell/components/LinkCell/utils.ts Implements utility functions to determine the correct component and attributes for a link.
src/components/Table/components/TableCell/components/LinkCell/stories/types.ts Provides type definitions for the LinkCell stories.
src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx Defines multiple Storybook stories for the LinkCell component.
src/components/Table/components/TableCell/components/LinkCell/stories/args.ts Configures reusable arguments for LinkCell Storybook stories.
src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx Implements the LinkCell component using the utilities and type guards.
package.json Updates development dependencies by adding @emotion/jest.

Comment thread tests/linkCell.test.tsx Outdated
@frano-m frano-m marked this pull request as ready for review May 13, 2025 04:23
@frano-m frano-m force-pushed the fran/468-dd-links branch 2 times, most recently from fe6dcca to 97bd561 Compare May 13, 2025 04:24
@frano-m frano-m force-pushed the fran/468-dd-links branch from 97bd561 to 497f8cb Compare May 13, 2025 04:25
@NoopDog NoopDog merged commit ac13085 into main May 13, 2025
2 checks passed
@frano-m frano-m deleted the fran/468-dd-links branch May 22, 2025 04:51
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.

Create table cell for displaying links

3 participants