-
Notifications
You must be signed in to change notification settings - Fork 8
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
adds the PromoBar
component and a new custom hook useNotificationMessage
to the PatronPage
#606
Conversation
6932a07
to
d8b0ba8
Compare
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.
Great work!
I have a few comments
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.
LGTM 👍
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.
Greatness. And the annoying reviewer has some more remarks
7392329
to
cfd0330
Compare
The `useNotificationMessage` hook manages to handle auto-scrolling to the top and setting a removal timeout for notifications. It integrates seamlessly with `promobar` and offers utility for additional use-cases.
Modified the hook to return either the `Promobar` component or 'null' as the initial item in the array. Also provided default settings for `timeout` and `scrollToTop` which can be overridden during usage.
In this commit, `NotificationComponent` has been extracted from the `useNotificationMessage` hook. By wrapping the retrun of `NotificationComponent` in a function, we enhance the reactivity of the component, ensuring that its body (the JSX) is re-evaluated with each render. This method is beneficial as it provides a mechanism to always capture the most recent state or props, eliminating concerns about stale closures.
Centralize all `useNotificationMessage` related logic.
When the handler has been called the user should be sent to the top of the page
0df507e
to
c69fb9d
Compare
- Replaced custom prop-based component identification with data-testid attributes for better test clarity and maintainability. - Introduced afterEach cleanup in tests to ensure isolated test environments. - Updated test descriptions for consistency and better readability. - Simplified ComponentWithNotificationMessage by removing unnecessary props.
Changes: 1. Import 'screen' from '@testing-library/react' for improved element querying. 2. Update the expectation for the non-existence of the message before the button click to use 'screen.queryByText' instead of asserting on the wrapper's content. 3. Modify the expectation after the button is clicked to check the existence of the message using 'screen.queryByText', ensuring a more robust and readable test.
- Updated `ComponentWithNotificationMessage` to accept `timeout` and `scrollToTop` options. - Added two new test cases: 1. To verify message display indefinitely when timeout is removed. 2. To ensure there's no scroll to top action when `scrollToTop` is set to false.
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.
Great additions!
Some comments need to be clarified though before approval
@@ -240,11 +240,20 @@ export default { | |||
defaultValue: "You used @this ebooks out of you quota of @that ebooks", | |||
control: { type: "text" } | |||
}, | |||
phoneInputMessageText: { | |||
patronPagePhoneInputMessageText: { |
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.
If you have refactored this data prop, what about dpl-cms then?
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.
it is fixed here: https://github.com/danskernesdigitalebibliotek/dpl-cms/pull/427/files
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.
LGTM 👍
7f8c3fd
into
danskernesdigitalebibliotek:develop
Link to issue
https://reload.atlassian.net/browse/DDFLSBP-84
Description
This Pull Request adds the
PromoBar
component and a new custom hookuseNotificationMessage
to thePatronPage
.The
PromoBar
provides visual notifications to users, while theuseNotificationMessage
hook is designed to manage these notifications by handling auto-scrolling and setting removal timeouts.Screenshot of the result
Skaermoptagelse.2023-10-13.kl.14.54.27.mov