| 
									
										
										
										
											2023-04-06 01:33:08 +02:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Thin wrapper around 'TabGroup' which binds the state | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2023-04-06 01:33:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     import {Tab, TabGroup, TabList, TabPanel, TabPanels} from "@rgossiaux/svelte-headlessui"; | 
					
						
							|  |  |  |     import {UIEventSource} from "../../Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2023-04-06 01:33:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     export let tab: UIEventSource<number>; | 
					
						
							|  |  |  |     let tabElements: HTMLElement[] = []; | 
					
						
							|  |  |  |     $: tabElements[$tab]?.click(); | 
					
						
							|  |  |  |     $: { | 
					
						
							|  |  |  |         if (tabElements[tab.data]) { | 
					
						
							|  |  |  |             window.setTimeout(() => tabElements[tab.data].click(), 50) | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-04-06 01:33:08 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  | <div class="tabbedgroup w-full h-full"> | 
					
						
							|  |  |  |     <TabGroup class="h-full w-full flex flex-col" defaultIndex={1} | 
					
						
							|  |  |  |               on:change={(e) =>{if(e.detail >= 0){tab.setData( e.detail); }} }> | 
					
						
							| 
									
										
										
										
											2023-05-11 02:17:41 +02:00
										 |  |  |         <div class="interactive flex items-center justify-between sticky top-0"> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |             <TabList class="flex flex-wrap"> | 
					
						
							|  |  |  |                 {#if $$slots.title1} | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |                     <Tab class={({selected}) => "tab "+(selected ? "primary" : "")}> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |                         <div bind:this={tabElements[0]} class="flex"> | 
					
						
							|  |  |  |                             <slot name="title0"> | 
					
						
							|  |  |  |                                 Tab 0 | 
					
						
							|  |  |  |                             </slot> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </Tab> | 
					
						
							|  |  |  |                 {/if} | 
					
						
							|  |  |  |                 {#if $$slots.title1} | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |                     <Tab class={({selected}) => "tab "+(selected ? "primary" : "")}> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |                         <div bind:this={tabElements[1]} class="flex"> | 
					
						
							|  |  |  |                             <slot name="title1"/> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </Tab> | 
					
						
							|  |  |  |                 {/if} | 
					
						
							|  |  |  |                 {#if $$slots.title2} | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |                     <Tab class={({selected}) => "tab "+(selected ? "primary" : "")}> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |                         <div bind:this={tabElements[2]} class="flex"> | 
					
						
							|  |  |  |                             <slot name="title2"/> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </Tab> | 
					
						
							|  |  |  |                 {/if} | 
					
						
							|  |  |  |                 {#if $$slots.title3} | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |                     <Tab class={({selected}) => "tab "+(selected ? "primary" : "")}> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |                         <div bind:this={tabElements[3]} class="flex"> | 
					
						
							|  |  |  |                             <slot name="title3"/> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </Tab> | 
					
						
							|  |  |  |                 {/if} | 
					
						
							|  |  |  |                 {#if $$slots.title4} | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |                     <Tab class={({selected}) => "tab "+(selected ? "primary" : "")}> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |                         <div bind:this={tabElements[4]} class="flex"> | 
					
						
							|  |  |  |                             <slot name="title4"/> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </Tab> | 
					
						
							|  |  |  |                 {/if} | 
					
						
							|  |  |  |             </TabList> | 
					
						
							|  |  |  |             <slot name="post-tablist"/> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <div class="overflow-y-auto normal-background"> | 
					
						
							| 
									
										
										
										
											2023-04-21 16:02:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |             <TabPanels defaultIndex={$tab}> | 
					
						
							|  |  |  |                 <TabPanel> | 
					
						
							|  |  |  |                     <slot name="content0"> | 
					
						
							|  |  |  |                         <div>Empty</div> | 
					
						
							|  |  |  |                     </slot> | 
					
						
							|  |  |  |                 </TabPanel> | 
					
						
							|  |  |  |                 <TabPanel> | 
					
						
							|  |  |  |                     <slot name="content1"/> | 
					
						
							|  |  |  |                 </TabPanel> | 
					
						
							|  |  |  |                 <TabPanel> | 
					
						
							|  |  |  |                     <slot name="content2"/> | 
					
						
							|  |  |  |                 </TabPanel> | 
					
						
							|  |  |  |                 <TabPanel> | 
					
						
							|  |  |  |                     <slot name="content3"/> | 
					
						
							|  |  |  |                 </TabPanel> | 
					
						
							|  |  |  |                 <TabPanel> | 
					
						
							|  |  |  |                     <slot name="content4"/> | 
					
						
							|  |  |  |                 </TabPanel> | 
					
						
							|  |  |  |             </TabPanels> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     </TabGroup> | 
					
						
							|  |  |  | </div> | 
					
						
							| 
									
										
										
										
											2023-04-21 16:02:36 +02:00
										 |  |  | <style> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     .tabbedgroup { | 
					
						
							|  |  |  |         max-height: 100vh; | 
					
						
							|  |  |  |         height: 100%; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-08 01:55:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     :global(.tab) { | 
					
						
							|  |  |  |         margin: 0.25rem; | 
					
						
							|  |  |  |         padding: 0.25rem; | 
					
						
							|  |  |  |         padding-left: 0.75rem; | 
					
						
							|  |  |  |         padding-right: 0.75rem; | 
					
						
							|  |  |  |         border-radius: 1rem; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     :global(.tab .flex) { | 
					
						
							|  |  |  |         align-items: center; | 
					
						
							|  |  |  |         gap: 0.25rem; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     :global(.tab span|div) { | 
					
						
							|  |  |  |         align-items: center; | 
					
						
							|  |  |  |         gap: 0.25rem; | 
					
						
							|  |  |  |         display: flex; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-08 01:55:21 +02:00
										 |  |  |     :global(.tab-selected svg) { | 
					
						
							|  |  |  |         fill: var(--catch-detail-color-contrast); | 
					
						
							| 
									
										
										
										
											2023-04-21 16:02:36 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |     :global(.tab-unselected) { | 
					
						
							| 
									
										
										
										
											2023-05-08 22:38:02 +02:00
										 |  |  |         background-color: var(--background-color) !important; | 
					
						
							|  |  |  |         color: var(--foreground-color) !important; | 
					
						
							| 
									
										
										
										
											2023-04-21 16:02:36 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | </style> |