Skip to content

syslog: equal-width severity-legend chips via CSS grid + longest-label seed - #390

Merged
TheWitness merged 4 commits into
developfrom
feature/legend-equal-chips-grid
Oct 7, 2026
Merged

TheWitness merged 4 commits into
developfrom
feature/legend-equal-chips-grid

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

Brings syslog's System Logs and Alert Logs severity legends in line with the thold / monitor / servcheck / mactrack chip legends — equal-width chips sized to the longest label, laid out as a CSS grid.

Previously .syslogLegend used display: flex with .syslogLegendItem { flex: 1 1 0 } and no chip-min seeding at all, so the chips were neither sized to the longest label nor equal width across wrapped rows (each flex line distributes free space independently, stretching a partial final row).

Change

  • includes/functions.php — syslog_syslog_legend() and syslog_log_legend() now build their chip set as an array, compute the longest label, and emit <div class="syslogLegend" style="--syslog-chip-min: calc(<N>ch + 1.5rem)">. Same chips, same classes, same order.
  • css/*.css (9 theme stylesheets) — .syslogLegend → display: grid; grid-template-columns: repeat(auto-fit, minmax(var(--syslog-chip-min, 8ch), 1fr)), and drop flex: 1 1 0 from .syslogLegendItem. Grid tracks are shared across all rows, so every chip is the same width; auto-fit still lets the chips fill the width on a single row.
  • tests/Unit/SyslogLegendTest.php — assert the exact calc(<N>ch + 1.5rem) value for both legends.
  • CHANGELOG.md — dev note.

Matches the exact formula used by the other four plugin legends (repeat(auto-fit, minmax(var(--<plugin>-chip-min, 8ch), 1fr)) + calc(<longest mb_strlen>ch + 1.5rem)).

Testing

  • php -l clean on includes/functions.php and the test.

…l seed

Brings the System Logs and Alert Logs severity legends in line with the thold/monitor/servcheck/mactrack legends. syslog_syslog_legend() and syslog_log_legend() now emit --syslog-chip-min (calc(longest-label ch + 1.5rem)), and .syslogLegend is a grid (repeat(auto-fit, minmax(var(--syslog-chip-min), 1fr))) across all nine theme stylesheets instead of flex: 1 1 0 (which only equalised chips within a wrapped line). Tests assert the exact chip-min value.
Copilot AI balanced review requested due to automatic review settings October 7, 2026 14:50

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.

🟡 Changes recommended

Translated labels remain unescaped, and translated-label sizing lacks direct test coverage.

3 open findings
What changed in this PR

Updates Syslog severity legends to use equal-width CSS grid chips sized from the longest translated label.

Changes:

  • Computes and emits a minimum chip width for both legends.
  • Applies grid layout across all theme stylesheets.
  • Adds rendering assertions and a changelog entry.
File Description
includes/​functions.php Calculates chip width and renders legend items.
tests/​Unit/​SyslogLegendTest.php Tests generated legend sizing markup.
css/​classic.css Adds grid-based legend layout.
css/​dark.css Adds grid-based legend layout.
css/​deepness.css Adds grid-based legend layout.
css/​legend.css Updates the fallback legend layout.
css/​midwinter.css Adds grid-based legend layout.
css/​modern.css Adds grid-based legend layout.
css/​paper-plane.css Adds grid-based legend layout.
css/​paw.css Adds grid-based legend layout.
css/​sunrise.css Adds grid-based legend layout.
CHANGELOG.md Documents the legend update.

🧠 Review effort: Balanced


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

Comment thread includes/functions.php Outdated
Comment thread includes/functions.php Outdated
Comment thread tests/Unit/SyslogLegendTest.php
…slated labels

Review follow-up (#390): use [] short-array syntax for the new legend item collections to match the rest of the file; add a test that overrides __() so a short English label ('Error') has the longest translation, proving --syslog-chip-min is sized from the emitted (translated) output rather than the English source.
Defence-in-depth: wrap the legend chip display text in html_escape() so markup or HTML entities in a translated label cannot alter the legend DOM. Applied consistently across the thold/monitor/servcheck/mactrack/syslog fleet legends. The chip-min sizing still measures the unescaped label length, so layout is unchanged. Resolves the review note on #390.
xmacan
xmacan previously approved these changes Oct 7, 2026
Resolve legend conflicts: keep the CSS-grid equal-width approach (drop develop's leftover flex:1 1 0 / min-width on .syslogLegendItem), keep escaped chip labels in functions.php, keep the PR's exact calc() legend tests, and retain develop's new changelog entries.
@TheWitness
TheWitness merged commit 8ec21ed into develop Oct 7, 2026
6 checks passed
@TheWitness
TheWitness deleted the feature/legend-equal-chips-grid 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