| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  | import { | 
					
						
							|  |  |  |   customElement, | 
					
						
							|  |  |  |   html, | 
					
						
							|  |  |  |   DeesElement, | 
					
						
							|  |  |  |   property, | 
					
						
							| 
									
										
										
										
											2023-08-07 20:02:18 +02:00
										 |  |  |   type TemplateResult, | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |   cssManager, | 
					
						
							|  |  |  |   css, | 
					
						
							| 
									
										
										
										
											2023-08-07 20:02:18 +02:00
										 |  |  |   type CSSResult, | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |   unsafeCSS, | 
					
						
							| 
									
										
										
										
											2023-08-07 19:13:29 +02:00
										 |  |  | } from '@design.estate/dees-element'; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 19:13:29 +02:00
										 |  |  | import * as domtools from '@design.estate/dees-domtools'; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | declare global { | 
					
						
							|  |  |  |   interface HTMLElementTagNameMap { | 
					
						
							|  |  |  |     'dees-spinner': DeesSpinner; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @customElement('dees-spinner') | 
					
						
							|  |  |  | export class DeesSpinner extends DeesElement { | 
					
						
							|  |  |  |   public static demo = () => html`
 | 
					
						
							|  |  |  |     <dees-spinner></dees-spinner> | 
					
						
							|  |  |  |     <dees-spinner status="success"></dees-spinner> | 
					
						
							|  |  |  |     <dees-spinner status="error"></dees-spinner> | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |     <dees-spinner size=${64} status="success"></dees-spinner> | 
					
						
							|  |  |  |     <dees-spinner .size=${64} status="error"></dees-spinner> | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |   `;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @property({ | 
					
						
							|  |  |  |     type: Number, | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  |   public size = 20; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |   @property({ | 
					
						
							|  |  |  |     type: String, | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  |   public bnw: boolean = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |   @property() | 
					
						
							|  |  |  |   public status: 'normal' | 'pending' | 'success' | 'error' = 'normal'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     super(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public static styles = [ | 
					
						
							|  |  |  |     cssManager.defaultStyles, | 
					
						
							|  |  |  |     css`
 | 
					
						
							|  |  |  |       :host { | 
					
						
							|  |  |  |         display: block; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       #loading { | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |         position: relative; | 
					
						
							| 
									
										
										
										
											2021-08-27 14:25:44 +02:00
										 |  |  |         transition: none; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |         display: flex; | 
					
						
							|  |  |  |         justify-content: center; | 
					
						
							|  |  |  |         align-content: center; | 
					
						
							|  |  |  |         background: #8bc34a00; | 
					
						
							|  |  |  |         border: 3px solid ${cssManager.bdTheme('rgba(0, 0, 0, 0.1)', 'rgba(255, 255, 255, 0.3)')}; | 
					
						
							|  |  |  |         border-radius: 50%; | 
					
						
							|  |  |  |         border-top-color: ${cssManager.bdTheme('#333', '#fff')}; | 
					
						
							|  |  |  |         animation: spin 1s ease-in-out infinite; | 
					
						
							|  |  |  |         -webkit-animation: spin 1s ease-in-out infinite; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       #loading.success { | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |         border: none; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |         border-radius: 50%; | 
					
						
							|  |  |  |         animation: none; | 
					
						
							|  |  |  |         -webkit-animation: none; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       #loading.error { | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |         border: none; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |         border-radius: 50%; | 
					
						
							|  |  |  |         animation: none; | 
					
						
							|  |  |  |         -webkit-animation: none; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       @keyframes spin { | 
					
						
							|  |  |  |         to { | 
					
						
							|  |  |  |           -webkit-transform: rotate(360deg); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       @-webkit-keyframes spin { | 
					
						
							|  |  |  |         to { | 
					
						
							|  |  |  |           -webkit-transform: rotate(360deg); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |       dees-icon { | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |         position: absolute; | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |         height: 100%; | 
					
						
							|  |  |  |         width: 100%; | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     return html`
 | 
					
						
							|  |  |  |       <style> | 
					
						
							|  |  |  |         #loading { | 
					
						
							|  |  |  |           width: ${this.size}px; | 
					
						
							|  |  |  |           height: ${this.size}px; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-01-13 00:46:17 +01:00
										 |  |  |         #loading.success { | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |           color: ${cssManager.bdTheme(this.bnw ? '#333': `#8bc34a`, this.bnw ? '#fff' : `#8bc34a`)}; | 
					
						
							|  |  |  |            | 
					
						
							| 
									
										
										
										
											2023-01-13 00:46:17 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         #loading.error { | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |           color: ${cssManager.bdTheme(this.bnw ? '#333': `#e64a19`, this.bnw ? '#fff' : `#e64a19`)}; | 
					
						
							| 
									
										
										
										
											2023-01-13 00:46:17 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |         dees-icon { | 
					
						
							| 
									
										
										
										
											2023-01-13 01:17:08 +01:00
										 |  |  |           font-size: ${this.size}px; | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |       </style> | 
					
						
							|  |  |  |       <div class="${this.status}" id="loading"> | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |         ${(() => { | 
					
						
							|  |  |  |           if (this.status === 'success') { | 
					
						
							| 
									
										
										
										
											2025-06-30 12:57:13 +00:00
										 |  |  |             return html`<dees-icon style="transform: translateX(1%) translateY(3%);" .icon=${'fa:circle-check'}></dees-icon>`; | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |           } else if (this.status === 'error') { | 
					
						
							| 
									
										
										
										
											2025-06-30 12:57:13 +00:00
										 |  |  |             return  html`<dees-icon .icon=${'fa:circle-xmark'}></dees-icon>`; | 
					
						
							| 
									
										
										
										
											2023-01-13 00:30:56 +01:00
										 |  |  |           } | 
					
						
							|  |  |  |         })()} | 
					
						
							| 
									
										
										
										
											2021-08-27 13:38:08 +02:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     `;
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |