-
Notifications
You must be signed in to change notification settings - Fork 26
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(text): Add as
prop while deprecating elementType
#631
Conversation
635d31b
to
c40685b
Compare
"${propName}" property of "${componentName}" has been deprecated | ||
and will be removed in the next major version.\n | ||
Please use "as" prop instead.`; | ||
warning(false, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause a massive amount of warnings.
I would proceed as following instead:
- introduce the
as
prop without touching the other props - wait for a new major bump
- deprecate the
elementType
prop and add the warning - wait for a new major bump
- remove the
elementType
prop
Ideally, we would also provide a codemod to run the migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what was aimed for here and also agreed upon before. Generally, I see the intend here to warn through prop-types given the prop is used. Then fix up the warnings (while still supporting the prop) by migrating to as
and then in the next major dropping the elementType
.
How did you read us wanting a quick breaking change from this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think providing a codemod is a bit overkill considering we could make the changes in the MC-FE in about 2 minutes with find and replace.
I think the path described by @tdeekens seems quite reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would be a nice learning experience to write a codemod during tech time if anybody wants but seems faster without. Assuming that not too many people use ui-kit yet (whom the find and replace is also quick an easy).
I am just lagging behind to how the suggested implementation here seemed to suggest another path than outlined above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I think there are several implications that need to be discussed first instead of jumping into the implementation.
I appreciate the thoughts and effort put into this but I would like to have an issue first where we discuss the usage and the API around this, as I feel it has bigger implications for the text components.
...rest | ||
); | ||
} | ||
return PropTypes.oneOf(['h1', 'h2', 'h3'])( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused now. What's the purpose of changing the prop elementType
to as
if you have the same exact restrictions as before? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...to settle on a convention most other component libraries also have in offeing a prop called as
not elementType
. Other components, before we started with #628 assuming there too, would then offer an as
prop too if needed and not elementType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I think there are several implications that need to be discussed first instead of jumping into the implementation.
We have an issue where the prop name was suggested. We (three developers) have discused this before starting the implementation assuming that there was no arhm. Anyway, assuming that there is, lets move the discussion there. Can you lay out the specific bigger implication you have for text components there?
as
prop while deprecating elementType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for giving this a spin. I really value trying to have offer an as
prop instead of elementType
with a deprecation migration plan.
} | ||
} | ||
|
||
return PropTypes.bool(props, propName, componentName, ...rest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea. Maybe we can share these prop-types in typography/prop-types
. I know that they will be removed but it makes the actual code less noisy.
00c334e
to
73e7a79
Compare
Thinking about merging this into 10.0.0, since it already implies breaking changes. I'm updating the branch and we can discuss this further. |
73e7a79
to
50ba651
Compare
50ba651
to
6c68f3f
Compare
I have a few things I'd like to discuss about the
As such, given these changes, almost all Text components (except for Thoughts on this? |
|
6c68f3f
to
077ae53
Compare
38594d4
to
0b9eb76
Compare
The diff from the icon refactoring is showing in this PR even though this is aimed at |
0b9eb76
to
c59f17e
Compare
@montezume Done! |
as
prop while deprecating elementType
as
prop while deprecating elementType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now for 10.0.0
c59f17e
to
4cd45fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like it!! 💯
Thanks a lot also for writing the codemod, pretty dope! 🙌
4cd45fb
to
f5f938b
Compare
f5f938b
to
dcff062
Compare
Ok, the VRT detected changes now are only the prop name changes, in addition to the ones inherited from |
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
* feat(text): add as prop * chore: update specs and story * chore: update readme * refactor: use requiredIf * refactor: elementType to as * refactor: remove className prop from Text.Details component * refactor(text): use util for deprecation warning * fix(tag): style text with css selector after removal of classname prop
Summary
This PR adds a
as
prop to the Text components, as suggested by @tdeekens in #588 (comment).Deprecates
elementType
prop ofText.Headline
andText.Subheadline
components.Deprecates
isInline
prop ofText.Body
component.Questions
Body
component? (currently justspan
andp
)