Closed mimarz closed 8 months ago
After testing asChild
and it working alongside as
we prefer asChild
as its much more flexible for end users, especially with callbacks having correct types.
We will use @radix-ui/react-slot for asChild
feature.
We hit a snag with using the Slot
component for Button
and Tabs
, in general components where we interspace things with children, such as icon passed via an icon
prop. This fails due to Slot
needing to have a single children for it to merge with.
We are currently investigating other options such as:
as
( component ) support
icon
prop and have users handle icons themselvesAfter some testing and investigation:
Slot
still feels like a better and more robust solution.icon
prop has also the added benefit of providing more flexibility to how users use icons inside our stories.After a short meeting on jan 5. we decided to remove the ability to pass icons through properties and instead favour them being passed as children
#1333
This issue will be put on hold until we finish #1333 and #1342
After some testing and investigation:
- Chakras/Mantines polymorphic factory are very cumbersome or complex to try to convert to our own.
- Radix's
Slot
still feels like a better and more robust solution.- Remove the ability to pass icon through
icon
prop has also the added benefit of providing more flexibility to how users use icons inside our stories.After a short meeting on jan 5. we decided to remove the ability to pass icons through properties and instead favour them being passed as
children
#1333This issue will be put on hold until we finish #1333 and #1342
The two other issues has been completed, should we move forward with this issue?
Closing as completed
Our implementation of polymorphism with
as
prop using OverridableComponent has its drawback with callback functions not being updated to use the casted type which has led to a few bumps when using this for our components and wanted feature.Suggest we investigate the following to figure out what to do:
OverridableComponent
can be expanded to support callback functionsasChild
and its Slot component and document its pros and drawbacks (since its using cloneElement).Adopting
asChild
approach could fix this issue but it would enforce other contraints on our users components when it comes to composition.Alternatively we can use
Box
to test usingasChild
for polymorphism.