| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | import { storiesOf } from '@storybook/react'; | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { CallingParticipantsList, PropsType } from './CallingParticipantsList'; | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  | import { Colors } from '../types/Colors'; | 
					
						
							|  |  |  | import { GroupCallRemoteParticipantType } from '../types/Calling'; | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  | import { setup as setupI18n } from '../../js/modules/i18n'; | 
					
						
							|  |  |  | import enMessages from '../../_locales/en/messages.json'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  | function createParticipant( | 
					
						
							|  |  |  |   participantProps: Partial<GroupCallRemoteParticipantType> | 
					
						
							|  |  |  | ): GroupCallRemoteParticipantType { | 
					
						
							|  |  |  |   const randomColor = Math.floor(Math.random() * Colors.length - 1); | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     avatarPath: participantProps.avatarPath, | 
					
						
							|  |  |  |     color: Colors[randomColor], | 
					
						
							|  |  |  |     hasRemoteAudio: Boolean(participantProps.hasRemoteAudio), | 
					
						
							|  |  |  |     hasRemoteVideo: Boolean(participantProps.hasRemoteVideo), | 
					
						
							|  |  |  |     isSelf: Boolean(participantProps.isSelf), | 
					
						
							|  |  |  |     profileName: participantProps.title, | 
					
						
							|  |  |  |     title: String(participantProps.title), | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({ | 
					
						
							|  |  |  |   i18n, | 
					
						
							|  |  |  |   onClose: action('on-close'), | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |   participants: overrideProps.participants || [], | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const story = storiesOf('Components/CallingParticipantsList', module); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  | story.add('No one', () => { | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  |   return <CallingParticipantsList {...props} />; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  | story.add('Solo Call', () => { | 
					
						
							|  |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     participants: [ | 
					
						
							|  |  |  |       createParticipant({ | 
					
						
							|  |  |  |         title: 'Bardock', | 
					
						
							|  |  |  |       }), | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <CallingParticipantsList {...props} />; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  | story.add('Many Participants', () => { | 
					
						
							|  |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     participants: [ | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       createParticipant({ | 
					
						
							|  |  |  |         isSelf: true, | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |         title: 'Son Goku', | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       }), | 
					
						
							|  |  |  |       createParticipant({ | 
					
						
							|  |  |  |         hasRemoteAudio: true, | 
					
						
							|  |  |  |         hasRemoteVideo: true, | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |         title: 'Rage Trunks', | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       }), | 
					
						
							|  |  |  |       createParticipant({ | 
					
						
							|  |  |  |         hasRemoteAudio: true, | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |         title: 'Prince Vegeta', | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       }), | 
					
						
							|  |  |  |       createParticipant({ | 
					
						
							|  |  |  |         hasRemoteAudio: true, | 
					
						
							|  |  |  |         hasRemoteVideo: true, | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |         title: 'Goku Black', | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       }), | 
					
						
							|  |  |  |       createParticipant({ | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |         title: 'Supreme Kai Zamasu', | 
					
						
							| 
									
										
										
										
											2020-11-17 10:07:53 -05:00
										 |  |  |       }), | 
					
						
							| 
									
										
										
										
											2020-10-15 15:53:21 -04:00
										 |  |  |     ], | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return <CallingParticipantsList {...props} />; | 
					
						
							|  |  |  | }); |