| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { boolean, number } from '@storybook/addon-knobs'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { Props } from './ExpireTimer'; | 
					
						
							|  |  |  | import { ExpireTimer } from './ExpireTimer'; | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Conversation/ExpireTimer', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<Props> = {}): Props => ({ | 
					
						
							|  |  |  |   direction: overrideProps.direction || 'outgoing', | 
					
						
							|  |  |  |   expirationLength: number( | 
					
						
							|  |  |  |     'expirationLength', | 
					
						
							|  |  |  |     overrideProps.expirationLength || 30 * 1000 | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  |   expirationTimestamp: number( | 
					
						
							|  |  |  |     'expirationTimestamp', | 
					
						
							|  |  |  |     overrideProps.expirationTimestamp || Date.now() + 30 * 1000 | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  |   withImageNoCaption: boolean( | 
					
						
							|  |  |  |     'withImageNoCaption', | 
					
						
							|  |  |  |     overrideProps.withImageNoCaption || false | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  |   withSticker: boolean('withSticker', overrideProps.withSticker || false), | 
					
						
							|  |  |  |   withTapToViewExpired: boolean( | 
					
						
							|  |  |  |     'withTapToViewExpired', | 
					
						
							|  |  |  |     overrideProps.withTapToViewExpired || false | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export const _30Seconds = (): JSX.Element => { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | _30Seconds.story = { | 
					
						
							|  |  |  |   name: '30 seconds', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export const _2Minutes = (): JSX.Element => { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const twoMinutes = 60 * 1000 * 2; | 
					
						
							|  |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     expirationTimestamp: Date.now() + twoMinutes, | 
					
						
							|  |  |  |     expirationLength: twoMinutes, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | _2Minutes.story = { | 
					
						
							|  |  |  |   name: '2 minutes', | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function InProgress(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     expirationTimestamp: Date.now() + 15 * 1000, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Expired(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     expirationTimestamp: Date.now() - 30 * 1000, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Sticker(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     withSticker: true, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function TapToViewExpired(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     withTapToViewExpired: true, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function ImageNoCaption(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     withImageNoCaption: true, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div style={{ backgroundColor: 'darkgreen' }}> | 
					
						
							|  |  |  |       <ExpireTimer {...props} /> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Incoming(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     direction: 'incoming', | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div style={{ backgroundColor: 'darkgreen' }}> | 
					
						
							|  |  |  |       <ExpireTimer {...props} /> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function ExpirationTooFarOut(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 09:28:26 -07:00
										 |  |  |   const props = createProps({ | 
					
						
							|  |  |  |     expirationTimestamp: Date.now() + 150 * 1000, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <ExpireTimer {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |