| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { Props } from './ReactionViewer'; | 
					
						
							|  |  |  | import { ReactionViewer } from './ReactionViewer'; | 
					
						
							| 
									
										
										
										
											2021-09-17 20:30:08 -04:00
										 |  |  | import { setupI18n } from '../../util/setupI18n'; | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | import enMessages from '../../../_locales/en/messages.json'; | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  | import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; | 
					
						
							| 
									
										
										
										
											2021-11-17 15:11:46 -06:00
										 |  |  | import { ThemeType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Conversation/ReactionViewer', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<Props> = {}): Props => ({ | 
					
						
							| 
									
										
										
										
											2021-11-17 15:11:46 -06:00
										 |  |  |   getPreferredBadge: () => undefined, | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |   i18n, | 
					
						
							|  |  |  |   onClose: action('onClose'), | 
					
						
							|  |  |  |   pickedReaction: overrideProps.pickedReaction, | 
					
						
							|  |  |  |   reactions: overrideProps.reactions || [], | 
					
						
							|  |  |  |   style: overrideProps.style, | 
					
						
							| 
									
										
										
										
											2021-11-17 15:11:46 -06:00
										 |  |  |   theme: ThemeType.light, | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function AllReactions(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     reactions: [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							|  |  |  |         timestamp: 1, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552671', | 
					
						
							|  |  |  |           phoneNumber: '+14155552671', | 
					
						
							|  |  |  |           profileName: 'Ameila Briggs', | 
					
						
							|  |  |  |           title: 'Amelia', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							|  |  |  |         timestamp: 2, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552672', | 
					
						
							|  |  |  |           name: 'Adam Burrel', | 
					
						
							|  |  |  |           title: 'Adam', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							|  |  |  |         timestamp: 3, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552673', | 
					
						
							|  |  |  |           name: 'Rick Owens', | 
					
						
							|  |  |  |           title: 'Rick', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							|  |  |  |         timestamp: 4, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552674', | 
					
						
							|  |  |  |           name: 'Bojack Horseman', | 
					
						
							|  |  |  |           title: 'Bojack', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '👍', | 
					
						
							|  |  |  |         timestamp: 9, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552678', | 
					
						
							|  |  |  |           phoneNumber: '+14155552678', | 
					
						
							|  |  |  |           profileName: 'Adam Burrel', | 
					
						
							|  |  |  |           title: 'Adam', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '👎', | 
					
						
							|  |  |  |         timestamp: 10, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552673', | 
					
						
							|  |  |  |           name: 'Rick Owens', | 
					
						
							|  |  |  |           title: 'Rick', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '😂', | 
					
						
							|  |  |  |         timestamp: 11, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552674', | 
					
						
							|  |  |  |           name: 'Bojack Horseman', | 
					
						
							|  |  |  |           title: 'Bojack', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '😮', | 
					
						
							|  |  |  |         timestamp: 12, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552675', | 
					
						
							|  |  |  |           name: 'Cayce Pollard', | 
					
						
							|  |  |  |           title: 'Cayce', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '😢', | 
					
						
							|  |  |  |         timestamp: 13, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552676', | 
					
						
							|  |  |  |           name: 'Foo McBarrington', | 
					
						
							|  |  |  |           title: 'Foo', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '😡', | 
					
						
							|  |  |  |         timestamp: 14, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552676', | 
					
						
							|  |  |  |           name: 'Foo McBarrington', | 
					
						
							|  |  |  |           title: 'Foo', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <ReactionViewer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function PickedReaction(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     pickedReaction: '❤️', | 
					
						
							|  |  |  |     reactions: [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552671', | 
					
						
							|  |  |  |           name: 'Amelia Briggs', | 
					
						
							|  |  |  |           isMe: true, | 
					
						
							|  |  |  |           title: 'Amelia', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |         timestamp: Date.now(), | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '👍', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552671', | 
					
						
							|  |  |  |           phoneNumber: '+14155552671', | 
					
						
							|  |  |  |           profileName: 'Joel Ferrari', | 
					
						
							|  |  |  |           title: 'Joel', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |         timestamp: Date.now(), | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <ReactionViewer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function PickedMissingReaction(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     pickedReaction: '😡', | 
					
						
							|  |  |  |     reactions: [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '❤️', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552671', | 
					
						
							|  |  |  |           name: 'Amelia Briggs', | 
					
						
							|  |  |  |           isMe: true, | 
					
						
							|  |  |  |           title: 'Amelia', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |         timestamp: Date.now(), | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         emoji: '👍', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |           id: '+14155552671', | 
					
						
							|  |  |  |           phoneNumber: '+14155552671', | 
					
						
							|  |  |  |           profileName: 'Joel Ferrari', | 
					
						
							|  |  |  |           title: 'Joel', | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |         }), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:28:50 -07:00
										 |  |  |         timestamp: Date.now(), | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <ReactionViewer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-02 13:05:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const skinTones = [ | 
					
						
							|  |  |  |   '\u{1F3FB}', | 
					
						
							|  |  |  |   '\u{1F3FC}', | 
					
						
							|  |  |  |   '\u{1F3FD}', | 
					
						
							|  |  |  |   '\u{1F3FE}', | 
					
						
							|  |  |  |   '\u{1F3FF}', | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | const thumbsUpHands = skinTones.map(skinTone => `👍${skinTone}`); | 
					
						
							|  |  |  | const okHands = skinTones.map(skinTone => `👌${skinTone}`).reverse(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const createReaction = ( | 
					
						
							|  |  |  |   emoji: string, | 
					
						
							|  |  |  |   name: string, | 
					
						
							|  |  |  |   timestamp = Date.now() | 
					
						
							|  |  |  | ) => ({ | 
					
						
							|  |  |  |   emoji, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |   from: getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2020-10-02 13:05:09 -07:00
										 |  |  |     id: '+14155552671', | 
					
						
							|  |  |  |     name, | 
					
						
							|  |  |  |     title: name, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |   }), | 
					
						
							| 
									
										
										
										
											2020-10-02 13:05:09 -07:00
										 |  |  |   timestamp, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function ReactionSkinTones(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-10-02 13:05:09 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     pickedReaction: '😡', | 
					
						
							|  |  |  |     reactions: [ | 
					
						
							|  |  |  |       ...thumbsUpHands.map((emoji, n) => | 
					
						
							|  |  |  |         createReaction(emoji, `Thumbs Up ${n + 1}`, Date.now() + n * 1000) | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       ...okHands.map((emoji, n) => | 
					
						
							|  |  |  |         createReaction(emoji, `Ok Hand ${n + 1}`, Date.now() + n * 1000) | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <ReactionViewer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |