| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { select, text } from '@storybook/addon-knobs'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { Props } from './Spinner'; | 
					
						
							|  |  |  | import { Spinner, SpinnerDirections, SpinnerSvgSizes } from './Spinner'; | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Spinner', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const createProps = (overrideProps: Partial<Props> = {}): Props => ({ | 
					
						
							|  |  |  |   size: text('size', overrideProps.size || ''), | 
					
						
							|  |  |  |   svgSize: select( | 
					
						
							|  |  |  |     'svgSize', | 
					
						
							|  |  |  |     SpinnerSvgSizes.reduce((m, s) => ({ ...m, [s]: s }), {}), | 
					
						
							|  |  |  |     overrideProps.svgSize || 'normal' | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  |   direction: select( | 
					
						
							|  |  |  |     'direction', | 
					
						
							|  |  |  |     SpinnerDirections.reduce((d, s) => ({ ...d, [s]: s }), {}), | 
					
						
							|  |  |  |     overrideProps.direction | 
					
						
							|  |  |  |   ), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Normal(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return <Spinner {...props} />; | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function SvgSizes(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <> | 
					
						
							|  |  |  |       {SpinnerSvgSizes.map(svgSize => ( | 
					
						
							|  |  |  |         <Spinner key={svgSize} {...props} svgSize={svgSize} /> | 
					
						
							|  |  |  |       ))} | 
					
						
							|  |  |  |     </> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | SvgSizes.story = { | 
					
						
							|  |  |  |   name: 'SVG Sizes', | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function Directions(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-08-21 15:04:19 -07:00
										 |  |  |   const props = createProps(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <> | 
					
						
							|  |  |  |       {SpinnerDirections.map(direction => ( | 
					
						
							|  |  |  |         <Spinner key={direction} {...props} direction={direction} /> | 
					
						
							|  |  |  |       ))} | 
					
						
							|  |  |  |     </> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |