|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import Box from "@cloudscape-design/components/box"; |
| 4 | + |
| 5 | +import { ChatBubble } from "../../lib/components"; |
| 6 | +import { Page } from "../app/templates"; |
| 7 | +import { TestBed } from "../app/test-bed"; |
| 8 | +import { Actions, ChatBubbleAvatarGenAI, ChatBubbleAvatarUser, ChatContainer } from "./util-components"; |
| 9 | + |
| 10 | +export default function ChatBubblePage() { |
| 11 | + return ( |
| 12 | + <Page title="Chat bubble"> |
| 13 | + <TestBed> |
| 14 | + <ChatContainer> |
| 15 | + {/* Background Color with Dark Mode */} |
| 16 | + <ChatBubble |
| 17 | + style={{ bubble: { background: "light-dark(#f0f8ff, #1a1a2e)", color: "light-dark(#333, #eee)" } }} |
| 18 | + type="incoming" |
| 19 | + avatar={<ChatBubbleAvatarGenAI />} |
| 20 | + ariaLabel="Background test" |
| 21 | + > |
| 22 | + Light blue/dark purple background with adaptive text color |
| 23 | + </ChatBubble> |
| 24 | + |
| 25 | + {/* Border Styles with Dark Mode */} |
| 26 | + <ChatBubble |
| 27 | + style={{ |
| 28 | + bubble: { borderColor: "light-dark(#e74c3c, #ff6b6b)", borderWidth: "2px", borderRadius: "20px" }, |
| 29 | + }} |
| 30 | + type="outgoing" |
| 31 | + avatar={<ChatBubbleAvatarUser />} |
| 32 | + ariaLabel="Border test" |
| 33 | + > |
| 34 | + Adaptive red border with rounded corners |
| 35 | + </ChatBubble> |
| 36 | + |
| 37 | + {/* Typography with Dark Mode */} |
| 38 | + <ChatBubble |
| 39 | + style={{ bubble: { fontSize: "18px", fontWeight: "bold", color: "light-dark(#8e44ad, #bb86fc)" } }} |
| 40 | + type="incoming" |
| 41 | + avatar={<ChatBubbleAvatarGenAI />} |
| 42 | + ariaLabel="Typography test" |
| 43 | + > |
| 44 | + Large bold adaptive purple text |
| 45 | + </ChatBubble> |
| 46 | + |
| 47 | + {/* Shadow Effect with Dark Mode */} |
| 48 | + <ChatBubble |
| 49 | + style={{ |
| 50 | + bubble: { boxShadow: "10px 5px 5px red" }, |
| 51 | + }} |
| 52 | + type="outgoing" |
| 53 | + avatar={<ChatBubbleAvatarUser />} |
| 54 | + ariaLabel="Shadow test" |
| 55 | + > |
| 56 | + Adaptive shadow for elevation |
| 57 | + </ChatBubble> |
| 58 | + |
| 59 | + {/* Spacing */} |
| 60 | + <ChatBubble |
| 61 | + style={{ root: { columnGap: "32px" }, bubble: { paddingBlock: "20px", paddingInline: "24px" } }} |
| 62 | + type="incoming" |
| 63 | + avatar={<ChatBubbleAvatarGenAI />} |
| 64 | + ariaLabel="Spacing test" |
| 65 | + > |
| 66 | + Wide avatar spacing with generous padding |
| 67 | + </ChatBubble> |
| 68 | + |
| 69 | + {/* Loading State with Dark Mode */} |
| 70 | + <ChatBubble |
| 71 | + style={{ |
| 72 | + bubble: { |
| 73 | + background: "light-dark(#fff3cd, #3d3d00)", |
| 74 | + borderColor: "light-dark(#ffc107, #ffeb3b)", |
| 75 | + borderWidth: "1px", |
| 76 | + }, |
| 77 | + }} |
| 78 | + avatar={<ChatBubbleAvatarGenAI loading={true} />} |
| 79 | + type="incoming" |
| 80 | + showLoadingBar={true} |
| 81 | + ariaLabel="Loading test" |
| 82 | + > |
| 83 | + <Box color="text-body-secondary">Generating response...</Box> |
| 84 | + </ChatBubble> |
| 85 | + |
| 86 | + {/* With Actions and Dark Mode */} |
| 87 | + <ChatBubble |
| 88 | + style={{ bubble: { background: "light-dark(#e8f5e8, #1b2e1b)", borderRadius: "18px", rowGap: "25px" } }} |
| 89 | + avatar={<ChatBubbleAvatarGenAI />} |
| 90 | + type="incoming" |
| 91 | + actions={<Actions />} |
| 92 | + ariaLabel="Actions test" |
| 93 | + > |
| 94 | + Message with action buttons |
| 95 | + </ChatBubble> |
| 96 | + |
| 97 | + {/* All Properties Combined with Dark Mode */} |
| 98 | + <ChatBubble |
| 99 | + style={{ |
| 100 | + root: { |
| 101 | + columnGap: "25px", |
| 102 | + }, |
| 103 | + bubble: { |
| 104 | + background: "light-dark(#ffffff, #2d2d2d)", |
| 105 | + color: "light-dark(#1b5e20, #81c784)", |
| 106 | + borderColor: "light-dark(#4caf50, #66bb6a)", |
| 107 | + borderWidth: "2px", |
| 108 | + borderRadius: "24px", |
| 109 | + boxShadow: "0 4px 12px rgb(29, 130, 118)", |
| 110 | + fontSize: "16px", |
| 111 | + fontWeight: "bold", |
| 112 | + paddingBlock: "20px", |
| 113 | + paddingInline: "30px", |
| 114 | + rowGap: "20px", |
| 115 | + }, |
| 116 | + }} |
| 117 | + type="outgoing" |
| 118 | + avatar={<ChatBubbleAvatarUser />} |
| 119 | + actions={<Actions />} |
| 120 | + ariaLabel="All properties test" |
| 121 | + showLoadingBar={true} |
| 122 | + > |
| 123 | + All style properties combined |
| 124 | + </ChatBubble> |
| 125 | + </ChatContainer> |
| 126 | + </TestBed> |
| 127 | + </Page> |
| 128 | + ); |
| 129 | +} |
0 commit comments