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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

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 999cd69
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/67912fc4562e9c0008b6d87d
😎 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 999cd69
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/67912fc456098600083f11d6
😎 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 999cd69
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/67912fc491104d0008240bba
😎 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants