feat(menu): Inherit Menu variables in MenuItem#94
Conversation
d71e710 to
bfec7fe
Compare
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
=======================================
Coverage 86.27% 86.27%
=======================================
Files 39 39
Lines 663 663
Branches 99 99
=======================================
Hits 572 572
Misses 88 88
Partials 3 3
Continue to review full report at Codecov.
|
src/lib/renderComponent.tsx
Outdated
| // Resolve variables for this component, allow props.variables to override | ||
| const resolvedVariables: ComponentVariablesObject = mergeComponentVariables( | ||
| componentVariables[displayName], | ||
| componentVariables[useVariablesFrom], |
There was a problem hiding this comment.
would it still work for other components with this change - for those where this property is not specified?
There was a problem hiding this comment.
#70 useVariablesFrom = displayName,
There was a problem hiding this comment.
got it, thanks!
But, actually, in a shed of recent decision on removing Children API from scope - do we really need to introduce this additional useVariablesFrom mechanism? What if we will do the following instead (as we've discussed it today's noon):
// in Menu.tsx, pseudo-code
renderComponent({..., variables, ... }) => (
....
<MenuItem variables={variables} />
)When set of cases has reduced to shorthand API those two approaches are absolutely equal in terms of cases covered - while, at the same time,
- the later one utilizes only those mechanisms that were already introduced
- semantically both reduce to passing
Menuvariables toMenu.Item
There was a problem hiding this comment.
Totally agree. I will remove child API for MenuItem (for now), it is already broken anyway, and pass computed variables to MenuItem in Menu.renderComponent()
This is an alternative solution to #84.
For discussion
TODO
API Proposal
Approach suggested by @kuzhelov in #84 - to pass all the resolved variables in
Menu.renderComponent()to theMenuItem. Works great for shorthand, but breaks with child API (currently, there is no way how parent could pass the variables overrides to children when child API is used).Alternative to child API which solves it:
For now we decided to remove Children API support for Menu so this should not be a problem.