| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-11 12:06:43 -07:00
										 |  |  | import type { Meta } from '@storybook/react'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { PropsType } from './ErrorModal'; | 
					
						
							|  |  |  | import { ErrorModal } from './ErrorModal'; | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 20:30:08 -04:00
										 |  |  | import { setupI18n } from '../util/setupI18n'; | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  | import enMessages from '../../_locales/en/messages.json'; | 
					
						
							| 
									
										
										
										
											2024-02-22 13:19:50 -08:00
										 |  |  | import { ButtonVariant } from './Button'; | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({ | 
					
						
							| 
									
										
										
										
											2024-02-22 13:19:50 -08:00
										 |  |  |   buttonVariant: overrideProps.buttonVariant ?? undefined, | 
					
						
							| 
									
										
										
										
											2023-10-11 12:06:43 -07:00
										 |  |  |   description: overrideProps.description ?? '', | 
					
						
							| 
									
										
										
										
											2024-02-22 13:19:50 -08:00
										 |  |  |   title: overrideProps.title ?? '', | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |   i18n, | 
					
						
							|  |  |  |   onClose: action('onClick'), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/ErrorModal', | 
					
						
							| 
									
										
										
										
											2023-10-11 12:06:43 -07:00
										 |  |  |   argTypes: {}, | 
					
						
							|  |  |  |   args: {}, | 
					
						
							|  |  |  | } satisfies Meta<PropsType>; | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Normal(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |   return <ErrorModal {...createProps()} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-22 13:19:50 -08:00
										 |  |  | export function PrimaryButton(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <ErrorModal {...createProps({ buttonVariant: ButtonVariant.Primary })} /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function CustomStrings(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-10-06 10:06:34 -07:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <ErrorModal | 
					
						
							|  |  |  |       {...createProps({ | 
					
						
							|  |  |  |         title: 'Real bad!', | 
					
						
							|  |  |  |         description: 'Just avoid that next time, kay?', | 
					
						
							|  |  |  |       })} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |