-
Notifications
You must be signed in to change notification settings - Fork 153
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
Show a banner based on some url param #5620
Show a banner based on some url param #5620
Conversation
@@ -7,11 +7,11 @@ block body | |||
block banner | |||
mixin login-signup("header") | |||
header | |||
!= stitch && stitch.components.NavBar({ user: sd.CURRENT_USER, notificationCount: sd.NOTIFICATION_COUNT }) | |||
!= stitch && stitch.components.NavBar({ user: sd.CURRENT_USER, flashMessage: sd.flashMessage, notificationCount: sd.NOTIFICATION_COUNT }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what the difference is between this and index.jade, and why we have 2 navbars in this file...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I am responsible for the double-header. 😅 (#5261)
I think what you have is fine, but note that the sticky-header behavior on mobile web for non-reaction pages is a little weird. I would verify that this looks fine on the home page (logged in and logged out) and on the artist page (logged in/out) to be sure that nothing's messed up!
403f450
to
1c121d9
Compare
@erikdstock - if y'all can hold off on merging this. Very close with the other PR and then y'all can rebase. We're going to do a release of some analytics updates but it would be best if this wasn't in that batch. |
That's fine! We're working on adding some tests for this behavior now. Can you ping us when the other PR is off and away? |
Error RangeError
Dangerfile
|
Codecov Report
@@ Coverage Diff @@
## master #5620 +/- ##
========================================
- Coverage 79.3% 79.3% -0.1%
========================================
Files 1250 1250
Lines 34034 34035 +1
Branches 2072 2073 +1
========================================
Hits 27021 27021
- Misses 5999 6000 +1
Partials 1014 1014 |
@erikdstock - Regarding approach, one thought is: rather than passing this data all through the system in order to SSR render, we simply look at the url in a const flashMessage = useFlashMessage()
...
<Box>
{flashMessage?.message && <FlashMessage message={flashMessage.message} />}
</Box> This can happen all on the client. As that url bar query param state will never be persisted across urls we don't need to worry about it flashing in when a user clicks something and a new page re-renders. Thoughts? |
Talking with @dleve123 much prefer this idea and spiked on it for a bit but weren't able to get it completely working. We'd like to merge this if tests pass and then iterate on it next week when we return for the more complicated next steps on the FlashBanner component, at which point (once working) we will undo all changes related to |
It might be worth reaching out to #dev-help if y'all are running into trouble with the client-side approach (versus rewinding everything)? A quick glance at https://github.com/artsy/force/pull/5620/files#diff-3df7ffd25fef9729a61746506a33251bR34 and i think this could be done with just a couple lines of code. |
Co-authored-by: Erik Stockmeier <erik.d.stock@gmail.com>
Co-authored-by: Erik Stockmeier <erik.d.stock@gmail.com>
Co-authored-by: Daniel Levenson <dleve123@gmail.com>
83b7e7a
to
9d421c4
Compare
@dleve123 and I were able to get it working this morning, much better- thanks for the tip! |
src/v2/Components/FlashBanner.tsx
Outdated
} | ||
}, []) | ||
|
||
if (!messageCode) return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this above the effect to show that we're exiting early and to avoid registering the effect inside of react's execution loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow you here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaning, if (!messageCode) return null
can move up above the React.useEffect
call. Since messageCode
is null, and we know that via props, we can immediately check for it right at the top of the component and exit early.
96ca972
to
b4b15bc
Compare
Related 🔒 Jira Ticket
Similar Eigen PR: artsy/eigen#3325
Initial working solution to a problem: I want to show a banner when the user passes email confirmation. This does it by catching the param very early in express, adding it to
sd
and then passing it into ourNavBar
component. It's a little bit over-engineered for what it is doing right now, a result of my trying to understand existing practices and where things were coming from.Questions here:
bannerCode
, my new banner-relatedNavBar
prop to too many places (eg a NavBar in a jade template).