Enhance `BannerNotification` to better support an elemental `description`
See original GitHub issueFeature Description
The BannerNotification
component currently allows for a non-scalar description
to be provided in the form of a React element. If provided it allows for more control over that part of the output but currently somewhat enforces that the given element is a valid child of a p
tag since the entire description is always rendered within one. This undermines the purpose of the prop’s flexibility and requires consumers to do odd things (e.g. if multiple paragraphs were desired instead of one) to work around it.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
BannerNotification
should be updated such that if a valid element is provided for itsdescription
, the given description is rendered as-is (without an added wrapper).- The case for when a non-element is provided should be updated to render the
p
tag with inner HTML set as it is now on the span tag
- The case for when a non-element is provided should be updated to render the
- Consuming use of
BannerNotification
should be updated to preserve the current styling where needed although exceptions can me made on a case-by-case basis.
Implementation Brief
- In
assets/js/components/notifications/BannerNotification/index.js
:- In the
inlineMarkup
variable assignment, locate the<p>
tag inside the.googlesitekit-publisher-win__desc
element. - Remove this wrapping
<p>
tag preserving all its internal contents. - In the condition where the
description
prop is not a valid element, wrap the existing<span>
tag with a new<p>
tag. - Wrap the adjacent elements, i.e. the “learn more” link and the “page index” in a new
<p>
tag.
- In the
- In
assets/js/components/notifications/ThankWithGoogleSupporterWallNotification.js
:- In the rendered
<BannerNotification>
component, update thedescription
prop so that its contents are wrapped with a<p>
tag instead of a<Fragment>
.
- In the rendered
- In
assets/js/components/ErrorHandler/index.js
:- In the rendered
<BannerNotification>
(imported as<Notification>
) component, update thedescription
prop so that its contents are wrapped with a<p>
tag instead of a<Fragment>
.
- In the rendered
Test Coverage
- No tests need to be added/updated. Optionally/time-permitting: add a few tests to cover this behaviour.
- Update VRT references if required.
QA Brief
- Check notification banners to appear and function correctly on a page and no Warning (from AC) appears on the page. (Eg.
ActivationBanner
,ThankWithGoogleSupporterWallNotification
,SetupSuccessBannerNotification
,AdSenseAlerts
etc…) - Description part of a banner should always appear inside single
<p>
as per the screenshot below:
( This ticket is technical and brings no updates to UI/UX. All functionality should remain the same )
Changelog entry
- Enhance the BannerNotification component to better support a description which is a React element.
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Banners - Material Design
A banner displays an important, succinct message, and provides actions for users to address (or dismiss the banner). It requires a user action...
Read more >ARIA: banner role - Accessibility - MDN Web Docs - Mozilla
A banner landmark role overwrites the implicit ARIA role of the container element upon which it is applied. It should be reserved for...
Read more >Notifications - Carbon Design System
Banners take over the top of an interface to show general notifications for the product or system, not a specific task. They persist...
Read more >Promoting Apps with Smart App Banners - Apple Developer
Overview. Smart App Banners vastly improve users' browsing experience ... Smart App Banners automatically determine whether the user's device supports your ...
Read more >The influence of banner advertisements on attention and ...
Memorability of the brand and advertising message was also enhanced. Conversely, in the condition involving faces with mutual gaze, the focus of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@techanvil pointed out that some questions around layout weren’t 100% answered here, but we shouldn’t change the visual layout of the “Learn more” link in this example.
It’s okay to change the markup here to something a bit more semantic (a
<p>
link @nfmohit proposed, or even a<div>
), but visually the “Learn more” link or other text that would accompany that content should—by default—be inline and not on a new line.Eg. This is the correct visual layout:
Looks good, but this is probably a 7 estimate, as a fair number of components are affected and should be reviewed/QA’d.
Plus: it’d be good to add a test or two for this new behaviour to make sure it’s preserved. I added mention of this to the IB, but otherwise looks good.
IB ✅