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

feat: Added strong PolymorphicProps #18384

Merged
merged 8 commits into from
Jan 27, 2025

Conversation

guidari
Copy link
Contributor

@guidari guidari commented Jan 20, 2025

Closes #18369
Closes #18370
Closes #18371

Added strong PolymorphicProps for Tag, Button and Link.

Changelog

Changed

  • Changed the way the PolymorphicProp is validated.

  • NOTE: The only changes are in the way the type


    Code example

      export type LinkProps<T extends React.ElementType> =
        PolymorphicComponentPropWithRef<T, LinkBaseProps>;
      
      type LinkComponent = <T extends React.ElementType = 'a'>(
        props: LinkProps<T>
      ) => React.ReactElement | any;
      
      const Link: LinkComponent = React.forwardRef(
        <T extends React.ElementType = 'a'>(
          {
            as: BaseComponent,
            children,
            className: customClassName,
            href,
            disabled = false,
            inline = false,
            visited = false,
            renderIcon: Icon,
            size,
            target,
            ...rest
          }: LinkProps<T>,
          ref: PolymorphicRef<T>
        ) => {   
    

Testing / Reviewing

  • CI should pass
  • You can also pull down the PR locally to test, but here it is a screenshot:

Screenshot 2025-01-20 at 09 18 19

@guidari guidari requested a review from a team as a code owner January 20, 2025 12:23
Copy link

netlify bot commented Jan 20, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit f223565
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/679252d849d19c0008d074fb
😎 Deploy Preview https://deploy-preview-18384--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit f223565
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/679252d7681a4800083120be
😎 Deploy Preview https://deploy-preview-18384--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f223565
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/679252d737157c000894c0d1
😎 Deploy Preview https://deploy-preview-18384--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 86.32479% with 16 lines in your changes missing coverage. Please review.

Project coverage is 84.15%. Comparing base (0c2ff15) to head (f223565).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
packages/react/src/components/Tag/Tag.tsx 81.35% 11 Missing ⚠️
packages/react/src/components/Button/Button.tsx 87.50% 4 Missing ⚠️
packages/react/src/components/Link/Link.tsx 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18384      +/-   ##
==========================================
- Coverage   84.17%   84.15%   -0.02%     
==========================================
  Files         408      408              
  Lines       14435    14437       +2     
  Branches     4660     4662       +2     
==========================================
  Hits        12150    12150              
- Misses       2120     2122       +2     
  Partials      165      165              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

LGTM

@riddhybansal riddhybansal added this pull request to the merge queue Jan 27, 2025
Merged via the queue into carbon-design-system:main with commit 9b9fa47 Jan 27, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants