|
16 | 16 |
|
17 | 17 | interface BackButton { |
18 | 18 | label: string; |
| 19 | + href?: string; |
19 | 20 | } |
20 | 21 |
|
21 | 22 | interface Breadcrumb { |
|
64 | 65 |
|
65 | 66 | function handleTabSelect(href: string) { |
66 | 67 | dropdownOpen = false; |
67 | | - goto(href); |
| 68 | + goto(href, { replaceState: true }); |
68 | 69 | } |
69 | 70 | </script> |
70 | 71 |
|
|
73 | 74 | {:else if useMobileMode} |
74 | 75 | <!-- Mobile: Custom dropdown with icons --> |
75 | 76 | <div class="border-b border-neutral-200 py-3 dark:border-neutral-800"> |
76 | | - <div class="relative" bind:this={triggerEl} use:clickOutside={() => (dropdownOpen = false)}> |
77 | | - <button |
78 | | - type="button" |
79 | | - on:click={() => (dropdownOpen = !dropdownOpen)} |
80 | | - class="flex w-full items-center justify-between gap-2 rounded-xl border border-neutral-300 bg-white px-3 py-2 text-sm font-medium text-neutral-900 transition-colors hover:bg-neutral-50 dark:border-neutral-700/60 dark:bg-neutral-800/50 dark:text-neutral-100 dark:hover:bg-neutral-700" |
81 | | - > |
| 77 | + <div class="flex items-center gap-2"> |
| 78 | + <div class="relative flex-1" bind:this={triggerEl} use:clickOutside={() => (dropdownOpen = false)}> |
| 79 | + <button |
| 80 | + type="button" |
| 81 | + on:click={() => (dropdownOpen = !dropdownOpen)} |
| 82 | + class="flex w-full items-center justify-between gap-2 rounded-xl border border-neutral-300 bg-white px-3 py-2 text-sm font-medium text-neutral-900 transition-colors hover:bg-neutral-50 dark:border-neutral-700/60 dark:bg-neutral-800/50 dark:text-neutral-100 dark:hover:bg-neutral-700" |
| 83 | + > |
82 | 84 | <span class="flex items-center gap-2"> |
83 | 85 | {#if activeTab?.icon} |
84 | 86 | <svelte:component this={activeTab.icon} size={16} class="text-accent-500" /> |
|
104 | 106 | </Dropdown> |
105 | 107 | {/if} |
106 | 108 | </div> |
| 109 | + {#if backButton} |
| 110 | + <button |
| 111 | + type="button" |
| 112 | + on:click={() => history.back()} |
| 113 | + class="flex cursor-pointer items-center gap-1.5 rounded-xl border border-neutral-300 bg-white px-3 py-2 text-sm font-medium text-neutral-600 transition-colors hover:bg-neutral-50 hover:text-neutral-900 dark:border-neutral-700/60 dark:bg-neutral-800/50 dark:text-neutral-400 dark:hover:bg-neutral-700 dark:hover:text-neutral-100" |
| 114 | + > |
| 115 | + <ArrowLeft size={14} /> |
| 116 | + {backButton.label} |
| 117 | + </button> |
| 118 | + {/if} |
| 119 | + </div> |
107 | 120 | </div> |
108 | 121 | {:else} |
109 | 122 | <!-- Desktop: Tab bar --> |
110 | 123 | <div class="border-b border-neutral-200 dark:border-neutral-800"> |
111 | 124 | <nav class="-mb-px flex items-center justify-between gap-2" aria-label="Tabs"> |
112 | 125 | <div class="flex gap-2"> |
113 | 126 | {#each tabs as tab (tab.href)} |
114 | | - <a |
115 | | - href={tab.href} |
116 | | - data-sveltekit-preload-data="tap" |
117 | | - class="flex items-center gap-2 border-b-2 px-4 py-3 text-sm font-medium transition-colors {tab.active |
| 127 | + <button |
| 128 | + type="button" |
| 129 | + on:click={() => handleTabSelect(tab.href)} |
| 130 | + class="flex cursor-pointer items-center gap-2 border-b-2 px-4 py-3 text-sm font-medium transition-colors {tab.active |
118 | 131 | ? 'border-accent-600 text-accent-600 dark:border-accent-500 dark:text-accent-500' |
119 | 132 | : 'border-transparent text-neutral-600 hover:border-neutral-300 hover:text-neutral-900 dark:text-neutral-400 dark:hover:border-neutral-700 dark:hover:text-neutral-50'}" |
120 | 133 | > |
121 | 134 | {#if tab.icon} |
122 | 135 | <svelte:component this={tab.icon} size={16} /> |
123 | 136 | {/if} |
124 | 137 | {tab.label} |
125 | | - </a> |
| 138 | + </button> |
126 | 139 | {/each} |
127 | 140 |
|
128 | 141 | <!-- Actions slot for custom action tabs (like Add Instance) --> |
|
144 | 157 | <button |
145 | 158 | type="button" |
146 | 159 | on:click={() => history.back()} |
147 | | - class="flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100" |
| 160 | + class="flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100" |
148 | 161 | > |
149 | 162 | <ArrowLeft size={14} /> |
150 | 163 | {backButton.label} |
|
0 commit comments