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

refactor: remove lodash dependency #6809

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

matthewgallo
Copy link
Member

@matthewgallo matthewgallo commented Jan 29, 2025

Closes #6805

To help reduce our footprint, this PR removes lodash as a dependency, as everything we used from lodash could be done natively. I added utilities for everything we previously imported from lodash.

Utilities replaced:
clamp
debounce
throttle
isEqual

I also added support for prefixing in our current uuidv4 utility as this was possibly with uniqueId from lodash (previously used in useDatagrid).

What did you change?

Any file importing anything from lodash, now using our own utilities that do the same thing

How did you test and verify your work?

Manually verified in storybook and made sure all tests pass

Copy link

netlify bot commented Jan 29, 2025

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

Name Link
🔨 Latest commit ceb8682
🔍 Latest deploy log https://app.netlify.com/sites/ibm-products-web-components/deploys/67a67810ac280100089f87f8
😎 Deploy Preview https://deploy-preview-6809--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 Jan 29, 2025

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

Name Link
🔨 Latest commit ceb8682
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/67a678103684300008589c01
😎 Deploy Preview https://deploy-preview-6809--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 Jan 29, 2025

Codecov Report

Attention: Patch coverage is 79.34783% with 19 lines in your changes missing coverage. Please review.

Project coverage is 81.52%. Comparing base (a9a4285) to head (ceb8682).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6809      +/-   ##
==========================================
+ Coverage   81.49%   81.52%   +0.03%     
==========================================
  Files         399      402       +3     
  Lines       12978    13028      +50     
  Branches     4270     4287      +17     
==========================================
+ Hits        10576    10621      +45     
- Misses       2402     2407       +5     
Components Coverage Δ
ibm-products ∅ <ø> (∅)
ibm-products-web-components ∅ <ø> (∅)

@matthewgallo matthewgallo marked this pull request as ready for review January 30, 2025 16:07
@matthewgallo matthewgallo requested a review from a team as a code owner January 30, 2025 16:07
@matthewgallo matthewgallo requested review from elycheea, amal-k-joy and jlongshore and removed request for a team January 30, 2025 16:07
};

useEffect(() => {
const observer = new IntersectionObserver(
Copy link
Member Author

@matthewgallo matthewgallo Jan 30, 2025

Choose a reason for hiding this comment

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

I did some refactoring here to use IntersectionObserver rather than a scroll event for tracking when the gradients should become visible. This should be more performant, also the behavior with the component using the throttle utility seemed subtly different than when using throttle from lodash so I opted to use an intersection observer.

Copy link
Contributor

@elycheea elycheea left a comment

Choose a reason for hiding this comment

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

Overall looking good — I do see some of the new utils aren’t covered by tests yet. Also might be some opportunity to clean up an extra clamp util in Coachmark helpers.

Still have scroll gradient changes left to review though. :)

Copy link
Contributor

@amal-k-joy amal-k-joy left a comment

Choose a reason for hiding this comment

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

Awesome work. 🎉
Some small comments has added.

@matthewgallo
Copy link
Member Author

Build/type issues will be resolved when #6861 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor to remove lodash as a dependency
3 participants