Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 218247d

Browse files
Saletanton-pubparfeonpubnub-release-bot
authored
feat(lib): actionsAfterInput option in MessageInput (#120)
* feat(lib): actionsAfterInput option in MessageInput * test: playwright configuration fix * test: playwright setup debug * test: playwright add to dev dependencies * test: yarn update * test: playwright cache strategy change * test: cache cleaned for playwright * test: playwright version update * test: dep install * test: cache debugging * test: cache debugging change key file * test: cache debugging continue * test: cache debugging syntax fix * test: cache debugging syntax fix * test: cache debugging fix * test: cache synatax fix * test: npm install add * test: dependencies update add * test: dependencies upgrade * Update run-tests.yml * PubNub SDK v0.28.0 release. --------- Co-authored-by: anton-pub <[email protected]> Co-authored-by: Serhii Mamontov <[email protected]> Co-authored-by: PubNub Release Bot <[email protected]>
1 parent 77ee1d3 commit 218247d

File tree

15 files changed

+2570
-2075
lines changed

15 files changed

+2570
-2075
lines changed

.github/workflows/run-tests.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ jobs:
5454
id: playwright-browsers-cache
5555
uses: actions/cache@v3
5656
with:
57-
key: ${{ runner.os }}-playwright-${{ hashFiles('react/package-lock.json') }}
57+
key: ${{ runner.os }}-playwright-${{ hashFiles('react/yarn.lock') }}
5858
restore-keys: ${{ runner.os }}-playwright-
5959
path: ~/.cache/ms-playwright
60+
- name: Clear Playwright cache
61+
run: npx playwright install-deps
62+
- name: Install project dependencies
63+
run: npm install
6064
- name: Install Playwright browsers
61-
if: steps.playwright-browsers-cache.outputs.cache-hit != 'true'
6265
run: npx playwright install
6366
- name: Checkout repository
6467
uses: actions/checkout@v3

.pubnub.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
---
22
name: pubnub-react-chat-components
3-
version: v0.27.0
3+
version: v0.28.0
44
scm: github.com/pubnub/react-chat-components
55
schema: 1
66
files:
77
- lib/dist/index.js
88
- lib/dist/index.es.js
99
changelog:
10+
- date: 2023-06-27
11+
version: v0.28.0
12+
changes:
13+
- type: feature
14+
text: "MessageInput - actionsAfterInput option to reorder elements."
1015
- date: 2023-04-19
1116
version: v0.27.0
1217
changes:

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"devDependencies": {
4646
"@commitlint/cli": "17.1.2",
4747
"@commitlint/config-conventional": "17.1.0",
48+
"@playwright/test": "^1.35.1",
4849
"@typescript-eslint/eslint-plugin": "5.37.0",
4950
"@typescript-eslint/parser": "5.37.0",
5051
"concurrently": "7.4.0",

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pubnub/common-chat-components",
3-
"version": "0.27.0",
3+
"version": "0.28.0",
44
"main": "src/index.ts",
55
"license": "MIT",
66
"scripts": {

packages/common/src/message-input/message-input.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, ChangeEvent } from "react";
1+
import { useState, useEffect } from "react";
22
import { useAtom } from "jotai";
33
import { usePubNub } from "pubnub-react";
44
import uuid from "react-native-uuid";
@@ -28,6 +28,8 @@ export interface CommonMessageInputProps {
2828
disabled?: boolean;
2929
/** Custom UI component to override default display for the Send button. */
3030
sendButton?: JSX.Element | string;
31+
/** Option to move action buttons (eg. file upload icon) to the right of the text input. */
32+
actionsAfterInput?: boolean;
3133
/** Callback to modify message content before sending it. This only works for text messages, not files. */
3234
onBeforeSend?: (value: MessagePayload) => MessagePayload;
3335
/** Callback for extra actions after sending a message. */

packages/react-native/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pubnub/react-native-chat-components",
3-
"version": "0.27.0",
3+
"version": "0.28.0",
44
"description": "PubNub Chat Components is a development kit of React Native components that aims to help you to easily build Chat applications using PubNub infrastructure. It removes the complexicity of picking an adequate Chat engine, learning its APIs and dealing with its low-level internals. As the same time it allows you to create apps of various use cases, with different functionalities and customizable looks.",
55
"author": "PubNub <[email protected]>",
66
"main": "dist/commonjs/index",

packages/react-native/src/message-input/message-input.style.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ export default (theme: Themes): MessageInputStyle => {
5151
return StyleSheet.create<MessageInputStyle>({
5252
messageInputWrapper: {
5353
backgroundColor: colors.wrapperBackground,
54-
paddingHorizontal: 16,
54+
paddingHorizontal: 8,
5555
paddingVertical: 10,
5656
flexDirection: "row",
5757
alignItems: "center",
5858
},
5959
messageInputFileLabel: {
6060
width: 20,
6161
height: 20,
62-
marginRight: 18,
62+
marginHorizontal: 9,
6363
},
6464
messageInputRemoveFileLabel: {
6565
width: 20,
6666
height: 20,
67-
marginRight: 18,
67+
marginHorizontal: 9,
6868
},
6969
messageInput: {
7070
backgroundColor: colors.inputBackground,
@@ -74,21 +74,22 @@ export default (theme: Themes): MessageInputStyle => {
7474
paddingTop: 8,
7575
paddingBottom: 10,
7676
fontSize: 16,
77+
marginHorizontal: 9,
7778
flex: 1,
7879
},
7980
messageInputPlaceholder: {
8081
color: colors.inputPlaceholder,
8182
},
8283
sendButton: {
83-
marginLeft: 16,
84+
marginHorizontal: 9,
8485
},
8586
sendButtonActive: {},
8687
icon: {
8788
height: 20,
8889
width: 20,
8990
},
9091
extraActions: {
91-
marginRight: 16,
92+
marginRight: 8,
9293
},
9394
fileUploadModalContent: {
9495
flex: 1,

packages/react-native/src/message-input/message-input.tsx

+33-25
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,32 @@ export const MessageInput: FC<MessageInputProps> = (props: MessageInputProps) =>
141141
const renderFileUpload = () => {
142142
return (
143143
<>
144-
<View>
145-
<>
146-
{props.fileUpload === "image" ? (
147-
<TouchableOpacity
148-
style={style.messageInputFileLabel}
149-
onPress={pickPhoto}
150-
testID="message-input-photo-icon-container"
151-
>
152-
<Image source={{ uri: ImageIcon }} style={style.icon} />
153-
</TouchableOpacity>
154-
) : (
155-
<TouchableOpacity
156-
style={style.messageInputFileLabel}
157-
onPress={() => setModalVisible(true)}
158-
testID="message-input-file-icon-container"
159-
>
160-
<Image source={{ uri: FileIcon }} style={style.icon} />
161-
</TouchableOpacity>
162-
)}
163-
</>
164-
</View>
165-
{file && (
144+
{file ? (
166145
<TouchableOpacity style={style.messageInputRemoveFileLabel} onPress={handleRemoveFile}>
167146
<Image source={{ uri: XCircleIcon }} style={style.icon} />
168147
</TouchableOpacity>
148+
) : (
149+
<View>
150+
<>
151+
{props.fileUpload === "image" ? (
152+
<TouchableOpacity
153+
style={style.messageInputFileLabel}
154+
onPress={pickPhoto}
155+
testID="message-input-photo-icon-container"
156+
>
157+
<Image source={{ uri: ImageIcon }} style={style.icon} />
158+
</TouchableOpacity>
159+
) : (
160+
<TouchableOpacity
161+
style={style.messageInputFileLabel}
162+
onPress={() => setModalVisible(true)}
163+
testID="message-input-file-icon-container"
164+
>
165+
<Image source={{ uri: FileIcon }} style={style.icon} />
166+
</TouchableOpacity>
167+
)}
168+
</>
169+
</View>
169170
)}
170171
</>
171172
);
@@ -187,13 +188,19 @@ export const MessageInput: FC<MessageInputProps> = (props: MessageInputProps) =>
187188
);
188189
};
189190

190-
return (
191-
<View style={style.messageInputWrapper}>
192-
{renderFileModal()}
191+
const renderActions = () => (
192+
<>
193193
{!props.disabled && props.fileUpload && renderFileUpload()}
194194
{props.extraActionsRenderer && (
195195
<View style={style.extraActions}>{props.extraActionsRenderer()}</View>
196196
)}
197+
</>
198+
);
199+
200+
return (
201+
<View style={style.messageInputWrapper}>
202+
{renderFileModal()}
203+
{!props.actionsAfterInput && renderActions()}
197204
<TextInput
198205
testID="message-input"
199206
autoComplete="off"
@@ -205,6 +212,7 @@ export const MessageInput: FC<MessageInputProps> = (props: MessageInputProps) =>
205212
editable={!props.disabled && file == null}
206213
value={text}
207214
/>
215+
{props.actionsAfterInput && renderActions()}
208216
{!props.disabled && (
209217
<View style={style.sendButton}>
210218
{loader ? (

packages/react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pubnub/react-chat-components",
3-
"version": "0.27.0",
3+
"version": "0.28.0",
44
"description": "PubNub Chat Components is a development kit of React components that aims to help you to easily build Chat applications using PubNub infrastructure. It removes the complexicity of picking an adequate Chat engine, learning its APIs and dealing with its low-level internals. As the same time it allows you to create apps of various use cases, with different functionalities and customizable looks.",
55
"author": "PubNub <[email protected]>",
66
"main": "dist/index.js",

packages/react/src/icons/file.svg

+1-1
Loading

packages/react/src/icons/image.svg

+1-1
Loading

packages/react/src/icons/x-circle.svg

+1-1
Loading

packages/react/src/message-input/message-input.scss

+18-9
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
** ********************* */
44
:root {
55
--msg-input__background: var(--chat--light__background--1);
6-
--msg-input__padding: 10px 18px;
7-
--msg-input__emoji-picker__bottom: 14px;
8-
--msg-input__emoji-picker__left: 10px;
6+
--msg-input__padding: 10px 9px;
7+
--msg-input__emoji-picker__bottom: 16px;
8+
--msg-input__emoji-picker__left: 16px;
9+
--msg-input__emoji-picker__right: 95px;
10+
--msg-input__icon__background: none;
11+
--msg-input__icon__border: none;
912
--msg-input__icon__color: var(--chat--light__color--2);
10-
--msg-input__icon__margin: 0 18px 0 0;
1113
--msg-input__icon__fontSize: 13px;
14+
--msg-input__icon__margin: 0 9px;
15+
--msg-input__icon__padding: 0;
1216
--msg-input__send__background: transparent;
1317
--msg-input__send__border: none;
1418
--msg-input__send__borderRadius: 5px;
@@ -17,7 +21,7 @@
1721
--msg-input__send__fontFamily: inherit;
1822
--msg-input__send__fontSize: 13px;
1923
--msg-input__send__fontWeight: bold;
20-
--msg-input__send__margin: 0 0 0 18px;
24+
--msg-input__send__margin: 0 9px;
2125
--msg-input__send__minWidth: 0;
2226
--msg-input__send__padding: 0;
2327
--msg-input--disabled__placeholder__color: rgba(var(--chat--light__color--2-rgb), 0.5);
@@ -37,6 +41,7 @@
3741
--msg-input__textarea__lineHeight: 18px;
3842
--msg-input__textarea__outline: none;
3943
--msg-input__textarea__padding: 6px 14px 8px;
44+
--msg-input__textarea__margin: 0 9px;
4045
--msg-input__textarea__resize: none;
4146
--msg-input__textarea__width: 100%;
4247
--msg-input__textarea__overflow: hidden;
@@ -67,11 +72,12 @@
6772
font-size: var(--msg-input__textarea__fontSize);
6873
height: var(--msg-input__textarea__height);
6974
line-height: var(--msg-input__textarea__lineHeight);
75+
margin: var(--msg-input__textarea__margin);
7076
outline: var(--msg-input__textarea__outline);
77+
overflow: var(--msg-input__textarea__overflow);
7178
padding: var(--msg-input__textarea__padding);
7279
resize: var(--msg-input__textarea__resize);
7380
width: var(--msg-input__textarea__width);
74-
overflow: var(--msg-input__textarea__overflow);
7581

7682
&:focus-within {
7783
outline: var(--msg-input__textarea--focus__outline);
@@ -95,7 +101,6 @@
95101
font-weight: var(--msg-input__send__fontWeight);
96102
margin: var(--msg-input__send__margin);
97103
min-width: var(--msg-input__send__minWidth);
98-
outline: none;
99104
padding: var(--msg-input__send__padding);
100105
white-space: nowrap;
101106

@@ -107,18 +112,22 @@
107112
&__emoji-picker {
108113
bottom: var(--msg-input__emoji-picker__bottom);
109114
left: var(--msg-input__emoji-picker__left);
115+
right: var(--msg-input__emoji-picker__right);
110116
position: absolute;
111117
}
112118

113119
&__icons {
114120
align-items: center;
115121
display: flex;
116122

117-
& > * {
118-
cursor: pointer;
123+
button {
124+
background: var(--msg-input__icon__background);
125+
border: var(--msg-input__icon__border);
119126
color: var(--msg-input__icon__color);
127+
cursor: pointer;
120128
font-size: var(--msg-input__icon__fontSize);
121129
margin: var(--msg-input__icon__margin);
130+
padding: var(--msg-input__icon__padding);
122131
}
123132
}
124133

0 commit comments

Comments
 (0)