Skip to content

Commit 3fc3551

Browse files
authored
1 parent 7b9797b commit 3fc3551

File tree

90 files changed

+2921
-1461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2921
-1461
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@
3434
"styled-components": "^5.3.11"
3535
},
3636
"devDependencies": {
37+
"@linaria/atomic": "^6.2.0",
38+
"@linaria/core": "^6.2.0",
39+
"@linaria/react": "^6.2.1",
3740
"@types/dompurify": "^3.0.5",
3841
"@types/react": "^18.0.37",
3942
"@types/react-dom": "^18.0.11",
4043
"@types/styled-components": "^5.1.26",
4144
"@typescript-eslint/eslint-plugin": "^5.60.1",
4245
"@typescript-eslint/parser": "^5.60.1",
4346
"@vitejs/plugin-react": "^4.2.1",
47+
"@wyw-in-js/babel-preset": "^0.5.3",
48+
"@wyw-in-js/vite": "^0.5.3",
4449
"date-fns": "^3.6.0",
4550
"eslint": "^8.44.0",
4651
"eslint-config-prettier": "^8.8.0",

packages/self-service/scripts/generateIndex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function generateIndexFile(version) {
66
process.exit(1);
77
}
88

9-
const content = `import(\`/${version}/output.js\`).then(() => console.log("AI chatbot module has been successfully loaded"));`;
9+
const content = `import('./${version}/output.js').then(() => console.log("AI chatbot module has been successfully loaded"));`;
1010

1111
fs.writeFileSync('dist/index.js', content);
1212
fs.cpSync('playground', 'dist/playground', { recursive: true });

packages/self-service/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
output: {
1616
manualChunks: undefined,
1717
entryFileNames: `output.js`,
18-
chunkFileNames: `[name].js`,
18+
chunkFileNames: `[hash].js`,
1919
assetFileNames: `[name].[ext]`,
2020
},
2121
},

packages/uikit

Submodule uikit updated 63 files

src/components/BotMessageFeedback.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import { Feedback, FeedbackRating } from '@sendbird/chat/message';
1+
import { BaseMessage, Feedback, FeedbackRating } from '@sendbird/chat/message';
22
import { useReducer } from 'react';
33

44
import FeedbackIconButton from '@uikit/ui/FeedbackIconButton';
5-
import Icon, { IconTypes } from '@uikit/ui/Icon';
65
import MessageFeedbackFailedModal from '@uikit/ui/MessageFeedbackFailedModal';
76
import MessageFeedbackModal from '@uikit/ui/MessageFeedbackModal';
87
import MobileFeedbackMenu from '@uikit/ui/MobileFeedbackMenu';
9-
import { CoreMessageType } from '@uikit/utils';
108

119
import { elementIds } from '../const';
1210
import { useConstantState } from '../context/ConstantContext';
11+
import { Icon } from '../foundation/components/Icon';
1312

1413
type State = Partial<{
1514
errorText: string;
1615
modalVisible: boolean;
1716
menuVisible: boolean;
1817
}>;
1918

