Skip to content

Update post list stats column to use icons#4136

Merged
acicovic merged 1 commit intodevelopfrom
update/post-list-stats-icon-display
Apr 6, 2026
Merged

Update post list stats column to use icons#4136
acicovic merged 1 commit intodevelopfrom
update/post-list-stats-icon-display

Conversation

@acicovic
Copy link
Copy Markdown
Collaborator

@acicovic acicovic commented Apr 3, 2026

Summary

This PR updates the Parse.ly Stats admin column to display metrics using Dashicons instead of plain text labels, making it more compact. Includes i18n and accessibility improvements and a stylesheet dependency fix.

Before

  • Column was labeled "Parse.ly Stats (7d)"
  • Each metric value included a translated label suffix appended in PHP (e.g., "50 page views", "20 visitors", "42 avg time")
  • Stats were displayed as text spans stacked vertically with <br/> separators, no icons
  • Page views metric was black; visitors and avg time metrics were gray (inherited from parent)
  • Column had explicit widths: 200px (desktop), 150px (mobile)
  • The stylesheet was enqueued with JS asset dependencies (including wp-i18n), causing a WP warning
  • Time values displayed with "sec." suffix for sub-minute values (e.g., "42 sec.")
  • Placeholder used "..."

After

  • Column is labeled "Parse.ly (7d)"
  • Label suffixes are removed from PHP stat values; each metric passes only the formatted number/time to JS
  • Each metric is displayed with a Dashicon (visibility, groups, clock) followed by the value, laid out inline with flex wrapping
  • All three metric values are consistently styled (gray color moved exclusively to the placeholder span)
  • Column width declarations removed; column sizes naturally
  • Stylesheet enqueued with an empty dependencies array, resolving the WP warning
  • Time values use abbreviated "s" suffix for sub-minute values (e.g., "42s")
  • Screen reader labels use sprintf/__() so translators can reorder the value within the phrase; visible values carry aria-hidden="true" to prevent double-reading
  • Placeholder changed from "..." to "—"
  • Boundary test cases added for time formatting at exactly 60s and 3600s

Screenshots

850px viewport

Before After
image image

1200px viewport

Before After
image image

1500px viewport

Before After
image image

Summary by CodeRabbit

  • New Features

    • Added icons to post stats display for enhanced visual presentation.
  • Style

    • Shortened column label from "Parse.ly Stats (7d)" to "Parse.ly (7d)."
    • Redesigned stats layout with improved spacing and alignment.
    • Simplified time formatting (e.g., "1s" instead of "1 sec.").
    • Removed unit suffixes from stat values; labels now display separately.
    • Updated placeholder from ellipsis to em dash.

@acicovic acicovic requested a review from a team as a code owner April 3, 2026 08:46
@acicovic acicovic self-assigned this Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

This PR refactors the Parse.ly post list stats component display by updating time formatting conventions (seconds display changes from "Ns sec." to "Ns"), removing unit label suffixes from metric values (e.g., "page views"), redesigning the stats layout with flexbox styling, and introducing a helper function for consistent stat span rendering with screen reader text.

Changes

Cohort / File(s) Summary
Utils Time Formatting
src/Utils/class-utils.php, tests/Unit/Utils/UtilsTest.php
Updated get_formatted_time() output for sub-60-second values from "N sec." format to "Ns" format (no space, no trailing period).
Post List Stats Component
src/content-helper/post-list-stats/class-post-list-stats.php, src/content-helper/post-list-stats/post-list-stats.scss, src/content-helper/post-list-stats/post-list-stats.ts
Removed unit/label text suffixes from metric responses; updated column label and placeholder; introduced getStatSpan() helper for consistent icon + screen-reader text rendering; redesigned layout from simple text to flexbox with gaps and adjusted styling for placeholders and icons.
Post List Stats Tests
tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php, tests/js/content-helper/post-list-stats.test.tsx
Updated test fixtures and assertions to match new compact formatting for page_views, visitors, and avg_time (numeric strings without unit labels); changed placeholder expectations from ellipsis to em dash; adjusted DOM queries to target screen-reader text elements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

