Skip to content

syslog: keep severity-legend chips equal width using the longest label - #389

Merged
TheWitness merged 1 commit into
developfrom
feature/legend-equal-chips
Oct 7, 2026
Merged

TheWitness merged 1 commit into
developfrom
feature/legend-equal-chips

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Description

Makes the System Logs and Alert Logs severity-legend chips stay equal width as the legend wraps responsively — the same refinement already applied to the Monitor and Thold plugins.

With flex: 1 1 0 and no shared minimum, each chip's floor was effectively its own text width, so the chips grew to different widths (and could clip their labels when space was tight). CSS can't measure the widest sibling, so syslog_syslog_legend() and syslog_log_legend() now build their severities as an ordered array, compute the longest label, and emit it as a --syslog-chip-min CSS variable (calc(<longest>ch + 1.5rem)). Every stylesheet — each per-theme css/<theme>.css and the css/legend.css fallback — uses that as a shared min-width (falling back to max-content).

Because every chip shares the same minimum, the equal flex-grow resolves them to equal widths, and they wrap as a tidy grid. white-space: nowrap is retained, so labels never clip.

Related Issue

Follow-up to the severity-legend chip restyle already on develop.

Motivation and Context

Keeps each severity legend reading as a clean, uniform key rather than a row of mismatched chip widths, especially once it wraps.

How Has This Been Tested?

  • php -l clean on includes/functions.php and tests/Unit/SyslogLegendTest.php.
  • All nine stylesheets (eight themes + legend.css) remain brace-balanced.
  • SyslogLegendTest assertions updated to match the new container markup; both renderers stay covered by the existing tests, satisfying the patch-coverage gate. The set of translatable strings is unchanged (same __() calls, just reorganised into an array), so no cacti.pot update is required.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.

The System Logs and Alert Logs severity legends used flex:1 1 0 with no shared minimum, so chips grew to unequal widths (and could clip their labels when tight). CSS can't measure the widest sibling, so syslog_syslog_legend() and syslog_log_legend() now build their severities as an ordered array, compute the longest label, and emit it as a --syslog-chip-min CSS variable (calc(<longest>ch + 1.5rem)); every stylesheet (per-theme + the legend.css fallback) uses it as a shared min-width (falling back to max-content). All chips share one minimum, so they stay equal width as the legend wraps. Updated SyslogLegendTest assertions to match the new container markup; the translatable string set is unchanged.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Flex wrapping still produces unequal final-row widths, and character counts do not reliably represent rendered label widths.

Review effort: Balanced
Findings: 11 Medium severity

Open (11)
What changed in this PR

Updates severity legends to derive a shared chip minimum width from the longest label.

Changes:

  • Computes and emits --syslog-chip-min.
  • Applies the minimum across all theme stylesheets.
  • Updates tests and changelog documentation.
File Description
includes/​functions.php Computes shared legend sizing.
tests/​Unit/​SyslogLegendTest.php Updates legend markup assertions.
css/​classic.css Applies shared minimum width.
css/​dark.css Applies shared minimum width.
css/​deepness.css Applies shared minimum width.
css/​legend.css Updates fallback legend styling.
css/​midwinter.css Applies shared minimum width.
css/​modern.css Applies shared minimum width.
css/​paper-plane.css Applies shared minimum width.
css/​paw.css Applies shared minimum width.
css/​sunrise.css Applies shared minimum width.
CHANGELOG.md Documents the legend refinement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread css/classic.css
Comment thread css/dark.css
Comment thread css/deepness.css
Comment thread css/legend.css
Comment thread css/midwinter.css
Comment thread css/paper-plane.css
Comment thread css/paw.css
Comment thread css/sunrise.css
Comment thread includes/functions.php
Comment thread tests/Unit/SyslogLegendTest.php
@TheWitness
TheWitness merged commit 66a31ce into develop Oct 7, 2026
7 checks passed
@TheWitness
TheWitness deleted the feature/legend-equal-chips branch October 8, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants