Skip to content

Commit 207366e

Browse files
CRNS-49 and CRNS-50: Adding types for reaction picket
1 parent df5da89 commit 207366e

File tree

4 files changed

+81
-10
lines changed

4 files changed

+81
-10
lines changed

src/components/ReactionList.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { Text } from 'react-native';
33
import styled from '@stream-io/styled-components';
44
import { emojiData } from '../utils';
5+
import PropTypes from 'prop-types';
56

67
import leftTail from '../images/reactionlist/left-tail.png';
78
import leftCenter from '../images/reactionlist/left-center.png';
@@ -85,6 +86,14 @@ export class ReactionList extends React.PureComponent {
8586
super(props);
8687
}
8788

89+
static propTypes = {
90+
latestReactions: PropTypes.array,
91+
openReactionSelector: PropTypes.func,
92+
getTotalReactionCount: PropTypes.func,
93+
visible: PropTypes.bool,
94+
position: PropTypes.string,
95+
};
96+
8897
_renderReactions = (reactions) => {
8998
const reactionsByType = {};
9099
reactions.map((item) => {

src/components/ReactionPicker.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { View, Modal } from 'react-native';
33
import { themed } from '../styles/theme';
4+
import PropTypes from 'prop-types';
45

56
import styled from '@stream-io/styled-components';
67
import { Avatar } from './Avatar';
@@ -46,6 +47,20 @@ const ReactionCount = styled.Text`
4647
export const ReactionPicker = themed(
4748
class ReactionPicker extends React.PureComponent {
4849
static themePath = 'message.reactionPicker';
50+
51+
static propTypes = {
52+
hideReactionOwners: PropTypes.bool,
53+
reactionPickerVisible: PropTypes.bool,
54+
handleDismiss: PropTypes.func,
55+
handleReaction: PropTypes.func,
56+
latestReactions: PropTypes.array,
57+
reactionCounts: PropTypes.object,
58+
rpLeft: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
59+
rpTop: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
60+
rpRight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
61+
emojiData: PropTypes.array,
62+
};
63+
4964
constructor(props) {
5065
super(props);
5166
}

src/components/ReactionPickerWrapper.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
24
import { TouchableOpacity, Dimensions } from 'react-native';
35

46
import { ReactionPicker } from './ReactionPicker';
57

68
export class ReactionPickerWrapper extends React.PureComponent {
9+
static propTypes = {
10+
isMyMessage: PropTypes.func,
11+
message: PropTypes.object,
12+
offset: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
13+
handleReaction: PropTypes.func,
14+
emojiData: PropTypes.array,
15+
style: PropTypes.any,
16+
};
17+
718
constructor(props) {
819
super(props);
920
this.state = { reactionPickerVisible: false };

types/index.d.ts

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,14 @@ export interface AutoCompleteInputProps {
462462
}
463463

464464
export interface CardProps {
465-
title: string;
466-
title_link: string;
467-
og_scrape_url: string;
468-
image_url: string;
469-
thumb_url: string;
470-
text: string;
471-
type: string;
472-
alignment: 'right' | 'left';
465+
title?: string;
466+
title_link?: string;
467+
og_scrape_url?: string;
468+
image_url?: string;
469+
thumb_url?: string;
470+
text?: string;
471+
type?: string;
472+
alignment?: 'right' | 'left';
473473
onLongPress?: (event: GestureResponderEvent) => void;
474474
}
475475

@@ -484,7 +484,7 @@ export interface DateSeparatorProps {
484484
formatDate?(date: Date): string;
485485
}
486486
export interface EmptyStateIndicatorProps {
487-
listType: 'string';
487+
listType?: 'string';
488488
}
489489
export interface EventIndicatorProps {
490490
event: Client.Event;
@@ -547,13 +547,41 @@ export interface MessageSystemProps {
547547
}
548548

549549
export interface ReactionListProps {
550-
latestReactions: any;
550+
latestReactions: Client.ReactionResponse[];
551551
openReactionSelector?(event: GestureResponderEvent): void;
552552
getTotalReactionCount?(): string | number;
553553
visible: boolean;
554554
position: string;
555555
}
556556

557+
export interface ReactionPickerProps {
558+
hideReactionOwners: boolean;
559+
reactionPickerVisible: boolean;
560+
handleDismiss?(): void;
561+
handleReaction?(id: string): void;
562+
latestReactions: Client.ReactionResponse[];
563+
reactionCounts: { [key: string]: number };
564+
rpLeft: string | number;
565+
rpTop: string | number;
566+
rpRight: string | number;
567+
emojiData: Array<{
568+
icon: string;
569+
id: string;
570+
}>;
571+
}
572+
573+
export interface ReactionPickerWrapperProps {
574+
isMyMessage?(message: Client.MessageResponse): boolean;
575+
message: Client.MessageResponse;
576+
offset: string | number;
577+
handleReaction?(id: string): void;
578+
emojiData: Array<{
579+
icon: string;
580+
id: string;
581+
}>;
582+
style: object;
583+
}
584+
557585
export interface SpinnerProps {}
558586

559587
export interface SuggestionsProviderProps {
@@ -639,6 +667,14 @@ export class MessageSystem extends React.PureComponent<
639667
any
640668
> {}
641669
export class ReactionList extends React.PureComponent<ReactionListProps, any> {}
670+
export class ReactionPicker extends React.PureComponent<
671+
ReactionPickerProps,
672+
any
673+
> {}
674+
export class ReactionPickerWrapper extends React.PureComponent<
675+
ReactionPickerWrapperProps,
676+
any
677+
> {}
642678
export class Spinner extends React.PureComponent<SpinnerProps, any> {}
643679
export class SuggestionsProvider extends React.PureComponent<
644680
SuggestionsProviderProps,

0 commit comments

Comments
 (0)