Skip to content

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

Open
ludvigovrevik wants to merge 2 commits into
developfrom
feat/alert-subsystem-counter
Open

feat(alert-subsystem-counter): add alert subsystem counter component#1045
ludvigovrevik wants to merge 2 commits 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 an alert subsystem counter component displaying a label, optional icon, alert badges, or a configurable empty state.
    • Supports horizontal and vertical orientations, abbreviated labels, alert-free states, and iconless configurations.
    • Added Storybook examples covering common display variations.
  • Style
    • Added spacing, alignment, borders, typography, truncation, and inactive/active state styling for consistent presentation.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03cbde86-2a4f-40c3-b7ef-38d3352bc324

📥 Commits

Reviewing files that changed from the base of the PR and between f2c74f5 and 842e12c.

⛔ 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
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.ts
  • packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts

📝 Walkthrough

Walkthrough

This PR adds the obc-alert-subsystem-counter Lit component. It defines public properties, icon slot detection, conditional badge or empty-state rendering, CSS layout styles, and Storybook stories for supported configurations.

Changes

Alert Subsystem Counter Component

Layer / File(s) Summary
Component contract and rendering logic
packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.ts
Defines the orientation enum, public properties, icon slot detection, conditional rendering, stylesheet registration, and tag typing.
Component styling
packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.css
Adds host, frame, orientation, icon, label, trailing-container, active-state, and empty-state styles.
Storybook stories and demonstrations
packages/openbridge-webcomponents/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts
Adds Storybook controls and stories for default, abbreviated, alert-free, vertical, combined vertical/abbreviated, and iconless configurations.

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

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant ObcAlertSubsystemCounter
  participant IconSlot

  Consumer->>ObcAlertSubsystemCounter: assign icon and badge slots
  ObcAlertSubsystemCounter->>IconSlot: receive slotchange event
  IconSlot->>ObcAlertSubsystemCounter: provide assigned icon nodes
  ObcAlertSubsystemCounter->>ObcAlertSubsystemCounter: update icon-presence state
  ObcAlertSubsystemCounter->>Consumer: render label and badges or emptyText
Loading

Suggested labels: Instrument Component

Suggested reviewers: tibnor, jon-daeh, ulrik-jo

🚥 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 new alert subsystem counter component added by the pull request.
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

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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.

2 participants