Skip to content
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

Conversation

Shankar-CodeJunkie
Copy link
Contributor

Closes #17585

Support the newly added properties like bottom-end, bottom-start, left-end, left-start in , and components.

Changelog

Changed

top
bottom
left
right
top-start
top-end
bottom-start
bottom-end
left-end
left-start
right-end
right-start

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 31327ba
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/671ca4b5a1867b0008e5ea63
😎 Deploy Preview https://deploy-preview-17834--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 0c8bacf
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6717ee8d6096ce0008a47890
😎 Deploy Preview https://deploy-preview-17834--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 0c8bacf
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6717ee8d549783000711631d
😎 Deploy Preview https://deploy-preview-17834--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 31327ba
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/671ca4b58380330008f077c7
😎 Deploy Preview https://deploy-preview-17834--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 31327ba
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/671ca4b57f31b400084256e3
😎 Deploy Preview https://deploy-preview-17834--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.44%. Comparing base (f4f3dfe) to head (31327ba).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
...s/react/src/components/CodeSnippet/CodeSnippet.tsx 33.33% 2 Missing ⚠️
...s/react/src/components/OverflowMenu/next/index.tsx 33.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@tay1orjones tay1orjones left a 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

/**
* 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

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.

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];
};

@Shankar-CodeJunkie
Copy link
Contributor Author

Hi @tay1orjones :
I have pushed the changes to the PR. I have refactored the files by taking similar changes done on popover component.

Copy link
Member

@emyarod emyarod left a 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!

Copy link
Member

@tay1orjones tay1orjones left a 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!

@tay1orjones tay1orjones enabled auto-merge October 31, 2024 19:40
@tay1orjones tay1orjones added this pull request to the merge queue Nov 7, 2024
Merged via the queue into carbon-design-system:main with commit 77fc925 Nov 7, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: CodeSnippet suggests align value that isn't available yet
3 participants