20-
function BotMessageFeedback({ message }: { message: CoreMessageType }) {
19+
function BotMessageFeedback({ message }: { message: BaseMessage }) {
2120
const { stringSet } = useConstantState();
2221
const [state, setState] = useReducer((p: State, a: State) => ({ ...p, ...a }), {
2322
errorText: '',
@@ -50,7 +49,7 @@ function BotMessageFeedback({ message }: { message: CoreMessageType }) {
5049
}}
5150
disabled={!!message.myFeedback && message.myFeedback.rating !== FeedbackRating.GOOD}
5251
>
53-
<Icon type={IconTypes.FEEDBACK_LIKE} width="24px" height="24px" />
52+
<Icon type={'feedback-like'} size={24} />
5453
</FeedbackIconButton>
5554
<FeedbackIconButton
5655
aria-label="Dislike the bot answer"
@@ -70,7 +69,7 @@ function BotMessageFeedback({ message }: { message: CoreMessageType }) {
7069
}}
7170
disabled={!!message.myFeedback && message.myFeedback.rating !== FeedbackRating.BAD}
7271
>
73-
<Icon type={IconTypes.FEEDBACK_DISLIKE} width="24px" height="24px" />
72+
<Icon type={'feedback-dislike'} size={24} />
7473
</FeedbackIconButton>
7574
</div>
7675
{
@@ -104,7 +103,7 @@ function BotMessageFeedback({ message }: { message: CoreMessageType }) {
104103
isMobile
105104
rootElementId={elementIds.widgetWindow}
106105
selectedFeedback={message.myFeedback.rating}
107-
message={message}
106+
message={message as any}
108107
onUpdate={async (selectedFeedback, comment) => {
109108
if (message.myFeedback) {
110109
try {

src/components/BotMessageWithBodyInput.tsx

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
import { User } from '@sendbird/chat';
21
import { ReactNode } from 'react';
32
import styled from 'styled-components';
43

5-
import Avatar from '@uikit/ui/Avatar';
6-
import Label, { LabelColors, LabelTypography } from '@uikit/ui/Label';
7-
84
import BotProfileImage from './BotProfileImage';
5+
import { useChatContext } from './chat/context/ChatProvider';
96
import { DefaultSentTime, FullBodyContainer, WideSentTime } from './MessageComponent';
107
import { useConstantState } from '../context/ConstantContext';
8+
import { Label } from '../foundation/components/Label';
119
import { formatCreatedAtToAMPM } from '../utils/messageTimestamp';
1210

1311
const Root = styled.span`
1412
display: flex;
1513
flex-direction: row;
1614
align-items: flex-end;
17-
margin-bottom: 6px;
1815
gap: 8px;
1916
position: relative;
2017
`;
@@ -40,14 +37,11 @@ const EmptyImageContainer = styled.div`
4037
`;
4138

4239
type Props = {
43-
botUser?: User;
4440
createdAt?: number;
4541
messageData?: string;
4642
bodyComponent: ReactNode;
4743
chainTop?: boolean;
4844
chainBottom?: boolean;
49-
messageCount?: number;
50-
zIndex?: number;
5145
messageFeedback?: ReactNode;
5246
wideContainer?: boolean;
5347
};
@@ -59,46 +53,33 @@ const HEIGHTS = {
5953
};
6054

6155
export default function BotMessageWithBodyInput(props: Props) {
56+
const { botUser } = useChatContext();
6257
const { botStudioEditProps, dateLocale } = useConstantState();
6358

64-
const {
65-
botUser,
66-
createdAt,
67-
bodyComponent,
68-
messageCount,
69-
zIndex,
70-
chainTop,
71-
chainBottom,
72-
messageFeedback,
73-
wideContainer = false,
74-
} = props;
59+
const { createdAt, bodyComponent, chainTop, chainBottom, messageFeedback, wideContainer = false } = props;
7560

7661
const profilePaddingBottom = (messageFeedback ? HEIGHTS.FEEDBACK : 0) + (wideContainer ? HEIGHTS.TIMESTAMP : 0);
7762

7863
const nonChainedMessage = chainTop == null && chainBottom == null;
79-
const displayProfileImage = nonChainedMessage || chainBottom;
8064
const displaySender = nonChainedMessage || chainTop;
65+
const displayProfileImage = nonChainedMessage || chainBottom;
8166
const { profileUrl, nickname } = botStudioEditProps?.botInfo ?? {};
8267
const botProfileUrl = profileUrl ?? botUser?.profileUrl;
8368
const botNickname = nickname ?? botUser?.nickname;
8469

8570
return (
86-
<Root style={{ zIndex: messageCount === 1 && zIndex ? zIndex : 0 }}>
71+
<Root>
8772
{displayProfileImage ? (
8873
<div style={{ paddingBottom: profilePaddingBottom }}>
89-
{botProfileUrl != null && botProfileUrl != '' ? (
90-
<Avatar src={botProfileUrl} alt="botProfileImage" height="28px" width="28px" />
91-
) : (
92-
<BotProfileImage width={28} height={28} iconWidth={16} iconHeight={16} />
93-
)}
74+
<BotProfileImage size={28} profileUrl={botProfileUrl} />
9475
</div>
9576
) : (
9677
<EmptyImageContainer />
9778
)}
9879
<FullBodyContainer>
9980
{displaySender && (
10081
<Sender>
101-
<Label type={LabelTypography.CAPTION_2} color={LabelColors.ONBACKGROUND_2}>
82+
<Label type={'caption2'} color={'onbackground2'}>
10283
{botNickname}
10384
</Label>
10485
</Sender>

src/components/BotProfileImage.tsx

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
import styled from 'styled-components';
1+
import { styled } from '@linaria/react';
2+
import { useTheme } from 'styled-components';
23

34
import { getColorBasedOnSaturation } from '../colors';
4-
import Icon from '../icons/bot-profile-image-small.svg';
5+
import BotProfileIcon from '../icons/bot-profile-image-small.svg';
56

6-
interface ImageProps {
7-
width: number;
8-
height: number;
9-
iconWidth: number;
10-
iconHeight: number;
11-
}
12-
const StyledBotImage = styled.span<ImageProps>`
13-
width: ${({ width }) => `${width}px`};
14-
height: ${({ height }) => `${height}px`};
15-
background: ${({ theme }) => theme.accentColor};
7+
const Container = styled.span<{ backgroundColor: string; size: number }>`
8+
width: ${({ size }) => `${size}px`};
9+
height: ${({ size }) => `${size}px`};
10+
background: ${({ backgroundColor }) => backgroundColor};
11+
box-sizing: border-box;
12+
padding: 6px;
1613
border-radius: 50%;
1714
display: flex;
1815
justify-content: center;
1916
align-items: center;
2017
}`;
2118

22-
const ChatBotIcon = styled(Icon)`
19+
const Icon = styled(BotProfileIcon)<{ fill: string }>`
2320
path {
24-
fill: ${({ theme }) => getColorBasedOnSaturation(theme.accentColor)};
21+
fill: ${({ fill }) => fill};
2522
}
2623
`;
27-
const StyledBotIcon = styled(ChatBotIcon).attrs(({ width, height }) => ({
28-
width,
29-
height,
30-
}))``;
3124

32-
function BotProfileImage(props: ImageProps) {
25+
type Props = {
26+
profileUrl?: string;
27+
size: number;
28+
};
29+
30+
function BotProfileImage({ size, profileUrl }: Props) {
31+
const theme = useTheme();
32+
33+
if (profileUrl) {
34+
return <img src={profileUrl} style={{ borderRadius: '50%', width: size, height: size }} alt={'bot profile'} />;
35+
}
36+
3337
return (
34-
<StyledBotImage {...props}>
35-
<StyledBotIcon width={props.iconWidth} height={props.iconHeight} />
36-
</StyledBotImage>
38+
<Container size={size} backgroundColor={theme.accentColor}>
39+
<Icon fill={getColorBasedOnSaturation(theme.accentColor)} />
40+
</Container>
3741
);
3842
}
3943

src/components/CurrentUserMessage.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const Root = styled.div<{ enableEmojiFeedback: boolean }>`
99
display: flex;
1010
justify-content: flex-end;
1111
align-items: end;
12-
margin-bottom: 6px;
1312
gap: 4px;
14-
margin-top: ${({ enableEmojiFeedback }) => (enableEmojiFeedback ? '16px' : '0')};
1513
`;
1614

1715
type Props = {

0 commit comments

Comments
 (0)