Skip to content

Commit c3124a4

Browse files
authored
Merge pull request #52 from sendbird/feat/reactions
[UIKIT-2585] Feat/reactions
2 parents 40ed1a4 + e8387cc commit c3124a4

File tree

45 files changed

+1377
-240
lines changed

Some content is hidden

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

45 files changed

+1377
-240
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
node-version: [16.x]
20+
node-version: [16]
2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v1
24+
uses: actions/setup-node@v3
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727

@@ -31,7 +31,7 @@ jobs:
3131

3232
- name: Check cached node_modules
3333
id: check_cache
34-
uses: actions/cache@v2
34+
uses: actions/cache@v3
3535
with:
3636
path: ${{ env.CACHE_NODE_MODULES_PATH }}
3737
key: ${{ steps.lockfile_hash.outputs.hash }}
@@ -47,16 +47,16 @@ jobs:
4747
runs-on: ubuntu-latest
4848
strategy:
4949
matrix:
50-
node-version: [16.x]
50+
node-version: [16]
5151
steps:
52-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
5353
- name: Use Node.js ${{ matrix.node-version }}
54-
uses: actions/setup-node@v1
54+
uses: actions/setup-node@v3
5555
with:
5656
node-version: ${{ matrix.node-version }}
5757

5858
- name: Check cached node_modules
59-
uses: actions/cache@v2
59+
uses: actions/cache@v3
6060
with:
6161
path: ${{ env.CACHE_NODE_MODULES_PATH }}
6262
key: ${{ needs.prepare.outputs.cache_node_modules_key }}
@@ -69,16 +69,16 @@ jobs:
6969
runs-on: ubuntu-latest
7070
strategy:
7171
matrix:
72-
node-version: [16.x]
72+
node-version: [16, 18]
7373
steps:
74-
- uses: actions/checkout@v2
74+
- uses: actions/checkout@v3
7575
- name: Use Node.js ${{ matrix.node-version }}
76-
uses: actions/setup-node@v1
76+
uses: actions/setup-node@v3
7777
with:
7878
node-version: ${{ matrix.node-version }}
7979

8080
- name: Check cached node_modules
81-
uses: actions/cache@v2
81+
uses: actions/cache@v3
8282
with:
8383
path: ${{ env.CACHE_NODE_MODULES_PATH }}
8484
key: ${{ needs.prepare.outputs.cache_node_modules_key }}
@@ -91,16 +91,16 @@ jobs:
9191
runs-on: ubuntu-latest
9292
strategy:
9393
matrix:
94-
node-version: [16.x]
94+
node-version: [16]
9595
steps:
96-
- uses: actions/checkout@v2
96+
- uses: actions/checkout@v3
9797
- name: Use Node.js ${{ matrix.node-version }}
98-
uses: actions/setup-node@v1
98+
uses: actions/setup-node@v3
9999
with:
100100
node-version: ${{ matrix.node-version }}
101101

102102
- name: Check cached node_modules
103-
uses: actions/cache@v2
103+
uses: actions/cache@v3
104104
with:
105105
path: ${{ env.CACHE_NODE_MODULES_PATH }}
106106
key: ${{ needs.prepare.outputs.cache_node_modules_key }}
@@ -113,16 +113,16 @@ jobs:
113113
runs-on: ubuntu-latest
114114
strategy:
115115
matrix:
116-
node-version: [16.x]
116+
node-version: [16]
117117
steps:
118-
- uses: actions/checkout@v2
118+
- uses: actions/checkout@v3
119119
- name: Use Node.js ${{ matrix.node-version }}
120-
uses: actions/setup-node@v1
120+
uses: actions/setup-node@v3
121121
with:
122122
node-version: ${{ matrix.node-version }}
123123

124124
- name: Check cached node_modules
125-
uses: actions/cache@v2
125+
uses: actions/cache@v3
126126
with:
127127
path: ${{ env.CACHE_NODE_MODULES_PATH }}
128128
key: ${{ needs.prepare.outputs.cache_node_modules_key }}

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ export const useGroupChannelMessagesWithQuery: UseGroupChannelMessages = (sdk, c
219219
async (failedMessage) => {
220220
const message = await (() => {
221221
if (failedMessage.isUserMessage()) return channel.resendUserMessage(failedMessage);
222-
// FIXME: v4 bugs
223-
// @ts-ignore
224222
if (failedMessage.isFileMessage()) return channel.resendFileMessage(failedMessage);
225223
return null;
226224
})();

packages/uikit-chat-hooks/src/common/useTotalUnreadChannelCount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react';
22

33
import type { SendbirdChatSDK } from '@sendbird/uikit-utils';
4-
import { truncatedBadgeCount, useAsyncEffect } from '@sendbird/uikit-utils';
4+
import { truncatedCount, useAsyncEffect } from '@sendbird/uikit-utils';
55
import { useUniqId } from '@sendbird/uikit-utils';
66

77
import { useUserEventHandler } from '../handler/useUserEventHandler';
@@ -24,5 +24,5 @@ export const useTotalUnreadChannelCount = (sdk: SendbirdChatSDK, params?: Params
2424
},
2525
});
2626

27-
return truncatedBadgeCount(unreadChannelCount, params?.maxCount);
27+
return truncatedCount(unreadChannelCount, params?.maxCount);
2828
};

packages/uikit-chat-hooks/src/common/useTotalUnreadMessageCount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22

33
import { SuperChannelFilter, TotalUnreadMessageCountParams } from '@sendbird/chat/groupChannel';
44
import type { SendbirdChatSDK } from '@sendbird/uikit-utils';
5-
import { truncatedBadgeCount, useAsyncEffect, useUniqId } from '@sendbird/uikit-utils';
5+
import { truncatedCount, useAsyncEffect, useUniqId } from '@sendbird/uikit-utils';
66

77
import { useUserEventHandler } from '../handler/useUserEventHandler';
88

@@ -28,5 +28,5 @@ export const useTotalUnreadMessageCount = (sdk: SendbirdChatSDK, options?: Optio
2828
onTotalUnreadMessageCountUpdated: (totalCount: number) => setUnreadMessageCount(totalCount),
2929
});
3030

31-
return truncatedBadgeCount(unreadMessageCount, options?.maxCount);
31+
return truncatedCount(unreadMessageCount, options?.maxCount);
3232
};

packages/uikit-react-native-foundation/src/components/Modal/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import createStyleSheet from '../../styles/createStyleSheet';
1919
import useHeaderStyle from '../../styles/useHeaderStyle';
2020
import useUIKitTheme from '../../theme/useUIKitTheme';
2121

22+
type ModalAnimationType = 'slide' | 'slide-no-gesture' | 'fade';
2223
type Props = {
23-
type?: 'slide' | 'fade';
24+
type?: ModalAnimationType;
2425
onClose: () => void;
2526
backgroundStyle?: StyleProp<ViewStyle>;
2627
disableBackgroundClose?: boolean;
@@ -117,12 +118,12 @@ const isHideGesture = (distanceY: number, velocityY: number) => {
117118
return distanceY > 125 || (distanceY > 0 && velocityY > 0.1);
118119
};
119120
const useModalPanResponder = (
120-
type: 'slide' | 'fade',
121+
type: ModalAnimationType,
121122
translateY: Animated.Value,
122123
show: () => void,
123124
hide: () => void,
124125
) => {
125-
if (type === 'fade') return { panHandlers: {} };
126+
if (type === 'fade' || type === 'slide-no-gesture') return { panHandlers: {} };
126127
return React.useRef(
127128
PanResponder.create({
128129
onMoveShouldSetPanResponderCapture: (_, { dy }) => dy > 8,
@@ -137,15 +138,15 @@ const useModalPanResponder = (
137138
).current;
138139
};
139140

140-
const useModalAnimation = (type: 'slide' | 'fade') => {
141-
const initialY = type === 'slide' ? Dimensions.get('window').height : 0;
141+
const useModalAnimation = (type: ModalAnimationType) => {
142+
const initialY = type === 'fade' ? 0 : Dimensions.get('window').height;
142143
const baseAnimBackground = useRef(new Animated.Value(0)).current;
143144
const baseAnimContent = useRef(new Animated.Value(initialY)).current;
144145

145146
const content = {
146147
opacity: baseAnimBackground.interpolate({
147148
inputRange: [0, 1],
148-
outputRange: [type === 'slide' ? 1 : 0, 1],
149+
outputRange: [type === 'fade' ? 0 : 1, 1],
149150
}),
150151
translateY: baseAnimContent,
151152
};

packages/uikit-react-native-foundation/src/styles/createStyleSheet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const preProcessor: Partial<StylePreprocessor> = {
1212
'lineHeight': DEFAULT_SCALE_FACTOR,
1313
'borderRadius': DEFAULT_SCALE_FACTOR,
1414
'minWidth': SCALE_FACTOR_WITH_STR,
15+
'maxWidth': SCALE_FACTOR_WITH_STR,
1516
'minHeight': SCALE_FACTOR_WITH_STR,
17+
'maxHeight': SCALE_FACTOR_WITH_STR,
1618
'height': SCALE_FACTOR_WITH_STR,
1719
'width': SCALE_FACTOR_WITH_STR,
1820
'padding': SCALE_FACTOR_WITH_STR,

packages/uikit-react-native-foundation/src/theme/DarkUIKitTheme.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,28 @@ const DarkUIKitTheme = createTheme({
179179
},
180180
},
181181
},
182+
reaction: {
183+
default: {
184+
enabled: {
185+
background: palette.transparent,
186+
highlight: palette.onBackgroundDark03,
187+
},
188+
selected: {
189+
background: palette.primary500,
190+
highlight: palette.primary200,
191+
},
192+
},
193+
rounded: {
194+
enabled: {
195+
background: palette.background400,
196+
highlight: palette.transparent,
197+
},
198+
selected: {
199+
background: palette.primary500,
200+
highlight: palette.transparent,
201+
},
202+
},
203+
},
182204
},
183205
}),
184206
});

packages/uikit-react-native-foundation/src/theme/LightUIKitTheme.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,28 @@ const LightUIKitTheme = createTheme({
179179
},
180180
},
181181
},
182+
reaction: {
183+
default: {
184+
enabled: {
185+
background: palette.transparent,
186+
highlight: palette.onBackgroundLight03,
187+
},
188+
selected: {
189+
background: palette.primary100,
190+
highlight: palette.primary300,
191+
},
192+
},
193+
rounded: {
194+
enabled: {
195+
background: palette.background100,
196+
highlight: palette.transparent,
197+
},
198+
selected: {
199+
background: palette.primary100,
200+
highlight: palette.transparent,
201+
},
202+
},
203+
},
182204
},
183205
}),
184206
});

