feat: add stretch property to ChatBubble - #170
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (87.86%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 87.79% 87.86% +0.07%
==========================================
Files 25 25
Lines 344 346 +2
Branches 92 97 +5
==========================================
+ Hits 302 304 +2
Misses 42 42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The stretch prop is implemented as a narrowly-scoped, opt-in layout change with corresponding unit test coverage and documentation updates.
Pull request overview
Adds an opt-in stretch prop to ChatBubble to allow the bubble to expand to available horizontal space, improving alignment for inner right/center-aligned elements (e.g., timestamps, footer links) while preserving existing default sizing behavior.
Changes:
- Added
stretch?: booleantoChatBubbleProps, including generated API documentation updates (snapshot). - Implemented the layout behavior via a conditional
stretchCSS class (flex: 1) on the message area. - Added unit tests covering default/false/true behavior for both
incomingandoutgoingbubbles, plus a new dev page demonstrating the option.
File summaries
| File | Description |
|---|---|
| src/chat-bubble/styles.scss | Adds the .stretch modifier to make the message area flex to full width. |
| src/chat-bubble/internal.tsx | Applies the stretch class conditionally and defaults stretch to false. |
| src/chat-bubble/interfaces.ts | Introduces the new stretch prop with JSDoc explaining behavior/usage. |
| src/chat-bubble/index.tsx | Plumbs stretch through the public component and base-component props. |
| src/chat-bubble/tests/chat-bubble.test.tsx | Adds tests asserting stretch class presence/absence across types and defaults. |
| src/tests/snapshots/documenter.test.ts.snap | Updates generated prop docs snapshot to include stretch. |
| pages/chat-bubble/stretch.page.tsx | Adds a dev page to demonstrate default vs stretched layout. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Adds an optional stretch boolean to ChatBubbleProps. By default the bubble width fits its content, so right- or center-aligned inner elements (timestamps, footer links) land at different horizontal positions in every message. With stretch=true the bubble fills the available container width, making those elements line up across messages. - interfaces.ts: new optional stretch prop (default false), named and documented consistently with Form Field's stretch - internal.tsx / styles.scss: applies flex: 1 to the message area when set; avatar slot and bubble content are unaffected - index.tsx: stretch included in component telemetry props - Backward compatible: default behavior is unchanged, no existing props or DOM structure modified; no test-utils changes needed - Tests: unit tests for default/false/true across both bubble types; documenter snapshot updated - Dev page: pages/chat-bubble/stretch.page.tsx shows the default and stretched variants on one page Ref: AWSUI-61966
cc6701c to
d77f4e3
Compare
Description
Adds an optional
stretchboolean toChatBubbleProps. By default the bubble width fits its content, so right- or center-aligned inner elements (timestamps, footer links) land at different horizontal positions in every message. Withstretch={true}the bubble fills the available container width, making those elements line up across messages.The prop is named and documented consistently with Form Field's
stretch(same semantics: opt-in full width, default preserves current behavior). Implementation is layout-only (flex: 1on the message area); the avatar slotand bubble content are unaffected. Applies to both
incomingandoutgoing.Related links, issue #, if available: AWSUI-61966
How has this been tested?
chat-bubble.test.tsx: no stretch class by default and withstretch={false}; class applied withstretch={true}for both bubble types.pages/chat-bubble/stretch.page.tsxshows the default and stretched variants on one page — reviewers can compare both behaviors in the dev-pages deployment; the page is covered automatically by the visual regression suite.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md. Yes — default behavior unchanged, no existing props or DOM structure modified.CONTRIBUTING.md. Flexbox only.Security
checkSafeUrlfunction. N/A — no URLs.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.