| 
									
										
										
										
											2024-04-21 14:18:06 -04:00
										 |  |  | import {LitElement, html, unsafeHTML} from './lit-all.min.js'; | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | import {styles, generate_theme} from './tf-styles.js'; | 
					
						
							| 
									
										
										
										
											2024-04-21 14:18:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | class TfReactionsModalElement extends LitElement { | 
					
						
							|  |  |  | 	static get properties() { | 
					
						
							|  |  |  | 		return { | 
					
						
							|  |  |  | 			users: {type: Object}, | 
					
						
							|  |  |  | 			votes: {type: Array}, | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	static styles = styles; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							|  |  |  | 		super(); | 
					
						
							|  |  |  | 		this.votes = []; | 
					
						
							|  |  |  | 		this.users = {}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	clear() { | 
					
						
							|  |  |  | 		this.votes = []; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	render() { | 
					
						
							|  |  |  | 		let self = this; | 
					
						
							| 
									
										
										
										
											2024-04-24 19:23:13 -04:00
										 |  |  | 		return this.votes?.length | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 			? html` <style>
 | 
					
						
							|  |  |  | 						${generate_theme()} | 
					
						
							|  |  |  | 					</style> | 
					
						
							| 
									
										
										
										
											2024-10-23 15:38:49 -04:00
										 |  |  | 					<div | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 						class="w3-modal w3-animate-opacity" | 
					
						
							|  |  |  | 						style="display: block; box-sizing: border-box; z-index: 10" | 
					
						
							|  |  |  | 						@click=${this.clear} | 
					
						
							| 
									
										
										
										
											2024-10-23 15:38:49 -04:00
										 |  |  | 					> | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 						<div | 
					
						
							|  |  |  | 							class="w3-modal-content w3-card-4 w3-theme-d1" | 
					
						
							|  |  |  | 							onclick="event.stopPropagation()" | 
					
						
							|  |  |  | 						> | 
					
						
							|  |  |  | 							<div class="w3-container w3-padding"> | 
					
						
							|  |  |  | 								<header class="w3-container"> | 
					
						
							|  |  |  | 									<h2>Reactions</h2> | 
					
						
							|  |  |  | 									<span | 
					
						
							|  |  |  | 										class="w3-button w3-display-topright" | 
					
						
							|  |  |  | 										@click=${this.clear} | 
					
						
							|  |  |  | 										>×</span | 
					
						
							|  |  |  | 									> | 
					
						
							|  |  |  | 								</header> | 
					
						
							|  |  |  | 								<ul class="w3-theme-dark w3-container w3-ul"> | 
					
						
							|  |  |  | 									${this.votes | 
					
						
							|  |  |  | 										.sort((x, y) => y.timestamp - x.timestamp) | 
					
						
							|  |  |  | 										.map( | 
					
						
							|  |  |  | 											(x) => html`
 | 
					
						
							|  |  |  | 												<li | 
					
						
							|  |  |  | 													style="display: flex; flex-direction: row; gap: 4px" | 
					
						
							| 
									
										
										
										
											2025-04-20 09:35:39 -04:00
										 |  |  | 												> | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 													<span style="flex-basis: 3em" | 
					
						
							|  |  |  | 														>${x?.content?.vote?.expression}</span | 
					
						
							|  |  |  | 													> | 
					
						
							|  |  |  | 													<tf-user | 
					
						
							| 
									
										
										
										
											2025-10-26 12:19:58 -04:00
										 |  |  | 														style="flex: 1 1; overflow: hidden" | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 														id=${x.author} | 
					
						
							|  |  |  | 														.users=${this.users} | 
					
						
							|  |  |  | 													></tf-user> | 
					
						
							|  |  |  | 													<span | 
					
						
							|  |  |  | 														style="flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis" | 
					
						
							|  |  |  | 														>${new Date(x?.timestamp).toLocaleString()}</span | 
					
						
							|  |  |  | 													> | 
					
						
							|  |  |  | 												</li> | 
					
						
							|  |  |  | 											`
 | 
					
						
							|  |  |  | 										)} | 
					
						
							|  |  |  | 								</ul> | 
					
						
							|  |  |  | 								<footer class="w3-container w3-padding"> | 
					
						
							|  |  |  | 									<button class="w3-button" @click=${this.clear}>Close</button> | 
					
						
							|  |  |  | 								</footer> | 
					
						
							|  |  |  | 							</div> | 
					
						
							| 
									
										
										
										
											2024-04-24 19:23:13 -04:00
										 |  |  | 						</div> | 
					
						
							| 
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 |  |  | 					</div>` | 
					
						
							| 
									
										
										
										
											2024-04-24 19:23:13 -04:00
										 |  |  | 			: undefined; | 
					
						
							| 
									
										
										
										
											2024-04-21 14:18:06 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | customElements.define('tf-reactions-modal', TfReactionsModalElement); |