Feature: PCH

Suggested reviewers

  • vaurdan
  • alecgeatches
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: updating the post list stats column to display metrics using icons instead of plain text labels.
Description check ✅ Passed The description includes all required sections: a clear summary of changes, motivation/context, before-and-after comparison, testing approach, and screenshots demonstrating the visual improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update/post-list-stats-icon-display

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.44)

Invalid configuration:
Unexpected item 'parameters › type_coverage'.

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@acicovic acicovic added Changelog: Changed PR to be added under the changelog's "Changed" section Feature: PCI Ticket/PR related to Content Intelligence labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
src/content-helper/post-list-stats/post-list-stats.scss (3)

15-27: Consider converting icon dimensions to rem units.

Per coding guidelines, dimensions >= 3px should use the to_rem function. The 4px gap and 16px icon sizes qualify.

♻️ Proposed fix
 .parsely-post-page-views,
 .parsely-post-visitors,
 .parsely-post-avg-time {
   display: flex;
   align-items: center;
-  gap: 4px;
+  gap: to_rem(4px);

   .dashicons {
-    font-size: 16px;
-    width: 16px;
-    height: 16px;
+    font-size: to_rem(16px);
+    width: to_rem(16px);
+    height: to_rem(16px);
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content-helper/post-list-stats/post-list-stats.scss` around lines 15 -
27, Replace the pixel values in the post-list-stats styles with rems using the
to_rem helper: update the gap: 4px on the .parsely-post-page-views,
.parsely-post-visitors, .parsely-post-avg-time rule to use to_rem(4px), and
change .dashicons font-size: 16px, width: 16px, height: 16px to to_rem(16px) so
all dimensions >=3px follow the coding guideline; keep selectors
(.parsely-post-page-views, .parsely-post-visitors, .parsely-post-avg-time and
.dashicons) unchanged.

10-13: Consider using a color variable.

Per coding guidelines, colors should use variables defined in src/content-helper/common/css/variables.scss instead of hardcoding values. Check if there's an existing variable for this gray tone (#959da5), or consider adding one for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content-helper/post-list-stats/post-list-stats.scss` around lines 10 -
13, The .parsely-post-stats-placeholder rule is using a hardcoded color `#959da5`;
update it to use a Sass color variable from
src/content-helper/common/css/variables.scss (or add a new variable there if
none exists) and replace the literal with that variable; ensure you import the
variables file at the top of post-list-stats.scss if it isn’t already imported
and choose a clear variable name (or reuse an existing one) so the rule uses the
variable instead of the hex value.

3-6: Consider converting dimensions to rem units.

Per coding guidelines, dimensions greater than or equal to 3px should be converted to rem units using the to_rem function. The 8px gap value qualifies.

♻️ Proposed fix
 .parsely-post-stats {
   cursor: default;
   display: flex;
   flex-wrap: wrap;
-  gap: 2px 8px;
+  gap: 2px to_rem(8px);
   min-height: 54px;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content-helper/post-list-stats/post-list-stats.scss` around lines 3 - 6,
The gap declaration in post-list-stats.scss uses a pixel value that violates the
guideline; update the gap: 2px 8px rule to convert the 8px dimension to rem via
the to_rem helper (i.e., keep the 2px as-is and replace the 8px with a call to
to_rem for 8px) so the rule reads gap: 2px <to_rem(8)> using the to_rem function
referenced by the codebase and ensure the change is made in the selector where
gap is defined in post-list-stats.scss.
src/content-helper/post-list-stats/post-list-stats.ts (1)

103-117: Missing @since tag in JSDoc.

Per coding guidelines, every JSDoc comment should include a @since tag indicating the next version of the plugin to include this code.

📝 Proposed fix
 /**
  * Gets HTML for a single stat metric span with an icon and screen-reader label.
  *
+ * `@since` 3.x.x
+ *
  * `@param` {string} className CSS class for the outer span.
  * `@param` {string} dashicon  Dashicon class name (without `dashicons` prefix).
  * `@param` {string} srText    Full screen reader text (including the value).
  * `@param` {string} value     The metric value to display visually.
  */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/content-helper/post-list-stats/post-list-stats.ts` around lines 103 -
117, The JSDoc for the getStatSpan function is missing a `@since` tag; update the
comment block above function getStatSpan to include a `@since` annotation with the
next plugin release version (e.g. `@since` 1.0.0 or your next release
placeholder), keeping the JSDoc style consistent with other files so the tag
appears alongside the existing param descriptions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/content-helper/post-list-stats/post-list-stats.scss`:
- Around line 15-27: Replace the pixel values in the post-list-stats styles with
rems using the to_rem helper: update the gap: 4px on the
.parsely-post-page-views, .parsely-post-visitors, .parsely-post-avg-time rule to
use to_rem(4px), and change .dashicons font-size: 16px, width: 16px, height:
16px to to_rem(16px) so all dimensions >=3px follow the coding guideline; keep
selectors (.parsely-post-page-views, .parsely-post-visitors,
.parsely-post-avg-time and .dashicons) unchanged.
- Around line 10-13: The .parsely-post-stats-placeholder rule is using a
hardcoded color `#959da5`; update it to use a Sass color variable from
src/content-helper/common/css/variables.scss (or add a new variable there if
none exists) and replace the literal with that variable; ensure you import the
variables file at the top of post-list-stats.scss if it isn’t already imported
and choose a clear variable name (or reuse an existing one) so the rule uses the
variable instead of the hex value.
- Around line 3-6: The gap declaration in post-list-stats.scss uses a pixel
value that violates the guideline; update the gap: 2px 8px rule to convert the
8px dimension to rem via the to_rem helper (i.e., keep the 2px as-is and replace
the 8px with a call to to_rem for 8px) so the rule reads gap: 2px <to_rem(8)>
using the to_rem function referenced by the codebase and ensure the change is
made in the selector where gap is defined in post-list-stats.scss.

In `@src/content-helper/post-list-stats/post-list-stats.ts`:
- Around line 103-117: The JSDoc for the getStatSpan function is missing a
`@since` tag; update the comment block above function getStatSpan to include a
`@since` annotation with the next plugin release version (e.g. `@since` 1.0.0 or
your next release placeholder), keeping the JSDoc style consistent with other
files so the tag appears alongside the existing param descriptions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aac0eb24-eee6-4aa1-bf99-02236f64aee2

📥 Commits

Reviewing files that changed from the base of the PR and between dbf06dd and d64d833.

⛔ Files ignored due to path filters (4)
  • build/content-helper/post-list-stats-rtl.css is excluded by !build/**
  • build/content-helper/post-list-stats.asset.php is excluded by !build/**
  • build/content-helper/post-list-stats.css is excluded by !build/**
  • build/content-helper/post-list-stats.js is excluded by !build/**
📒 Files selected for processing (7)
  • src/Utils/class-utils.php
  • src/content-helper/post-list-stats/class-post-list-stats.php
  • src/content-helper/post-list-stats/post-list-stats.scss
  • src/content-helper/post-list-stats/post-list-stats.ts
  • tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php
  • tests/Unit/Utils/UtilsTest.php
  • tests/js/content-helper/post-list-stats.test.tsx

@acicovic acicovic added this to the 3.23.0 milestone Apr 6, 2026
@acicovic acicovic merged commit a4bc623 into develop Apr 6, 2026
37 of 38 checks passed
@acicovic acicovic deleted the update/post-list-stats-icon-display branch April 6, 2026 06:58
github-actions bot added a commit that referenced this pull request Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Changed PR to be added under the changelog's "Changed" section Feature: PCI Ticket/PR related to Content Intelligence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant