| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | import { boolean, text } from '@storybook/addon-knobs'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 20:30:08 -04:00
										 |  |  | import { setupI18n } from '../../util/setupI18n'; | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | import enMessages from '../../../_locales/en/messages.json'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { ContactType, Props } from './SafetyNumberNotification'; | 
					
						
							|  |  |  | import { SafetyNumberNotification } from './SafetyNumberNotification'; | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const createContact = (props: Partial<ContactType>): ContactType => ({ | 
					
						
							|  |  |  |   id: '', | 
					
						
							|  |  |  |   title: text('contact title', props.title || ''), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<Props> = {}): Props => ({ | 
					
						
							|  |  |  |   i18n, | 
					
						
							|  |  |  |   contact: overrideProps.contact || ({} as ContactType), | 
					
						
							|  |  |  |   isGroup: boolean('isGroup', overrideProps.isGroup || false), | 
					
						
							| 
									
										
										
										
											2022-12-09 00:53:19 -05:00
										 |  |  |   toggleSafetyNumberModal: action('toggleSafetyNumberModal'), | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Conversation/SafetyNumberNotification', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupConversation(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     isGroup: true, | 
					
						
							|  |  |  |     contact: createContact({ | 
					
						
							|  |  |  |       title: 'Mr. Fire', | 
					
						
							|  |  |  |     }), | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <SafetyNumberNotification {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function DirectConversation(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     isGroup: false, | 
					
						
							|  |  |  |     contact: createContact({ | 
					
						
							|  |  |  |       title: 'Mr. Fire', | 
					
						
							|  |  |  |     }), | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <SafetyNumberNotification {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function LongNameInGroup(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     isGroup: true, | 
					
						
							|  |  |  |     contact: createContact({ | 
					
						
							|  |  |  |       title: '🐈⬛🍕🎂'.repeat(50), | 
					
						
							|  |  |  |     }), | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <SafetyNumberNotification {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | LongNameInGroup.story = { | 
					
						
							|  |  |  |   name: 'Long name in group', | 
					
						
							|  |  |  | }; |