-
Notifications
You must be signed in to change notification settings - Fork 291
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
Extract "Subtle Notification" styling/logic to a shared SubtleNotification
component
#8725
Comments
@tofumatt here's my first pass on the IB. We could simplify this further by also bringing the dismiss logic into the new Taking it further we could bring the render logic into the component also, but I don't see much of a benefit here as some notification render logic is more complex than others so we'd need to pass it as a boolean prop from the parent componet. I believe it's cleaner to have this logic in a component within the module it relates to and to return null here instead of rendering the component. site-kit-wp/assets/js/components/notifications/GA4AdSenseLinkedNotification.js Lines 168 to 182 in 7704dc4
|
@benbowler To future-proof this one a bit, I think at least the I agree about keeping the logic to display the notification inside each component rather than it being passed as a prop. It's more awkward that way 👍🏻 Re: your idea about unifying the dismiss logic: I think it seems to make sense to consolidate that dismissal into the component, but in reality it's just one line. 🤔 Line 64 in b820762
Given the components themselves will already be checking that slug to see if it is dismissed to know whether they should render the notification, it probably makes sense to just let each component render as many CTA buttons at they like. Plus, the logic to dismiss each notification isn't even totally consistent in the plugin right now. The PAX one just unsets a query arg: site-kit-wp/assets/js/modules/ads/components/notifications/PAXSetupSuccessSubtleNotification.js Line 41 in b820762
I think passing If you're cool with |
Thanks @tofumatt updated. |
Awesome, thanks! IB ✅ |
Hey @10upsimon, just want to give you a heads up that I'm making a couple of changes to the SCSS for the subtle notifications in PR #9046. Looking at the IB for this issue, it might not actually affect it, but I figure it's worth a mention just in case! |
QA brief updated 🙂 |
QA Update
|
@mohitwp Oh, right, I forgot about that, and I had tested it another (more involved) way 😅 That's totally fine, I think the pass cases are enough to move this to approval, so I've moved it there 👍🏻 |
QA Update ✅Thanks @tofumatt !
|
Feature Description
We intentionally did not create a "Subtle Notification" component for the new styles of component rendered by components like https://github.com/google/site-kit-wp/blob/f5a89cf2cd5978ee012308281a2840e03192b2c4/assets/js/components/notifications/GA4AdSenseLinkedNotification.js
But now that we have a few of these "Subtle Notifications", we can see how they're used in real-world scenarios and should be able to extract the logic for them into a common, shared component (eg.
SubtleNotification
) that all existing notifications should move to using and new notifications can use.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
SubtleNotification
should be created that implements the subtle notification components, with the ability to provide a header, text, and CTA actions, eg:GA4AdSenseLinkedNotification
,SetupSuccessSubtleNotification
, andAudienceSegmentationSetupSuccessSubtleNotification
, should be used to extract this new component. They should then be converted to use<SubtleNotification>
instead of the existing approach.Implementation Brief
assets/js/modules/analytics-4/components/SubtleNotification.js
, that has the following props:title
(string): Title passed through the__
function.description
(ReactNode): Description passed as an element to enable DOM elements such as links in the description in future.onDismiss
(function): Function to call to dismiss the notification.additionalCTA
(ReactNode|false): An optional CTA component (used forassets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSegmentationSetupSuccessSubtleNotification.js
to show the "Show me" CTA)assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSegmentationSetupSuccessSubtleNotification.js
, replacing the title, description, dismiss function and additional CTA components with the values passed from the props.<AudienceSegmentationSetupSuccessSubtleNotification />
,<GA4AdSenseLinkedNotification />
,<SetupSuccessSubtleNotification />
and<PAXSetupSuccessSubtleNotification />
to use the newassets/js/modules/analytics-4/components/SubtleNotification.js
instead of duplicating the DOM.Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: