-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: update align prop value across various components #17834
fix: update align prop value across various components #17834
Conversation
✅ Deploy Preview for v11-carbon-web-components ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17834 +/- ##
==========================================
- Coverage 80.45% 80.44% -0.01%
==========================================
Files 406 406
Lines 14041 14059 +18
Branches 4347 4399 +52
==========================================
+ Hits 11296 11310 +14
- Misses 2579 2582 +3
- Partials 166 167 +1 ☔ View full report in Codecov by Sentry. |
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 taking a look at this! The old values must remain for backwards compatibility. I think you could mirror the approach taken in popover
carbon/packages/react/src/components/Popover/index.tsx
Lines 50 to 79 in 4b4fe02
/** | |
* Deprecated popover alignment values. | |
* @deprecated Use NewPopoverAlignment instead. | |
*/ | |
export type DeprecatedPopoverAlignment = | |
| 'top-left' | |
| 'top-right' | |
| 'bottom-left' | |
| 'bottom-right' | |
| 'left-bottom' | |
| 'left-top' | |
| 'right-bottom' | |
| 'right-top'; | |
export type NewPopoverAlignment = | |
| 'top' | |
| 'bottom' | |
| 'left' | |
| 'right' | |
| 'top-start' | |
| 'top-end' | |
| 'bottom-start' | |
| 'bottom-end' | |
| 'left-end' | |
| 'left-start' | |
| 'right-end' | |
| 'right-start'; | |
export type PopoverAlignment = DeprecatedPopoverAlignment | NewPopoverAlignment; |
The proptypes use a helper to distinguish them as deprecated
carbon/packages/react/src/components/Popover/index.tsx
Lines 457 to 465 in 4b4fe02
align: deprecateValuesWithin( | |
PropTypes.oneOf([ | |
'top', | |
'top-left', // deprecated use top-start instead | |
'top-right', // deprecated use top-end instead | |
'bottom', | |
'bottom-left', // deprecated use bottom-start instead | |
'bottom-right', // deprecated use bottom-end instead |
If align
is actually used anywhere other than passed through to the child component you can use the prop mapper function to help handle the new values. This might not apply to these components though, I'm not sure.
carbon/packages/react/src/components/Popover/index.tsx
Lines 81 to 93 in 4b4fe02
const propMappingFunction = (deprecatedValue) => { | |
const mapping = { | |
'top-left': 'top-start', | |
'top-right': 'top-end', | |
'bottom-left': 'bottom-start', | |
'bottom-right': 'bottom-end', | |
'left-bottom': 'left-end', | |
'left-top': 'left-start', | |
'right-bottom': 'right-end', | |
'right-top': 'right-start', | |
}; | |
return mapping[deprecatedValue]; | |
}; |
Hi @tay1orjones : |
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!
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, sorry for the delay!
77fc925
Closes #17585
Support the newly added properties like
bottom-end
,bottom-start
,left-end
,left-start
in , and components.Changelog
Changed