@tellescope/chat 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/chat",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -33,13 +33,13 @@
33
33
  "@fontsource/roboto": "^4.5.1",
34
34
  "@mui/icons-material": "^5.0.1",
35
35
  "@mui/material": "^5.0.2",
36
- "@tellescope/constants": "^0.0.34",
37
- "@tellescope/react-components": "^0.0.34",
38
- "@tellescope/sdk": "^0.0.34",
39
- "@tellescope/types-client": "^0.0.34",
40
- "@tellescope/types-models": "^0.0.34",
41
- "@tellescope/types-utilities": "^0.0.34",
42
- "@tellescope/utilities": "^0.0.34",
36
+ "@tellescope/constants": "^0.0.35",
37
+ "@tellescope/react-components": "^0.0.35",
38
+ "@tellescope/sdk": "^0.0.35",
39
+ "@tellescope/types-client": "^0.0.35",
40
+ "@tellescope/types-models": "^0.0.35",
41
+ "@tellescope/types-utilities": "^0.0.35",
42
+ "@tellescope/utilities": "^0.0.35",
43
43
  "@typescript-eslint/eslint-plugin": "^4.33.0",
44
44
  "@typescript-eslint/parser": "^4.33.0",
45
45
  "eslint": "^7.32.0",
@@ -50,7 +50,7 @@
50
50
  "react": "^17.0.2",
51
51
  "react-dom": "^17.0.2"
52
52
  },
53
- "gitHead": "67704e64744cd701cf02f92b64c6fb9f8d210b2d",
53
+ "gitHead": "1f046842cae8e5d2344312f2d49d905d4bcca786",
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
package/src/chat.tsx CHANGED
@@ -2,6 +2,7 @@ import React, { useCallback, useState, CSSProperties } from "react"
2
2
 
3
3
  import {
4
4
  DisplayPicture,
5
+ IN_REACT_WEB,
5
6
  } from "@tellescope/react-components"
6
7
  import {
7
8
  List,
@@ -75,47 +76,48 @@ export {
75
76
  user_display_name, // for convenience
76
77
  }
77
78
 
78
- const defaultMessagesStyle: CSSProperties = {
79
- borderRadius: 5,
80
- }
79
+ const MESSAGE_BORDER_RADIUS = 25
81
80
 
82
81
  const defaultSentContainerStyle: CSSProperties = {
83
- justifyContent: 'flex-end',
84
82
  margin: 5,
85
- marginLeft: 'auto',
86
83
  }
87
84
  const defaultReceivedContainerStyle: CSSProperties = {
88
- justifyContent: 'flex-start',
89
85
  margin: 5,
90
- marginRight: 'auto',
91
86
  }
92
87
 
93
- const baseMessageStyle = {
94
- borderRadius: 25,
88
+ const baseMessageStyle: CSSProperties = {
89
+ borderRadius: MESSAGE_BORDER_RADIUS,
90
+ maxWidth: '80%',
95
91
  paddingRight: 10,
96
92
  paddingLeft: 10,
97
- margin: 5,
98
- maxWidth: '80%',
93
+ paddingTop: 6,
94
+ paddingBottom: 6,
99
95
  }
100
96
  const defaultSentStyle: CSSProperties = {
101
97
  ...baseMessageStyle,
98
+ marginLeft: 'auto',
99
+ marginRight: 5,
102
100
  backgroundColor: PRIMARY_HEX,
103
101
  }
104
102
  const defaultReceivedStyle: CSSProperties = {
105
103
  ...baseMessageStyle,
104
+ marginRight: 'auto',
105
+ marginLeft: 5,
106
106
  backgroundColor: "#444444",
107
107
  }
108
+
108
109
  const baseTextStyle = {
109
110
  color: "#ffffff",
110
- padding: 4,
111
111
  }
112
- const defaultTextSentStyle: CSSProperties = {
112
+ const defaultSentTextStyle = {
113
113
  ...baseTextStyle,
114
- textAlign: 'right',
114
+ marginRight: 5,
115
+ marginLeft: 5,
115
116
  }
116
- const defaultTextReceivedStyle: CSSProperties = {
117
+ const defaultReceivedTextStyle = {
117
118
  ...baseTextStyle,
118
- textAlign: 'left',
119
+ marginRight: 5,
120
+ marginLeft: 5,
119
121
  }
120
122
 
121
123
  export interface MessagesHeaderProps {
@@ -150,10 +152,10 @@ export const Message = ({
150
152
  iconSize=30,
151
153
  sentMessageContainerStyle=defaultSentContainerStyle,
152
154
  receivedMessageContainerStyle=defaultReceivedContainerStyle,
153
- receivedMessageStyle=defaultReceivedStyle,
154
- receivedMessageTextStyle=defaultTextReceivedStyle,
155
155
  sentMessageStyle=defaultSentStyle,
156
- sentMessageTextStyle=defaultTextSentStyle,
156
+ receivedMessageStyle=defaultReceivedStyle,
157
+ sentMessageTextStyle=defaultSentTextStyle,
158
+ receivedMessageTextStyle=defaultReceivedTextStyle,
157
159
  }: MessageProps) => {
158
160
  const session = useResolvedSession()
159
161
  const chatUserId = session.userInfo.id
@@ -164,18 +166,30 @@ export const Message = ({
164
166
  const displayPicture = (
165
167
  <DisplayPicture
166
168
  user={displayInfoLookup[message.senderId ?? ''] ?? { id: message.senderId, avatar: '' }}
167
- size={iconSize}
169
+ size={iconSize} style={{ position: 'relative' }}
168
170
  />
169
171
  )
170
172
 
173
+ const textBGStyle = message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle
174
+ const textStyle = message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle
175
+
176
+ const inBrowser = typeof window !== undefined
177
+
171
178
  return (
172
- <Flex alignItems="center" style={message.senderId === chatUserId ? sentMessageContainerStyle : receivedMessageContainerStyle}>
179
+ <Flex style={{ margin: 5 }}>
173
180
  {message.senderId !== chatUserId && displayPicture}
174
- <Flex style={message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle}>
175
- <Typography style={message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle}>
181
+ {IN_REACT_WEB ? (
182
+ <Typography component="div" style={{ ...textStyle, ...textBGStyle }}>
176
183
  {message.message}
177
- </Typography>
178
- </Flex>
184
+ </Typography>
185
+ )
186
+ : (
187
+ <Flex style={{ ...textBGStyle }}>
188
+ <Typography component="div" style={{ ...textStyle }}>
189
+ {message.message}
190
+ </Typography>
191
+ </Flex>
192
+ )}
179
193
  {message.senderId === chatUserId && displayPicture}
180
194
  </Flex>
181
195
  )
@@ -194,7 +208,7 @@ export const Messages = ({
194
208
  chatUserId,
195
209
  Header=MessagesHeader,
196
210
  headerProps,
197
- style=defaultMessagesStyle,
211
+ style,
198
212
  ...messageStyles
199
213
  }: Messages_T & Styled) => (
200
214
  <LoadingLinear data={messages} render={messages => (