Skip to content

Commit 81e5531

Browse files
authored
Merge pull request #1037 from GetStream/lazy-load-emoji-mart
Lazy load emoji mart
2 parents 86a1616 + 8c11e3e commit 81e5531

33 files changed

+317
-1800
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [6.4.0](https://github.com/GetStream/stream-chat-react/releases/tag/v6.4.0) 2021-07-07
4+
5+
### ⚠️ BREAKING CHANGES ⚠️ - The following values have been moved to the newly created [`EmojiContext`](https://getstream.io/chat/docs/sdk/react/contexts/emoji_context/):
6+
7+
- `Emoji` - moved from `ComponentContext`
8+
- `emojiConfig` - moved from `ChannelStateContext`
9+
- `EmojiIndex` - moved from `ComponentContext`
10+
- `EmojiPicker` - moved from `ComponentContext`
11+
12+
### Feature
13+
14+
- Lazy load the `emoji-mart` dependency [#1037](https://github.com/GetStream/stream-chat-react/pull/1037)
15+
16+
### Chore
17+
18+
- Remove unused CSS [#1035](https://github.com/GetStream/stream-chat-react/pull/1035)
19+
320
## [6.3.0](https://github.com/GetStream/stream-chat-react/releases/tag/v6.3.0) 2021-07-02
421

522
### ⚠️ BREAKING CHANGES ⚠️ - We've removed the following deprecated UI components [#1031](https://github.com/GetStream/stream-chat-react/pull/1031):

docusaurus/docs/React/contexts/channel-state-context.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ The configurations object for the currently active channel.
4141
| ------ |
4242
| object |
4343

44-
### emojiConfig
45-
46-
The configuration for Emojis.
47-
48-
| Type |
49-
| ----------- |
50-
| EmojiConfig |
51-
5244
### error
5345

5446
Error object (if any) in loading the `channel`, otherwise null.

docusaurus/docs/React/contexts/component-context.mdx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The `ComponentContext` also exposes the hook `useComponentContext`.
1414
Pull values from context with our custom hook:
1515

1616
```jsx
17-
const { Attachment, Avatar, EmojiPicker } = useComponentContext();
17+
const { Attachment, Avatar, Message } = useComponentContext();
1818
```
1919

2020
## Values
@@ -83,14 +83,6 @@ Custom UI component to override default edit message input.
8383
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
8484
| component | [EditMessageForm](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/EditMessageForm.tsx) |
8585

86-
### Emoji
87-
88-
Custom UI component to override default `NimbleEmoji` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
89-
90-
| Type |
91-
| --------- |
92-
| component |
93-
9486
### EmojiIcon
9587

9688
Custom UI component for emoji button in input.
@@ -99,22 +91,6 @@ Custom UI component for emoji button in input.
9991
| --------- | ------------------------------------------------------------------------------------------------------------------ |
10092
| component | [EmojiIconSmall](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/icons.tsx) |
10193

102-
### EmojiIndex
103-
104-
Custom class constructor to override default `NimbleEmojiIndex` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
105-
106-
| Type |
107-
| ----------- |
108-
| constructor |
109-
110-
### EmojiPicker
111-
112-
Custom UI component to override default `NimblePicker` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
113-
114-
| Type |
115-
| --------- |
116-
| component |
117-
11894
### EmptyStateIndicator
11995

12096
Custom UI component to be displayed when the `MessageList` is empty.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: emoji_context
3+
sidebar_position: 5
4+
title: EmojiContext
5+
---
6+
7+
The `EmojiContext` is established by the `Channel` component and exposes the `useEmojiContext` hook. This context holds
8+
the UI components and stateful data necessary to render emoji selector functionality.
9+
10+
## Basic Usage
11+
12+
Pull values from context with our custom hook:
13+
14+
```jsx
15+
const { Emoji, emojiConfig } = useEmojiContext();
16+
```
17+
18+
## Values
19+
20+
### Emoji
21+
22+
Custom UI component to override default `NimbleEmoji` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
23+
24+
| Type |
25+
| --------- |
26+
| component |
27+
28+
### emojiConfig
29+
30+
The configuration data for emojis, including the rendered JSON data set.
31+
32+
| Type |
33+
| ----------- |
34+
| EmojiConfig |
35+
36+
### EmojiIndex
37+
38+
Custom class constructor to override default `NimbleEmojiIndex` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
39+
40+
| Type |
41+
| ----------- |
42+
| constructor |
43+
44+
### EmojiPicker
45+
46+
Custom UI component to override default `NimblePicker` from ['emoji-mart'](https://www.npmjs.com/package/emoji-mart).
47+
48+
| Type |
49+
| --------- |
50+
| component |

docusaurus/docs/React/contexts/message-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: message_context
3-
sidebar_position: 5
3+
sidebar_position: 6
44
title: MessageContext
55
---
66

docusaurus/docs/React/contexts/message-input-context.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
id: message_input_context
3-
sidebar_position: 6
3+
sidebar_position: 7
44
title: MessageInputContext
55
---
66

77
The `MessageInputContext` is established within the [`MessageInput`](../message-input-components/message-input.mdx) component.
8-
The value is the combination of the `MessageInputProps`, `MessageInputState` (returned by the `useMessageInputState` hook), and `cooldownTimerState` (returned by the `useCooldownTimer hook`).
8+
The value is the combination of the `MessageInputProps`, `MessageInputState` (returned by the `useMessageInputState` hook), and `cooldownTimerState` (returned by the `useCooldownTimer hook`).
99
It provides data to the [Input UI](../message-input-components/input-ui.mdx) component and its children. Use the values stored
1010
within this context to build a custom Input UI component. You can access the context values by calling the `useMessageInputContext`
1111
custom hook.

docusaurus/docs/React/contexts/translation-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: translation_context
3-
sidebar_position: 7
3+
sidebar_position: 8
44
title: TranslationContext
55
---
66

docusaurus/docs/React/contexts/typing-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: typing_context
3-
sidebar_position: 8
3+
sidebar_position: 9
44
title: TypingContext
55
---
66

docusaurus/docs/React/core-components/channel.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ It provides four separate contexts to its children:
1010
- [`ChannelStateContext`](../contexts/channel-state-context.mdx) - stateful data (ex: `messages` or `members`)
1111
- [`ChannelActionContext`](../contexts/channel-action-context.mdx) - action handlers (ex: `sendMessage` or `openThread`)
1212
- [`ComponentContext`](../contexts/component-context.mdx) - custom component UI overrides (ex: `Avatar` or `Message`)
13+
- [`EmojiContext`](../contexts/emoji-context.mdx) - emoji UI components and data (ex: `EmojiPicker` or `emojiConfig`)
1314
- [`TypingContext`](../contexts/typing-context.mdx) - object of currently typing users (i.e., `typing`)
1415

1516
:::note

docusaurus/docs/React/custom-code-examples/emoji-picker.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ loaded into the component library.
4343

4444
## Create the Custom Component
4545

46-
To construct our component, we will utilize the `ChannelStateContext` to get our `emojiConfig` data. This config object contains the `emojiData` we need for
47-
our `data` prop. Using the `onSelectEmoji` method from the `MessageInputContext`, we can add the onClick functionality to our custom picker. This is what our final code will look like:
46+
To construct our component, we will utilize the `EmojiContext` to get our `emojiConfig` data. This config object contains the `emojiData` we need for the
47+
`data` prop on the `Emoji` component. Using the `onSelectEmoji` method from the `MessageInputContext`, we can add the onClick functionality to our custom picker.
48+
49+
This is what our final code will look like:
4850

4951
```tsx
5052
export const CustomEmojiPicker = () => {
51-
const { emojiConfig } = useChannelStateContext();
52-
const { Emoji } = useComponentContext();
53+
const { Emoji, emojiConfig } = useEmojiContext();
5354
const { onSelectEmoji } = useMessageInputContext();
5455

5556
const { emojiData } = emojiConfig || {};

0 commit comments

Comments
 (0)