Open DiegoAndai opened 10 months ago
A few notes:
- They don't have respective slots
Do they need a slot? Every time we can use a React element over a React component is a significantly better DX (more flexible), but it's not always possible.
- Seems arbitrary that icon is to the left and action to the right
Indeed, though it depends on what we optimize for. For example, icon
/ action
is clearer than start
/ end
if it's 80% of the use case.
- iconMapping might be better handled via slots
If I recall correctly, this prop is meant for theme
customization (use with defaultProps), or through a wrapper to save boilerplate code. It was inspired by the variantMapping
prop of the Typography (though there it's a component, not an element as object value).
@oliviertassinari I think we could optimize for the most common use case but be flexible:
We could keep icon
/action
as is and introduce leftDecorator
and rightDecorator
slots for anything beyond that use case. Using leftDecorator
would override icon
, for example.
Regarding iconMapping
. I think using leftDecorator
would be more flexible, and users could still provide it as defaultProps.
Overall, I think promoting the slots pattern for all specialized use cases where possible would result in users getting familiar with it and incorporating it in their mental models, instead of having different mental models for each component. I would say:
icon
and action
.
What's the problem?
The
action
,icon
, andiconMappings
props could use a revision:icon
is to the left andaction
to the righticonMapping
might be better handled via slotsWhat are the requirements?
Revise the API, comparing with the rest of components, and deciding whether it's still the best option or if it needs an update.
What are our options?
Proposed solution
Implement something similar to Joy UI: deprecate and eventually remove
action
andicon
in favor ofstartDecorator
andendDecorator
, each with a corresponding slot like Joy UI. The slots receive theownerState
so they can be used to replaceiconMappings
.Resources and benchmarks
Search keywords: