Page MenuHomePhabricator

[native] introduce loading logic to relationship prompt button
ClosedPublic

Authored by ginsu on Jun 27 2024, 1:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 12:24 PM
Unknown Object (File)
Mon, Nov 11, 7:51 AM
Unknown Object (File)
Mon, Nov 11, 4:48 AM
Unknown Object (File)
Mon, Nov 11, 2:44 AM
Unknown Object (File)
Mon, Nov 11, 2:00 AM
Unknown Object (File)
Mon, Nov 11, 1:28 AM
Unknown Object (File)
Sun, Nov 10, 5:57 PM
Unknown Object (File)
Fri, Nov 8, 10:38 PM
Subscribers

Details

Summary

This diff introduces the loading logic to the relationship prompt button.

Depends on D12595

Test Plan

Confirmed that the relationship prompt buttons in the user profile show a loading spinner when the action is in progress

Loading state:

Screenshot 2024-07-02 at 11.50.42 PM.png (1×944 px, 624 KB)

Screenshot 2024-07-02 at 11.50.21 PM.png (1×1 px, 789 KB)

Non loading state:

Screenshot 2024-07-02 at 11.55.20 PM.png (1×1 px, 802 KB)

Screenshot 2024-07-02 at 11.55.27 PM.png (1×1 px, 793 KB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu requested review of this revision.Jun 27 2024, 1:18 PM
ginsu retitled this revision from [native] intorduce loading logic to relationship prompt button to [native] introduce loading logic to relationship prompt button.Jun 27 2024, 1:19 PM
ginsu edited the summary of this revision. (Show Details)
ginsu added reviewers: inka, ashoat.
native/components/relationship-button.react.js
10 ↗(On Diff #41768)

Introduced this new type with intention that this can be extended in the future with new sizes (M, L, XL, etc)

69 ↗(On Diff #41768)

If these copy changes are good, will make sure I dedup the copy + pasted strings with D12595 before landing

93 ↗(On Diff #41768)

Made the icon a bit smaller. It felt a little too big for me + looked a better with a smaller icon imo, but happy to change it back if people disagree

Before:

Screenshot 2024-06-27 at 4.31.11 PM.png (1×1 px, 789 KB)

Screenshot 2024-06-27 at 4.32.40 PM.png (1×1 px, 818 KB)

After:

Screenshot 2024-06-27 at 4.34.46 PM.png (1×1 px, 807 KB)

Screenshot 2024-06-27 at 4.35.24 PM.png (1×1 px, 828 KB)

native/user-profile/user-profile-relationship-button.react.js
99 ↗(On Diff #41768)

The new small size makes the font of the button text a bit smaller so that we can fit all the elements nicely in the button

Before:

Screenshot 2024-06-27 at 4.41.25 PM.png (1×944 px, 660 KB)

After:

Screenshot 2024-06-27 at 4.41.29 PM.png (1×944 px, 652 KB)

158 ↗(On Diff #41768)

Hardcoded the height here so that we guarantee that when the button state goes to loading then the height of the button never changes; however, recently got some feedback about hardcoding the height in CSS being a no-no. Looks like visibility: hidden is not supported in react native, but if we still don't want this, I can explore other ways of doing this

This height was determined by using the element inspector in my simulator

ashoat requested changes to this revision.Jul 1 2024, 1:20 PM
ashoat added inline comments.
native/components/relationship-button.react.js
69 ↗(On Diff #41768)

I don't like the new, longer strings.

  1. We already say eg. "incoming friend request", so it's unambiguous what's being accepted/rejected/withdrawn
  2. The text looks too scrunched up
native/user-profile/user-profile-relationship-button.react.js
158 ↗(On Diff #41768)

Let's remove this. The underlying issue is that the button changes height when loading.

The button changes height because one thing is unrendered (text) and another thing is rendered instead (spinner).

We should make the following changes:

  1. Always render one of these (eg. text) normally, but make it invisible when we don't want to see it
    • We can do this by changing its color to match the background as a baseline
    • But there might be a better way to do this (opacity: 0)
  2. Render the spinner with position: absolute
    • Don't bother rendering it when not necessary
169 ↗(On Diff #41768)

Same here

This revision now requires changes to proceed.Jul 1 2024, 1:20 PM
ashoat added inline comments.
native/components/relationship-button.react.js
42 ↗(On Diff #41923)

Feels like there's some duplication of the ButtonContentContainer stuff you also have in D12600. What do you think of my suggestion there to factoring some of the logic out so it can be reused here?

70–80 ↗(On Diff #41923)

Nit: personally I don't love this use of ternary syntax. See point 3 here

This revision is now accepted and ready to land.Jul 3 2024, 6:41 AM
This revision was landed with ongoing or failed builds.Jul 3 2024, 3:13 PM
This revision was automatically updated to reflect the committed changes.