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 lightbox prop drilling #6073

Merged
merged 5 commits into from
Nov 4, 2024
Merged

Refactor lightbox prop drilling #6073

merged 5 commits into from
Nov 4, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 1, 2024

Stacked on #6047


No changes to behavior.

This may be easier to read commit by commit.

  • I get rid of the cloneElement and the weird data flow where the footer reads data via the hook. A more natural way to express this is to have the parent component pass a render prop to the child, closing over the lightbox data.
  • Then I get rid of the two lightbox types. As far as the lightbox is concerned, everything here is images. It shouldn't be thinking about profile pictures etc. This makes it annoying to evolve the code. So I unified the types.
  • Then I refactor LightboxFooter to take all images. This is a bit cleaner and allows it to make its own decisions about how to deal with them (right now it just reads the current one, but it doesn't have to).
  • Finally, I decide to move LightboxFooter so it lives together with the actual lightbox shell. I keep some of the app-specific logic out of it but the visual parts are now moved. This will make adding animation later easier.

Test Plan

Open lightbox with 1 image, or with multiple. Flick through them. Verify Save/Share buttons work and point at the right image. Verify the alt text shows up for the right image.

Open lightbox in profile too. Verify that works.

type: 'profile-image',
profile: profile,
images: [
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is copypasta moved from another file (see below)

@gaearon gaearon mentioned this pull request Nov 1, 2024
9 tasks
Copy link

github-actions bot commented Nov 2, 2024

Old size New size Diff
8.12 MB 8.12 MB 0 B (0.00%)

Copy link
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

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

lgtm

Base automatically changed from aspect-1 to main November 4, 2024 21:28
@arcalinea arcalinea temporarily deployed to aspect-2 - social-app PR #6073 November 4, 2024 21:30 — with Render Destroyed
@gaearon gaearon merged commit 26c4837 into main Nov 4, 2024
6 checks passed
@gaearon gaearon deleted the aspect-2 branch November 4, 2024 21:31
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.

3 participants