generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Chat bubble style api #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import Box from "@cloudscape-design/components/box"; | ||
|
|
||
| import { ChatBubble } from "../../lib/components"; | ||
| import { Page } from "../app/templates"; | ||
| import { TestBed } from "../app/test-bed"; | ||
| import { Actions, ChatBubbleAvatarGenAI, ChatBubbleAvatarUser, ChatContainer } from "./util-components"; | ||
|
|
||
| export default function ChatBubblePage() { | ||
| return ( | ||
| <Page title="Chat bubble"> | ||
| <TestBed> | ||
| <ChatContainer> | ||
| {/* Background Color with Dark Mode */} | ||
| <ChatBubble | ||
| style={{ bubble: { background: "light-dark(#f0f8ff, #1a1a2e)", color: "light-dark(#333, #eee)" } }} | ||
| type="incoming" | ||
| avatar={<ChatBubbleAvatarGenAI />} | ||
| ariaLabel="Background test" | ||
| > | ||
| Light blue/dark purple background with adaptive text color | ||
| </ChatBubble> | ||
|
|
||
| {/* Border Styles with Dark Mode */} | ||
| <ChatBubble | ||
| style={{ | ||
| bubble: { borderColor: "light-dark(#e74c3c, #ff6b6b)", borderWidth: "2px", borderRadius: "20px" }, | ||
| }} | ||
| type="outgoing" | ||
| avatar={<ChatBubbleAvatarUser />} | ||
| ariaLabel="Border test" | ||
| > | ||
| Adaptive red border with rounded corners | ||
| </ChatBubble> | ||
|
|
||
| {/* Typography with Dark Mode */} | ||
| <ChatBubble | ||
| style={{ bubble: { fontSize: "18px", fontWeight: "bold", color: "light-dark(#8e44ad, #bb86fc)" } }} | ||
| type="incoming" | ||
| avatar={<ChatBubbleAvatarGenAI />} | ||
| ariaLabel="Typography test" | ||
| > | ||
| Large bold adaptive purple text | ||
| </ChatBubble> | ||
|
|
||
| {/* Shadow Effect with Dark Mode */} | ||
| <ChatBubble | ||
| style={{ | ||
| bubble: { boxShadow: "10px 5px 5px red" }, | ||
| }} | ||
| type="outgoing" | ||
| avatar={<ChatBubbleAvatarUser />} | ||
| ariaLabel="Shadow test" | ||
| > | ||
| Adaptive shadow for elevation | ||
| </ChatBubble> | ||
|
|
||
| {/* Spacing */} | ||
| <ChatBubble | ||
| style={{ root: { columnGap: "32px" }, bubble: { paddingBlock: "20px", paddingInline: "24px" } }} | ||
| type="incoming" | ||
| avatar={<ChatBubbleAvatarGenAI />} | ||
| ariaLabel="Spacing test" | ||
| > | ||
| Wide avatar spacing with generous padding | ||
| </ChatBubble> | ||
|
|
||
| {/* Loading State with Dark Mode */} | ||
| <ChatBubble | ||
| style={{ | ||
| bubble: { | ||
| background: "light-dark(#fff3cd, #3d3d00)", | ||
| borderColor: "light-dark(#ffc107, #ffeb3b)", | ||
| borderWidth: "1px", | ||
| }, | ||
| }} | ||
| avatar={<ChatBubbleAvatarGenAI loading={true} />} | ||
| type="incoming" | ||
| showLoadingBar={true} | ||
| ariaLabel="Loading test" | ||
| > | ||
| <Box color="text-body-secondary">Generating response...</Box> | ||
| </ChatBubble> | ||
|
|
||
| {/* With Actions and Dark Mode */} | ||
| <ChatBubble | ||
| style={{ bubble: { background: "light-dark(#e8f5e8, #1b2e1b)", borderRadius: "18px", rowGap: "25px" } }} | ||
| avatar={<ChatBubbleAvatarGenAI />} | ||
| type="incoming" | ||
| actions={<Actions />} | ||
| ariaLabel="Actions test" | ||
| > | ||
| Message with action buttons | ||
| </ChatBubble> | ||
|
|
||
| {/* All Properties Combined with Dark Mode */} | ||
amanabiy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <ChatBubble | ||
| style={{ | ||
| root: { | ||
| columnGap: "25px", | ||
| }, | ||
| bubble: { | ||
| background: "light-dark(#ffffff, #2d2d2d)", | ||
| color: "light-dark(#1b5e20, #81c784)", | ||
| borderColor: "light-dark(#4caf50, #66bb6a)", | ||
| borderWidth: "2px", | ||
| borderRadius: "24px", | ||
| boxShadow: "0 4px 12px rgb(29, 130, 118)", | ||
| fontSize: "16px", | ||
| fontWeight: "bold", | ||
| paddingBlock: "20px", | ||
| paddingInline: "30px", | ||
| rowGap: "20px", | ||
| }, | ||
| }} | ||
| type="outgoing" | ||
| avatar={<ChatBubbleAvatarUser />} | ||
| actions={<Actions />} | ||
| ariaLabel="All properties test" | ||
| showLoadingBar={true} | ||
| > | ||
| All style properties combined | ||
| </ChatBubble> | ||
| </ChatContainer> | ||
| </TestBed> | ||
| </Page> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/chat-bubble/__tests__/__snapshots__/style.test.ts.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`getBubbleStyle > handles all possible style configurations 1`] = ` | ||
| { | ||
| "background": undefined, | ||
| "borderColor": undefined, | ||
| "borderRadius": undefined, | ||
| "borderStyle": undefined, | ||
| "borderWidth": undefined, | ||
| "boxShadow": undefined, | ||
| "color": undefined, | ||
| "fontSize": undefined, | ||
| "fontWeight": undefined, | ||
| "paddingBlock": undefined, | ||
| "paddingInline": undefined, | ||
| "rowGap": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`getBubbleStyle > handles all possible style configurations 2`] = ` | ||
| { | ||
| "background": undefined, | ||
| "borderColor": undefined, | ||
| "borderRadius": undefined, | ||
| "borderStyle": undefined, | ||
| "borderWidth": undefined, | ||
| "boxShadow": undefined, | ||
| "color": undefined, | ||
| "fontSize": undefined, | ||
| "fontWeight": undefined, | ||
| "paddingBlock": undefined, | ||
| "paddingInline": undefined, | ||
| "rowGap": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`getBubbleStyle > handles all possible style configurations 3`] = ` | ||
| { | ||
| "background": "#f0f0f0", | ||
| "borderColor": "#ccc", | ||
| "borderRadius": "8px", | ||
| "borderStyle": "solid", | ||
| "borderWidth": "2px", | ||
| "boxShadow": "0 4px 8px rgba(0,0,0,0.2)", | ||
| "color": "#333", | ||
| "fontSize": "16px", | ||
| "fontWeight": "500", | ||
| "paddingBlock": "20px", | ||
| "paddingInline": "24px", | ||
| "rowGap": "12px", | ||
| } | ||
| `; | ||
|
|
||
| exports[`getChatBubbleRootStyle > handles all possible style configurations 1`] = ` | ||
| { | ||
| "columnGap": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`getChatBubbleRootStyle > handles all possible style configurations 2`] = ` | ||
| { | ||
| "columnGap": undefined, | ||
| } | ||
| `; | ||
|
|
||
| exports[`getChatBubbleRootStyle > handles all possible style configurations 3`] = ` | ||
| { | ||
| "columnGap": "10px", | ||
| } | ||
| `; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[non-blocking]: I'd suggest to implement it using the same abstraction as in the
componentsrepo: https://github.com/cloudscape-design/components/blob/main/pages/alert/permutations.page.tsx#L10 as it's more scalable and easier to modify / test new propertiesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we don't have PermutationsView util in this package. We can make it reusable and use it here as well in the future. For this PR, I will not be adding it so that I can get unblocked.