Page MenuHomePhabricator

[lib] introduced components/modal to lib
AbandonedPublic

Authored by ginsu on Oct 12 2022, 12:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 6, 10:41 PM
Unknown Object (File)
Fri, Sep 6, 10:41 PM
Unknown Object (File)
Fri, Sep 6, 10:41 PM
Unknown Object (File)
Fri, Sep 6, 10:41 PM
Unknown Object (File)
Sat, Aug 24, 9:38 AM
Unknown Object (File)
Sat, Aug 24, 9:38 AM
Unknown Object (File)
Sat, Aug 24, 9:38 AM
Unknown Object (File)
Sat, Aug 24, 9:33 AM

Details

Summary

introduced components directory, and modal.react.js, modal.css, and modal-provider.js files to lib. I have a strong feeling that once D5315 gets approved, I will need to bring that logic into the modal.react.js file as well. Thinking that will be an additional diff to this stack

Next Steps:

  1. Refactor modal.react.js in web to use lib Modal component
  2. Refactor modal-provider.js imports in web to use lib instead of web
  3. Refacor modal.react.js in landing
  4. Refactor modal-provider.js imports in landing to use lib instead of landing

Linear Task: ENG-2038

Test Plan

N/A

More testing will come when refactoring web, but all of this code was pretty much approved in this diff

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, rohan, abosh.
ginsu edited the test plan for this revision. (Show Details)
lib/components/modal-provider.react.js
1–68 ↗(On Diff #17525)

Used the Modal provider in web as inspiration

lib/components/modal.css
1–13 ↗(On Diff #17525)

Used the Modal styles on web as inspiration

lib/components/modal.react.js
1–54 ↗(On Diff #17525)

Used the Modal Component on web as inspiration

repositioned useLayoutEffect to be under useRef

ginsu added inline comments.
lib/components/modal-provider.react.js
1–68

Used the Modal provider in web as inspiration

lib/components/modal.css
1–13

Used the Modal styles on web as inspiration

lib/components/modal.react.js
1–54

Used the Modal Component on web as inspiration

atul requested changes to this revision.Oct 13 2022, 8:50 AM

It looks like we're introducing a new modified modal.react.js in lib/components that will eventually be used by both web and landing... but is "dead code" for now.

I think a better approach would be to start with a noop diff that moves the existing modal components in web to lib and adjusting imports to have things work as before.

If you think this is the best approach, would be good to explain the differences between the existing and new modal components.

lib/components/modal-provider.react.js
1–68

Can you flag any differences?

As a reviewer I can pull up the files side-by-side and try to spot the differences (more likely use a diff tool), but it'd be way easier if the diff author handled that


In this case looks like the only differences are whitespace/newlines?

lib/components/modal.css
1–13

Can you flag any differences?

As a reviewer I can pull up the files side-by-side and try to spot the differences (more likely use a diff tool), but it'd be way easier if the diff author handled that


In this case looks like the difference is using hex value for background-color instead of rgba(...)?

lib/components/modal.react.js
1–54

Can you flag any differences?

As a reviewer I can pull up the files side-by-side and try to spot the differences (more likely use a diff tool), but it'd be way easier if the diff author handled that


It looks like there are a lot of differences here.

Why do we need to modify the modal components in web so much? Would it not be possible to just move the modal components from web/modals to lib/components and change imports?

This revision now requires changes to proceed.Oct 13 2022, 8:50 AM
lib/components/modal-provider.react.js
1–68

Only difference here is newlines/whitespace for better readabilty

lib/components/modal.css
1–13

Only difference is switching background-color to hex value from rgba

lib/components/modal.react.js
1–54

This component is pretty much just the dark overlay surrounding the modal. The reason why I didn't just copy and paste the same modal component from web is that the web modal has a bunch of other features that landing does not need, for instance, name, icon, and close button. All these extra features also use other dependencies and components that would also need to be brought over to lib.

The big difference between the modal on web and this one here is:

  • This uses useLayoutEffect and not useEffect. Reasoning here
  • I stripped out all the unnecessary features from web including things like header icon, name, corner close button
In D5353#158422, @atul wrote:

It looks like we're introducing a new modified modal.react.js in lib/components that will eventually be used by both web and landing... but is "dead code" for now.

I think a better approach would be to start with a noop diff that moves the existing modal components in web to lib and adjusting imports to have things work as before.

Very much agree with @atul... this diff should be moving the file instead of introducing a copy. The approach you took here makes it hard to easily see the changes. Read more

Planning changes to separate diff out

abandoning diff due to better refactor strategy with other diffs