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

Building Strongly Typed Polymorphic Components #18274

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

guidari
Copy link
Contributor

@guidari guidari commented Dec 26, 2024

Closes #18279

Implemented a strong type PolymorphicProps to be reusable to other components.
Text component is using the new PolymorphicComponentPropWithRef

Here it is an example:
Screenshot 2024-12-26 at 11 24 09

Changelog

New

  • Added a new internal code for PolymorphicProps.

Changed

  • Changes Text to use new PolymorphicComponentPropWithRef

Testing / Reviewing

  • Text component should work as expected
  • It should not accept wrong attributes

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 09ebd53
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/676ea1bb914876000884c069
😎 Deploy Preview https://deploy-preview-18274--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 Dec 27, 2024

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

Name Link
🔨 Latest commit 09ebd53
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/676ea1bbc3e8780008f8b4ae
😎 Deploy Preview https://deploy-preview-18274--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 Dec 27, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 09ebd53
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/676ea1bb79f1ff00084c5dc8
😎 Deploy Preview https://deploy-preview-18274--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 Dec 27, 2024

Codecov Report

Attention: Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 84.31%. Comparing base (03170a8) to head (09ebd53).

Files with missing lines Patch % Lines
packages/react/src/components/Text/Text.tsx 88.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18274   +/-   ##
=======================================
  Coverage   84.31%   84.31%           
=======================================
  Files         404      404           
  Lines       14359    14359           
  Branches     4656     4660    +4     
=======================================
  Hits        12107    12107           
+ Misses       2090     2089    -1     
- Partials      162      163    +1     

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

@@ -11,7 +11,7 @@ import classnames from 'classnames';
import { usePrefix } from '../../internal/usePrefix';
import { Text } from '../Text';

type ListItemProps = ComponentProps<'li'>;
type ListItemProps = Omit<ComponentProps<'li'>, 'ref'>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this fix because of this typescript error:
Types of property 'ref' are incompatible.
This removes the ref property from ComponentProps<'li'>, preventing conflicts with the Text component.

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.

Implement the reusable code and add to Text component
1 participant