Skip to content

Commit 55c848f

Browse files
authored
doc: update all examples to V4 + StackBlitz (#661)
* Update all sample code to V4 * Convert CodeSandbox to StackBlitz * Render all examples with Vite
1 parent e6388eb commit 55c848f

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

SAMPLES.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Find out more about Sendbird UIKit for React at [UIKit for React doc](https://se
2323

2424
## UIKit components and ways to customize
2525

26-
These samples are here to help you better understand UIKit for React by going over the core components and ways to customize. On each core component sample, there is an attached CodeSandbox link in which you can see the sample codes and alter them to see how the changes are rendered.
26+
These samples are here to help you better understand UIKit for React by going over the core components and ways to customize. On each core component sample, there is an attached [StackBlitz](https://stackblitz.com/) link in which you can see the sample codes and alter them to see how the changes are rendered.
2727

2828
<br />
2929

@@ -43,7 +43,7 @@ The minimum requirements for UIKit for React are:
4343

4444
### Implement Chat with App component
4545

46-
The `App` component is a collection of all UIKit components you need to implement chat. This is included in all core component samples, so be sure to set your own APP_ID, USER_ID, and NICKNAME in `const.js` in each to customize your sample. On the [CodeSandbox](https://codesandbox.io/s/1-1-using-sendbird-app-9l4d4b) link, you will see that the props of the `App` component refer to use the values of the correspondings of `const.js` for initialization.
46+
The `App` component is a collection of all UIKit components you need to implement chat. This is included in all core component samples, so be sure to set your own APP_ID, USER_ID, and NICKNAME in `const.js` in each to customize your sample. On the [StackBlitz](https://stackblitz.com/edit/sendbird-react-uikit-base-app) link, you will see that the props of the `App` component refer to use the values of the correspondings of `const.js` for initialization.
4747

4848
Try setting your own by downloading the Sendbird sample.
4949

@@ -55,7 +55,7 @@ import SendbirdApp from '@sendbird/uikit-react/App';
5555

5656
Here is a list of the essential components that you need to import before you start customizing chat. Note that the names of the components are changed as shown in the code below.
5757

58-
Try [importing components on CodeSandbox](https://codesandbox.io/s/1-2-customization-basic-format-9skqq3).
58+
Try [importing components on StackBlitz](https://stackblitz.com/edit/sendbird-react-uikit-customized-app).
5959

6060
```javascript
6161
import SBConversation from '@sendbird/uikit-react/Channel';
@@ -64,11 +64,11 @@ import SBChannelSettings from '@sendbird/uikit-react/ChannelSettings';
6464
import withSendBird from '@sendbird/uikit-react/withSendbird';
6565
```
6666

67-
### Referring to CodeSandbox
67+
### Referring to StackBlitz
6868

69-
Each CodeSandbox sample has `App.js` and `CustomizedApp.js` which operate based on the imported `const.js`. CodeSandbox is a code editor that provides an instant live preview. The preview has two buttons placed at the top center. If you click the left button, you will see unaltered `App.js`. If you click the right button, you will see the customized component from `CustomizedApp.js`, and any changes you make on them applied and rendered on the live preview.
69+
Each StackBlitz sample has `App.js` and `CustomizedApp.js` which operate based on the imported `const.js`. StackBlitz is a code editor that provides an instant live preview. The preview has two buttons placed at the top center. If you click the left button, you will see unaltered `App.js`. If you click the right button, you will see the customized component from `CustomizedApp.js`, and any changes you make on them applied and rendered on the live preview.
7070

71-
If you would like to get a deeper understanding of how CodeSandbox works, refer to **CustomizedMessageItems**, **CustomizedHeader**, **CustomizedMessageInput**, and **CustomizedChannelPreviewItem** which you can find on corresponding CodeSandbox samples.
71+
If you would like to get a deeper understanding of how StackBlitz works, refer to **CustomizedMessageItems**, **CustomizedHeader**, **CustomizedMessageInput**, and **CustomizedChannelPreviewItem** which you can find on corresponding StackBlitz samples.
7272

7373
<br />
7474

@@ -80,7 +80,7 @@ This section explains what you need to know before testing the sample app.
8080

8181
The **renderChatItem** is a `ReactElement` prop in the Channel component which you can use to customize `message` by setting a function. This prop provides three arguments: **message**, **onUpdateMessage**, and **onDeleteMessage**. The **message** represents an already sent or received message of an `BaseMessage` object; **onUpdateMessage** and **onDeleteMessage** are callback functions which you can implement with custom code for events related to the corresponding user actions.
8282

83-
Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-messageitem-q38cg5).
83+
Try your [message item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-item).
8484

8585
```javascript
8686
<Channel
@@ -96,29 +96,29 @@ Try your [message item on CodeSandbox](https://codesandbox.io/s/2-1-customizing-
9696
>
9797
```
9898

99-
> Note: You can try making your own customized message item by using `<CustomizedMessageItem />` on the CodeSandbox sample.
99+
> Note: You can try making your own customized message item by using `<CustomizedMessageItem />` on the StackBlitz sample.
100100
101101
### Message list params
102102

103103
The **queries.messageListParams** is an `instance` prop in the **channel** component which you can use to retrieve a list of messages by specifying the properties of `MessageListParams`.
104104

105-
Try your [message list params on CodeSandbox](https://codesandbox.io/s/2-2-customizing-messagelistparams-3ipi0g).
105+
Try your [message list params on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-list-params).
106106

107-
> Note: On CodeSandbox’s preview, only the messages you sent will be displayed.
107+
> Note: On StackBlitz preview, only the messages you sent will be displayed.
108108
109109
```javascript
110110
// Pass arguments in JSON data input format to the query instance.
111-
const [queries] = useState({
111+
const queries = useMemo(() => ({
112112
// use object json type input, don't create sendbird query instance
113-
// https://sendbird.github.io/core-sdk-javascript/module-model_params_messageListParams-MessageListParams.html
114-
// https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/SendBird.d.ts#L488
113+
// https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_message.MessageListParams.html
114+
// https://github.com/sendbird/sendbird-chat-sdk-javascript/blob/main/lib/__definition.d.ts#L764
115115
messageListParams: {
116-
senderUserIds: [USER_ID],
116+
senderUserIdsFilter: [USER_ID],
117117
prevResultSize: 30,
118118
includeReplies: false,
119119
includeReactions: false,
120120
},
121-
});
121+
}));
122122

123123
<Channel queries={queries} />;
124124
```
@@ -127,9 +127,9 @@ const [queries] = useState({
127127

128128
The **onBeforeSendUserMessage**, **onBeforeSendFileMessage**, and **onBeforeUpdateUserMessage** are `callback function` props in the **channel** component. The first two execute additional operations for a user message and a file message respectively; the corresponding modified messages are returned through the **text** and the **file** arguments respectively. The **onBeforeUpdateUserMessage** executes additional operations for a user message before updating it.
129129

130-
Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizing-messageparams-606156)
130+
Try your [message params on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-params)
131131

132-
> Note: On the CodeSandbox’s preview, you can send or update a message in highlight.
132+
> Note: On the StackBlitz preview, you can send or update a message in highlight.
133133
134134
```javascript
135135
<Channel
@@ -139,7 +139,7 @@ Try your [message params on CodeSandbox](https://codesandbox.io/s/2-3-customizin
139139
>
140140
```
141141

142-
In order to complete an operation you intend to carry out with each function, you should return `UserMessageParams` and `FileMessageParams` objects.
142+
In order to complete an operation you intend to carry out with each function, you should return `UserMessageCreateParams`, `UserMessageUpdateParams` and `FileMessageCreateParams` objects.
143143

144144
```javascript
145145
const handleUpdateUserMessage = (text) => {
@@ -149,13 +149,13 @@ const handleUpdateUserMessage = (text) => {
149149
};
150150
```
151151

152-
Find out more about `UserMessageParams` and `FileMessageParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_message.UserMessageCreateParams.html).
152+
Find out more about `UserMessageCreateParams`, `UserMessageUpdateParams` and `FileMessageCreateParams` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/modules/_sendbird_chat_message.html).
153153

154154
### Chat header
155155

156156
The **renderChatHeader** is a `ReactElement` prop in the **channel** component which you can use to customize the header of `channel` by setting a function. This prop provides two arguments: **channel** and **user**. The channel refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **user** refers to a `User` object which represents the current user.
157157

158-
Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-chatheader-mi5ijz)
158+
Try your [chat header on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-chat-header)
159159

160160
```javascript
161161
<Channel
@@ -165,13 +165,13 @@ Try your [chat header on CodeSandbox](https://codesandbox.io/s/2-4-customizing-c
165165
>
166166
```
167167

168-
> Note: You can try making your own customized chat header item by using `<CustomizedHeader />` on the CodeSandbox sample.
168+
> Note: You can try making your own customized chat header item by using `<CustomizedHeader />` on the StackBlitz sample.
169169
170170
### Message input
171171

172172
The **renderMessageInput** is a `ReactElement` prop in the **Channel** component which allows you to customize the message input by setting a function. This prop provides three arguments: **channel**, **user**, and **disabled**. The **channel** refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **user** refers to a `User` object which represents the current user. The **disabled** refers to whether to enable the message input box or not.
173173

174-
Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing-messageinput-forked-or4lm8)
174+
Try your [message input on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-message-input)
175175

176176
```javascript
177177
<Channel
@@ -181,13 +181,13 @@ Try your [message input on CodeSandbox](https://codesandbox.io/s/2-5-customizing
181181
>
182182
```
183183

184-
> Note: You can try making your own customized message input item by using `<CustomizedMessageInput />` on the CodeSandbox sample.
184+
> Note: You can try making your own customized message input item by using `<CustomizedMessageInput />` on the StackBlitz sample.
185185
186186
### Channel preview item
187187

188188
The **renderChannelPreview** is a `ReactElement` prop in the **ChannelList** component which allows you to customize channel preview by setting a function. This prop provides two arguments: **channel** and **onLeaveChannel**. The **channel** refers to a `GroupChannel` object which is a collection of properties necessary to render the current channel view. The **onLeaveChannel** has a callback function as an argument which can be implemented with custom code for events related to the corresponding user action.
189189

190-
Try your [channel preview item on CodeSandbox](https://codesandbox.io/s/3-1-customizing-channelpreviewitem-7c9xz6)
190+
Try your [channel preview item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-preview)
191191

192192
```javascript
193193
<ChannelList
@@ -214,40 +214,39 @@ const CustomizedChannelPreviewItem = (props) => {
214214

215215
The **queries.channelListQuery** is an `instance` prop in the **ChannelList** component which filters channels by using its options.
216216

217-
Try your [channel list query item on CodeSandbox](https://codesandbox.io/s/3-2-customizing-channellistquery-d0t2l8)
217+
Try your [channel list query item on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-list-queries)
218218

219-
> Note: On the CodeSandbox’s preview, the empty channels that you see means that the channels are successfully created and there are no messages sent by users.
219+
> Note: On the StackBlitz’s preview, the empty channels that you see means that the channels are successfully created and there are no messages sent by users.
220220
221221
```javascript
222222
// Pass arguments in JSON data input format to the query instance.
223-
const [queries] = useState({
223+
const queries = useMemo(() => ({
224224
channelListQuery: {
225+
// Should be an instance of GroupChannelListQueryParams
226+
// https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat_groupChannel.GroupChannelListQueryParams.html
225227
includeEmpty: true,
226228
limit: 50,
227-
order: "chronological"
228-
// channelListQuery
229-
// https://sendbird.github.io/core-sdk-javascript/module-model_query_groupChannelListQuery-GroupChannelListQuery.html
229+
order: 'chronological',
230230
},
231231
applicationUserListQuery: {
232-
limit: 50
233-
// ex) userIdsFilter: ["sendbirdian", ...]
234-
// applicationUserListQuery
235-
// https://sendbird.github.io/core-sdk-javascript/module-model_query_applicationUserListQuery-ApplicationUserListQuery.html
236-
}
237-
});
232+
// Should be an instance of ApplicaitonUserListQuery
233+
// https://sendbird.com/docs/chat/v4/javascript/ref/interfaces/_sendbird_chat.ApplicationUserListQueryParams.html
234+
nicknameStartsWithFilter: 'Jackson',
235+
},
236+
}));
238237

239238
<ChannelList
240239
queries={queries}
241240
>
242241
```
243242

244-
Find out more about `ChannelListQuery` and `ApplicationUserListQuery` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/classes/_sendbird_chat_groupChannel.GroupChannelListQuery.html).
243+
Find out more about `ChannelListQuery` and `ApplicationUserListQuery` on the [API reference of Sendbird Chat SDK for JavaScript](https://sendbird.com/docs/chat/v4/javascript/ref/modules/_sendbird_chat_groupChannel.html).
245244

246245
### Channel params
247246

248247
The **onBeforeCreateChannel** is a prop of the **ChannelList** component which can be implemented with custom code for events related to the corresponding user actions.
249248

250-
Try your [channel param on CodeSandbox](https://codesandbox.io/s/3-3-customizing-channelparams-vgcgtj)
249+
Try your [channel param on StackBlitz](https://stackblitz.com/edit/sendbird-uikit-react-custom-channel-params)
251250

252251
> Note: you can create a channel using `GroupChannelParams`.
253252

0 commit comments

Comments
 (0)