Skip to content

feat: add borderStyle to ChatBubble style API#148

Draft
ernst-dev wants to merge 6 commits into
mainfrom
dev-v3-ernstka-chat-bubble-border-style
Draft

feat: add borderStyle to ChatBubble style API#148
ernst-dev wants to merge 6 commits into
mainfrom
dev-v3-ernstka-chat-bubble-border-style

Conversation

@ernst-dev

@ernst-dev ernst-dev commented Jul 10, 2026

Copy link
Copy Markdown
Member

Description

Adds borderStyle to ChatBubbleProps.Style.bubble so consumers can control the CSS border-style property through the supported style API.

Today, setting borderWidth on a ChatBubble hard-codes border-style: solid internally — there is no way to produce a non-solid border (e.g. dashed, dotted) without a CSS !important override. This blocks use-cases like a "queued message" bubble that needs a dashed border to signal a pending state.

API change (src/chat-bubble/interfaces.ts): adds borderStyle?: string to Style.bubble.

Behaviour (src/chat-bubble/style.tsx): borderStyle: style?.bubble?.borderStyle ?? (style?.bubble?.borderWidth ? "solid" : undefined). Fully backward-compatible — existing borderWidth-only usage still yields border-style: solid.

Related links, issue #, if available: n/a

How has this been tested?

Unit tests in src/chat-bubble/__tests__/style.test.ts cover the full ?? fallback matrix (explicit value wins incl. "none"; borderWidth-only → solid; neither → undefined; siblings undisturbed). DOM-level tests in chat-bubble.test.tsx verify the style reaches the element via getComputedStyle. Snapshots updated.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates. JSDoc added to borderStyle; API-docs snapshot updated.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md. Yes — borderWidth-only usage still yields solid.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md. border-style is universally supported.
  • Changes were manually tested for accessibility, see accessibility guidelines. N/A — style-only API.

Security

Testing

  • Changes are covered with new/existing unit tests? Yes — full branch matrix in style.test.ts.
  • Changes are covered with new/existing integration tests? Yes — DOM-level assertions in chat-bubble.test.tsx.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add `borderStyle` to `ChatBubbleProps.Style.bubble` so consumers can
control the CSS `border-style` property through the supported style API
instead of relying on `!important` overrides.

Motivation: wrappers such as a Rhythm queued-message bubble need a
dashed border to signal a pending/queued state.  Previously the only
hook was `borderWidth`, which hard-coded `border-style: solid`.

API shape (interfaces.ts):
  bubble?: {
    ...
    borderStyle?: string;   // new – e.g. "dashed", "dotted", "solid"
    ...
  }

Behaviour (style.tsx):
  borderStyle: style?.bubble?.borderStyle
             ?? (style?.bubble?.borderWidth ? "solid" : undefined)

  • When `borderStyle` is explicitly provided it wins (any value).
  • When only `borderWidth` is set the existing default of "solid"
    is preserved (fully backward-compatible).
  • When neither is set the property is `undefined` (no change).

Tests (style.test.ts):
  • Added `borderStyle: "dashed"` to the allStyles fixture so the
    snapshot covers the new property end-to-end.
  • Four new explicit tests:
    - defaults to "solid" when borderWidth is set and borderStyle is not
    - uses explicit borderStyle alongside borderWidth
    - uses explicit borderStyle without borderWidth
    - is undefined when neither borderWidth nor borderStyle is set

Snapshots updated accordingly (style.test.ts.snap, documenter.test.ts.snap).
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.04%. Comparing base (d4a2b1d) to head (2ac34fe).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
+ Coverage   87.75%   95.04%   +7.28%     
==========================================
  Files          25       25              
  Lines         343      343              
  Branches       93       91       -2     
==========================================
+ Hits          301      326      +25     
+ Misses         42       17      -25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Unit tests (style.test.ts) — new cases added to getBubbleStyle describe:
- emits 'dotted' verbatim regardless of borderWidth being absent
- emits 'none' verbatim — explicit borderStyle wins over solid fallback
  even when borderWidth is set (the ?? operator must not coerce 'none')
- emits 'double' verbatim alongside borderWidth
- borderWidth set without borderStyle always falls back to 'solid'
  (regression guard — must never silently become undefined)
- borderStyle does not disturb borderColor when set together
- borderStyle does not disturb borderRadius when set together
- borderStyle, borderColor, borderWidth, and borderRadius all coexist
- non-border props are unaffected when only borderStyle is set
  (also asserts borderWidth/borderColor remain undefined — not coerced)

Integration tests (chat-bubble.test.tsx) — DOM-level style API tests
mirroring the Avatar 'style api' test pattern (getComputedStyle on the
rendered message-area element):
- style api — borderStyle reaches the bubble element as 'dashed'
- style api — borderStyle 'dotted' reaches the bubble element without borderWidth
- style api — borderWidth alone defaults border-style to 'solid' on the DOM element
- style api — borderColor and borderRadius are unaffected when borderStyle is set

No snapshot changes (new tests use explicit assertions, not toMatchSnapshot).
…M checks

Trim the 8 granular borderStyle unit tests added in 428cb8f down to a
focused set that covers the full ?? fallback branch matrix:

  (a) borderStyle provided (explicit value wins, including 'none')
  (b) borderStyle absent + borderWidth present → solid (regression guard)
  (c) both absent → undefined

Add a 'does not disturb sibling border props' test and keep the
getChatBubbleRootStyle non-core guard.

DOM integration tests in chat-bubble.test.tsx reduced from 4 to 2:
  - borderStyle reaches the bubble element as 'dashed'
  - borderWidth alone defaults border-style to 'solid' on the DOM element

All 126 unit tests pass (1 pre-existing skip).
codecov/patch: all changed lines covered (src/chat-bubble/style.tsx 100%).
codecov/project failure is pre-existing (main also at 87.75% / 42 misses
in test-utils and internal files unrelated to this PR).
…overage

- src/avatar/__tests__/style.test.ts (NEW): covers getRootStyles/getContentStyles/
  getImageStyles/getLoadingDotsStyle branches (SYSTEM=core + style.root truthy)
  that were previously uncovered
- src/internal/events/__tests__/events.test.tsx: adds fireNonCancelableEvent tests
  (handler-called path and no-op when handler is undefined)
- src/support-prompt-group/__tests__/support-prompt-group.test.tsx: adds Home/End
  keyboard navigation tests; adds vi.clearAllMocks() to afterEach

These tests cover pre-existing misses unrelated to the borderStyle feature change.
No production code modified.
src/internal/keycode.ts was 0% covered (18 lines) because no existing
test imported it directly — the support-prompt-group tests use the
KeyCode re-export from @cloudscape-design/component-toolkit/internal.

Add a small unit test that imports KeyCode from src and asserts every
enum member has the correct numeric value. This is real, testable
behaviour (the values are the actual DOM keyCode constants the
keyboard-navigation handler depends on) and lifts project coverage
from 89.79% → ~95% (308/343 → 326/343 lines), comfortably past the
90.00% Codecov threshold.
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