site-kit-wp: Make "New" metric badge layout more consistent between Data Blocks and Report Tables.

Feature Description

Since the implementation of #6904, the “New” badges in Report Tables display above the metric titles. However, the badges in Data Blocks still display beside/below the titles, which is a bit inconsistent, particularly so at narrower viewport sizes. This is most evident on the Entity Dashboard. To illustrate:

The new Report Table layout:

image.png

The Data Block layout:

image.png


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The “New” metric badges in Data Blocks should follow the same design as those in the Report Tables.
  • Specifically that means the Conversions metric in the Search Traffic widget on the Main Dashboard, and the Engagement Rate metric on the Search Traffic widget and Sessions and Engagement Rate metrics on the Overall Page Metrics widget on the Entity Dashboard should be updated to appear above the metric names instead of beside/below them.

Implementation Brief

Within assets/js/components/DataBlock/index.js:

  • Update the badge prop to accept a boolean or React node. If the value true is passed, render a hidden Badge in order to allow the layout to align with a badge-containing Data Block.
  • Move the badge above the rendered title.

Within assets/js/modules/search-console/components/dashboard/SearchFunnelWidgetGA4/Overview/index.js and assets/js/modules/analytics/components/dashboard/DashboardOverallPageMetricsWidgetGA4.js:

  • Pass true for the badge prop to the DataBlock components which don’t have a “New” badge.

Make additional DOM and CSS changes as necessary to bring the with-badge layout more in line with Report Tables as per the AC. Note, though, that due to the way Data Blocks are designed, it doesn’t make sense to try to right-align the badges/titles, rather they should be left or center-aligned (for the default vs “button” case) as per the existing design.

Finish off this PR: https://github.com/google/site-kit-wp/pull/7008

Test Coverage

  • Update VRT reference images as needed.

QA Brief

  • Ensure ga4Reporting feature flag is enabled.
  • Set up Site Kit on a site with Analytics data and Analytics connected, including GA4 and GA4 data.
  • Scroll down to “Search traffic over the last 28 days” and observe the “new” badge above “Conversions”. It should be above the “Conversions” text and not beside it, with no layout issues in the rest of the data blocks/tab selects for the chart, eg.:
  • Navigate to the Entity Dashboard, and verify the “new” badge is correctly aligned for the “Engagement Rate” metric on the “Search traffic” widget, and “Sessions” and “Engagement Rate” metrics on the Overall Page Metrics widget.
  • Verify these at various breakpoints.
CleanShot 2023-05-11 at 12 09 07

QA Update

Changelog entry

  • Enhance consistency of layouts with “New” badges.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15

Most upvoted comments

@techanvil I am happy to go with what you have said. Will get this into approval.

Sounds good! In that case, IB ✅

@techanvil I think this is better, but I still wonder about needing to pass the boolean at all. Is it possible to use the “with-badge” layout all of the time and render a hidden badge when a component isn’t passed?

I’d just love it if we didn’t need to pass that prop unless we are actually sending it our own badge thinking

The problem with this is we don’t always want to show an empty space above the title where a badge would be. We only want to do so for Data Blocks which are displayed next to ones with a badge, which means those in the GA4 Search Traffic and Overall Page Metrics widgets; the DataBlock component is used in many other places.

An additional point to consider is the “New” badges will be removed in time, but we may yet find other cases where a badge would be useful, it generally seems quite a good idea to have a flexible component in this regard. But really this is a bit of a moot point as, AFAICT, the fact we use DataBlock in various scenarios where we don’t want the empty space is the overriding factor.

@techanvil thanks for raising this! definitely makes sense to fix this so it aligns with how the new badges are displayed on the main dashboard. +1 on following the design from the main dashboard.