Skip to content

feat(alert-subsystem-counter): add alert subsystem counter component - #1045

Open
ludvigovrevik wants to merge 1 commit into
developfrom
feat/alert-subsystem-counter
Open

feat(alert-subsystem-counter): add alert subsystem counter component#1045
ludvigovrevik wants to merge 1 commit into
developfrom
feat/alert-subsystem-counter

Conversation

@ludvigovrevik

@ludvigovrevik ludvigovrevik commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds obc-alert-subsystem-counter — a framed summary of a single subsystem's alert counts. It provides a leading icon, a label, and a trailing set of slotted severity count badges, giving an at-a-glance view of outstanding alerts grouped by severity.

Features

  • Orientation: horizontal (single row) or vertical (badges on a line below the label).
  • Alert state: hasAlert toggles between an active presentation (bold label + badges) and an inactive one (muted label + empty text).
  • Freeform label: full title or abbreviation, decided by the caller.
  • Configurable empty text via emptyText (default No alerts).
  • Optional leading icon via the icon slot; the leading box collapses when absent.
  • Count badges are supplied by the consumer as slotted obc-badge elements.

Testing

  • Storybook stories cover 7 variants: Default, Abbreviation, No Alerts, Vertical, Vertical No Alerts, Abbreviation Vertical, Without Icon.
  • Linux visual baselines generated via the project Docker image and verified stable (7/7 passing on a re-run without --update).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new alert subsystem counter component for showing a label, icon, and alert badges or an empty state.
    • Supports horizontal and vertical layouts, with a responsive stacked option for narrow spaces.
    • Added Storybook examples for default, no-alert, vertical, abbreviated, and icon-free variations.
  • Style
    • Introduced polished spacing, borders, typography, and truncation behavior for cleaner display in the component.

Add obc-alert-subsystem-counter: a framed summary of a subsystem's
alert counts with a leading icon, label, and slotted severity count
badges. Supports horizontal/vertical orientation, an alert/empty
state via hasAlert, and configurable empty text.

Includes Storybook stories and Linux visual baselines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a new obc-alert-subsystem-counter Lit web component with an ObcAlertSubsystemCounterOrientation enum, public properties for label/orientation/hasAlert/emptyText, icon slot detection, conditional badge/empty rendering, accompanying CSS styling, and Storybook stories demonstrating various configurations.

Changes

Alert Subsystem Counter Component

Layer / File(s) Summary
Component contract and rendering logic
.../alert-subsystem-counter.ts
Adds ObcAlertSubsystemCounterOrientation enum, ObcAlertSubsystemCounter class with label, orientation, hasAlert, emptyText properties, icon slot-change detection via hasIcon state, conditional rendering of badges/empty text, and tag registration.
Component styling
.../alert-subsystem-counter.css
Adds host, frame, orientation variants, icon/label/trailing alignment, active/inactive label color, and empty-state typography styles.
Storybook stories and demonstrations
.../alert-subsystem-counter.stories.ts
Adds Storybook meta with argTypes and badges template, plus Default, Abbreviation, NoAlerts, Vertical, VerticalNoAlerts, AbbreviationVertical, and WithoutIcon story exports.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant ObcAlertSubsystemCounter
  participant IconSlot

  Consumer->>ObcAlertSubsystemCounter: assign icon/badges slots
  ObcAlertSubsystemCounter->>IconSlot: slotchange event
  IconSlot->>ObcAlertSubsystemCounter: handleIconSlotChange(assignedNodes)
  ObcAlertSubsystemCounter->>ObcAlertSubsystemCounter: update hasIcon state
  ObcAlertSubsystemCounter->>Consumer: render frame with label and badges/emptyText
Loading

Suggested reviewers: ulrik-jo, jon-daeh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the alert subsystem counter component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 feat/alert-subsystem-counter

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts (1)

36-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce duplication across story render functions.

The meta.render, AbbreviationVertical.render, and WithoutIcon.render blocks duplicate nearly identical markup, differing only in wrapper width and icon-slot presence. Extracting a shared template helper would reduce upkeep if the component's slots/attributes change.