packages/uikit-react-native-foundation/src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export type Component =
4040
| 'Message'
4141
| 'DateSeparator'
4242
| 'GroupChannelPreview'
43-
| 'ProfileCard';
43+
| 'ProfileCard'
44+
| 'Reaction';
4445

4546
export type GetColorTree<
4647
Tree extends {
@@ -68,6 +69,7 @@ export type ComponentColorTree = GetColorTree<{
6869
DateSeparator: 'default';
6970
GroupChannelPreview: 'default';
7071
ProfileCard: 'default';
72+
Reaction: 'default' | 'rounded';
7173
};
7274
State: {
7375
Header: 'none';
@@ -80,6 +82,7 @@ export type ComponentColorTree = GetColorTree<{
8082
DateSeparator: 'none';
8183
GroupChannelPreview: 'none';
8284
ProfileCard: 'none';
85+
Reaction: 'enabled' | 'selected';
8386
};
8487
ColorPart: {
8588
Header: 'background' | 'borderBottom';
@@ -101,6 +104,7 @@ export type ComponentColorTree = GetColorTree<{
101104
| 'bodyIconBackground'
102105
| 'separator';
103106
ProfileCard: 'textUsername' | 'textBodyLabel' | 'textBody' | 'background';
107+
Reaction: 'background' | 'highlight';
104108
};
105109
}>;
106110
export type ComponentColors<T extends Component> = {
@@ -145,6 +149,7 @@ export interface UIKitColors {
145149
dateSeparator: ComponentColors<'DateSeparator'>;
146150
groupChannelPreview: ComponentColors<'GroupChannelPreview'>;
147151
profileCard: ComponentColors<'ProfileCard'>;
152+
reaction: ComponentColors<'Reaction'>;
148153
};
149154
}
150155

packages/uikit-react-native-foundation/src/ui/Badge/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Platform, StyleProp, View, ViewStyle } from 'react-native';
33

4-
import { truncatedBadgeCount } from '@sendbird/uikit-utils';
4+
import { truncatedCount } from '@sendbird/uikit-utils';
55

66
import Text from '../../components/Text';
77
import createStyleSheet from '../../styles/createStyleSheet';
@@ -29,7 +29,7 @@ const Badge = ({ count, maxCount, badgeColor, textColor, style, size = 'default'
2929
]}
3030
>
3131
<Text caption1 color={textColor ?? colors.ui.badge.default.none.text}>
32-
{truncatedBadgeCount(count, maxCount)}
32+
{truncatedCount(count, maxCount)}
3333
</Text>
3434
</View>
3535
);

0 commit comments

Comments
 (0)