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(NotificationsPanel): new date-time formatting function #6904

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

paul-balchin-ibm
Copy link
Contributor

@paul-balchin-ibm paul-balchin-ibm commented Feb 13, 2025

Closes #6761

Introduced new Carbon utilities dateTimeFormat() function, which follows official date and time and language guidance.

dateTimeFormat() and 2 new props replaces:

  • 13 existing date/time props, which must be filled out by the app developer, for each supported language,
  • bespoke code to support those 13 props.

What did you change?

packages/ibm-products/src/components/NotificationsPanel/NotificationsPanel.tsx
packages/ibm-products/src/components/NotificationsPanel/NotificationsPanel.stories.jsx

Deleted bespoke code.

packages/ibm-products/src/components/NotificationsPanel/utils.js

Added @carbon/utilities.

packages/core/package.json

How did you test and verify your work?

  • Storybook

@paul-balchin-ibm paul-balchin-ibm requested a review from a team as a code owner February 13, 2025 14:27
@paul-balchin-ibm paul-balchin-ibm requested review from elycheea and makafsal and removed request for a team February 13, 2025 14:27
Copy link

netlify bot commented Feb 13, 2025

Deploy Preview for ibm-products-web-components ready!

Name Link
🔨 Latest commit 21d8f37
🔍 Latest deploy log https://app.netlify.com/sites/ibm-products-web-components/deploys/67b6188c4d25ff0008e93386
😎 Deploy Preview https://deploy-preview-6904--ibm-products-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 Feb 13, 2025

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit 21d8f37
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/67b6188ccce76e0009b75f21
😎 Deploy Preview https://deploy-preview-6904--carbon-for-ibm-products.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 Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.70%. Comparing base (cdaceb2) to head (21d8f37).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6904      +/-   ##
==========================================
+ Coverage   81.56%   81.70%   +0.13%     
==========================================
  Files         403      402       -1     
  Lines       13050    12991      -59     
  Branches     4297     4267      -30     
==========================================
- Hits        10644    10614      -30     
+ Misses       2406     2377      -29     
Components Coverage Δ
ibm-products ∅ <ø> (∅)
ibm-products-web-components ∅ <ø> (∅)

@@ -68,6 +68,7 @@
"vite": "^6.0.7"
},
"dependencies": {
"@carbon/utilities": "^0.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is being used by the actual NotificationsPanel component, we would need to move this into the packages/ibm-products/package.json.

However, re-reading the original issue, it looks like we actually intended for the user to use dateTimeFormat, which means we would probably want to use the utility in the data or story rather than in the component itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our intention was to introduce a new timeAgoText prop and deprecating but not removing the existing props. Since we’re in a major version, we don’t want to remove functionality that could break for adopters when they update to the latest version. Deprecation first is the softer approach and allows us to direct adopters to the new recommended implementation.

You can see an example of how we’ve previously deprecated props here.

@paul-balchin-ibm paul-balchin-ibm marked this pull request as draft February 20, 2025 19:33
@paul-balchin-ibm
Copy link
Contributor Author

Put into draft mode.

After further discussion, there are still open questions on how to deprecate the old props gracefully.

We can keep the old props, mark them as deprecated, and remove the timeAgo() function. The new, internal dateTimeFormat() will take over gracefully.

But, if the app developer was providing translations using the old props, these will now only render the default English, since the old functionality has been removed. For the app developer to specify other languages, they will need to know to use the new dateTimeLocale prop (i.e. 'en-US', 'fr_CA', etc).

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.

NotificationsPanel: "relative" time stamp is bespoke code and not localized
2 participants