|
1 | 1 | <script lang="ts"> |
2 | 2 | import { onMount } from "svelte"; |
3 | | - import type { PackDetails, SongDetails, FocusedSong } from "../../lib/types"; |
4 | | - import { filterSongs } from '../../lib/utils'; |
| 3 | + import type { |
| 4 | + PackDetails, |
| 5 | + SongDetails, |
| 6 | + FocusedSong, |
| 7 | + } from "../../lib/types"; |
| 8 | + import { filterSongs } from "../../lib/utils"; |
5 | 9 | import Search from "./Search.svelte"; |
6 | 10 |
|
7 | 11 | export let currentIndex: number; |
|
44 | 48 | }); |
45 | 49 |
|
46 | 50 | // updates CSS to show focus on the current element |
47 | | - async function updateFocus( |
48 | | - focusedData: PackDetails | SongDetails |
49 | | - ) { |
50 | | - focusedSong.title = focusedData?.name ? focusedData.name : focusedData.title; |
| 51 | + async function updateFocus(focusedData: PackDetails | SongDetails) { |
| 52 | + focusedSong.title = focusedData?.name |
| 53 | + ? focusedData.name |
| 54 | + : focusedData.title; |
51 | 55 | focusedSong.banner = focusedData?.banner || ""; |
52 | 56 | focusedSong.artist = focusedData?.artist ? focusedData.artist : ""; |
53 | 57 | focusedSong.charts = focusedData?.charts ? focusedData.charts : []; |
|
147 | 151 | } |
148 | 152 |
|
149 | 153 | const handleHover = (event: MouseEvent) => { |
150 | | - console.log("hovering"); |
151 | 154 | if (scrollable.length === 0) { |
152 | 155 | return; |
153 | 156 | } |
|
168 | 171 | id="packs" |
169 | 172 | class="w-screen md:w-1/2 h-full flex flex-col bg-navy z-1 overflow-y-auto" |
170 | 173 | bind:this={listContainer} |
171 | | - |
172 | 174 | > |
173 | | - <Search bind:query bind:filters/> |
| 175 | + <Search bind:query bind:filters /> |
174 | 176 | <ul> |
175 | 177 | <!-- <li class="font-semibold text-darknavy text-center bg-yellow-500"> |
176 | 178 | Note: the current songlist is a placeholder and it will be up to date |
177 | 179 | soon. |
178 | 180 | </li> --> |
179 | | - {#each Object.entries(filteredPackDict).sort( ([, a], [, b]) => a.name.localeCompare(b.name), ) as [_, packDetails]} |
180 | | - <li |
181 | | - class="pack scroll-item font-semibold text-blue-300 text-center" |
182 | | - > |
183 | | - <!-- TODO: not critical but might change, was kinda breaking when using enter to just trigger onclick but it would be nice to make it work --> |
184 | | - <button |
185 | | - type="button" |
186 | | - class="p-2 w-full" |
187 | | - on:click|preventDefault={() => |
188 | | - handleClick(packDetails.name)} |
189 | | - on:keydown={(event) => { |
190 | | - if (event.key === "Enter") { |
191 | | - event.stopPropagation(); |
192 | | - event.preventDefault(); |
193 | | - handleEnter(event); |
194 | | - } |
195 | | - }} |
| 181 | + {#each Object.entries(filteredPackDict).sort( ([, a], [, b]) => a.name.localeCompare(b.name), ) as [_, packDetails]} |
| 182 | + <li |
| 183 | + class="pack scroll-item font-semibold text-blue-300 text-center" |
196 | 184 | > |
197 | | - {packDetails.name} |
198 | | - </button> |
199 | | - </li> |
200 | | - {#if openPack === packDetails.name} |
201 | | - <div class="bg-darknavy"> |
202 | | - <ul> |
203 | | - {#each Object.entries(packDetails.songs).sort( (a, b) => a[1].title.localeCompare(b[1].title), ) as [songName, songDetails]} |
204 | | - <li class="song scroll-item text-center p-2"> |
205 | | - <p>{songDetails.title}</p> |
206 | | - </li> |
207 | | - {/each} |
208 | | - </ul> |
209 | | - </div> |
210 | | - {/if} |
211 | | - {/each} |
| 185 | + <!-- TODO: not critical but might change, was kinda breaking when using enter to just trigger onclick but it would be nice to make it work --> |
| 186 | + <button |
| 187 | + type="button" |
| 188 | + class="p-2 w-full" |
| 189 | + on:click|preventDefault={() => |
| 190 | + handleClick(packDetails.name)} |
| 191 | + on:keydown={(event) => { |
| 192 | + if (event.key === "Enter") { |
| 193 | + event.stopPropagation(); |
| 194 | + event.preventDefault(); |
| 195 | + handleEnter(event); |
| 196 | + } |
| 197 | + }} |
| 198 | + > |
| 199 | + {packDetails.name} |
| 200 | + </button> |
| 201 | + </li> |
| 202 | + {#if openPack === packDetails.name} |
| 203 | + <div class="bg-darknavy"> |
| 204 | + <ul> |
| 205 | + {#each Object.entries(packDetails.songs).sort( (a, b) => a[1].title.localeCompare(b[1].title), ) as [songName, songDetails]} |
| 206 | + <li class="song scroll-item text-center p-2"> |
| 207 | + <p>{songDetails.title}</p> |
| 208 | + </li> |
| 209 | + {/each} |
| 210 | + </ul> |
| 211 | + </div> |
| 212 | + {/if} |
| 213 | + {/each} |
212 | 214 | </ul> |
213 | 215 | </div> |
0 commit comments