♻️ Proposed refactor
+const renderCounter = (args: any, options?: {width?: string; withIcon?: boolean}) =>
+  html`<div style="width:${options?.width ?? '191px'}">
+    <obc-alert-subsystem-counter
+      .label=${args.label}
+      .orientation=${args.orientation}
+      .hasAlert=${args.hasAlert}
+      .emptyText=${args.emptyText}
+    >
+      ${options?.withIcon !== false
+        ? html`<obi-placeholder slot="icon"></obi-placeholder>`
+        : ''}
+      ${badges}
+    </obc-alert-subsystem-counter>
+  </div>`;

Then reuse renderCounter(args), renderCounter(args, {width: 'fit-content'}), and renderCounter(args, {withIcon: false}) in the respective stories.

Also applies to: 79-91, 93-105

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts`
around lines 36 - 47, The story file has repeated `render` markup in
`meta.render`, `AbbreviationVertical.render`, and `WithoutIcon.render`; factor
the shared `obc-alert-subsystem-counter` template into a helper such as
`renderCounter(args, options)` and reuse it across those stories. Keep the
helper responsible for the common label/orientation/hasAlert/emptyText bindings
and let options control wrapper width and whether the `obi-placeholder` icon
slot is included, so the story variants only pass `width` and `withIcon`
differences.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.css`:
- Around line 40-51: The CSS in the alert-subsystem-counter styles is missing
the required blank line after each `@mixin`, triggering stylelint
declaration-empty-line-before violations. Update the affected selectors in
alert-subsystem-counter.css, including .label and the other matching blocks in
the referenced range, so there is an empty line immediately after each `@mixin`
font-body (and any similar mixin usage) before the next declaration.

---

Nitpick comments:
In
`@packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts`:
- Around line 36-47: The story file has repeated `render` markup in
`meta.render`, `AbbreviationVertical.render`, and `WithoutIcon.render`; factor
the shared `obc-alert-subsystem-counter` template into a helper such as
`renderCounter(args, options)` and reuse it across those stories. Keep the
helper responsible for the common label/orientation/hasAlert/emptyText bindings
and let options control wrapper width and whether the `obi-placeholder` icon
slot is included, so the story variants only pass `width` and `withIcon`
differences.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45c9e8a9-7ae8-4c4f-b830-20c3eaf89310

📥 Commits

Reviewing files that changed from the base of the PR and between 1d433c9 and 9abc79c.

⛔ Files ignored due to path filters (7)
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/abbreviation-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/abbreviation-vertical-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/default-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/no-alerts-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/vertical-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/vertical-no-alerts-auto.png is excluded by !**/*.png
  • packages/openbridge-webcomponents/__vis__/linux/__baselines__/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts/without-icon-auto.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.css
  • packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts
  • packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.ts

Comment on lines +40 to +51
.label {
@mixin font-body;
flex: 1 0 0;
min-width: 0;
padding-left: 4px;
color: var(--element-inactive-color);
font-feature-settings: "ss04" 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix Stylelint declaration-empty-line-before violations.

Static analysis flags missing blank lines after @mixin calls at lines 42, 54, and 70.

🎨 Proposed fix
 .label {
   `@mixin` font-body;
+
   flex: 1 0 0;
   min-width: 0;
   padding-left: 4px;
   color: var(--element-inactive-color);
   font-feature-settings: "ss04" 1;
   overflow: hidden;
   white-space: nowrap;
   text-overflow: ellipsis;
 }

 .frame.has-alert .label {
   `@mixin` font-body-active;
+
   color: var(--on-indent-active-color);
 }

 .empty {
   `@mixin` font-label;
+
   color: var(--element-inactive-color);
   white-space: nowrap;
   font-feature-settings: "ss04" 1;
 }

Also applies to: 52-55, 68-73

🧰 Tools
🪛 Stylelint (17.14.0)

[error] 42-42: Expected empty line before declaration (declaration-empty-line-before)

(declaration-empty-line-before)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.css`
around lines 40 - 51, The CSS in the alert-subsystem-counter styles is missing
the required blank line after each `@mixin`, triggering stylelint
declaration-empty-line-before violations. Update the affected selectors in
alert-subsystem-counter.css, including .label and the other matching blocks in
the referenced range, so there is an empty line immediately after each `@mixin`
font-body (and any similar mixin usage) before the next declaration.

Source: Linters/SAST tools

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.

1 participant