diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c68051d..09f17dc 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -18,14 +18,21 @@ let eventRefs = $state>({}); onMount(() => { + // Get the teams endpoint scoreEndpoint = new EventSource('/api/teams'); + // When the endpoint sends something scoreEndpoint.onmessage = (e) => { + // Parse the json const teamsData = JSON.parse(e.data); + // If its teams info, then update the teams thing if (teamsData['teams']) teams = teamsData['teams']; }; + + // Basically same for events eventEndpoint = new EventSource('/api/registeredEvents'); eventEndpoint.onmessage = (e) => { eventTable = JSON.parse(e.data); + console.log(eventTable); }; }); @@ -44,20 +51,18 @@ } // When focusEventId changes, scroll to and highlight that event card - // TODO make this scrolling shit work idk $effect(() => { if (focusEventId == null) return; tick().then(() => { + // Get focused element const el = eventRefs[focusEventId!]; - const container = el?.closest('.events-scroll') as HTMLElement; - if (el && container) { - const elMid = el.offsetTop + el.offsetHeight / 2; - const targetScroll = elMid - container.clientHeight / 2 - 60; - container.scrollTo({ top: targetScroll, behavior: 'smooth' }); - el.classList.remove('highlight-pulse'); - void el.offsetWidth; - el.classList.add('highlight-pulse'); - } + // Scroll it to the top of the box + el.scrollIntoView({ alignToTop: true, behavior: 'instant', container: 'nearest' }); + // Wait for that to finish + tick().then(() => { + // Scroll the window back to the top + window.scrollTo(0, 0); + }); }); }); // Svelte action: measures text overflow and drives CSS marquee @@ -159,10 +164,22 @@
{#each eventTable as event (event.id)} -
+
{event.name} {event.division} + {#if event.state == 1} + ONGOING + {:else if event.state == 2} + Won By {event.winner.name} + {/if}
@@ -211,355 +228,3 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/routes/layout.css b/src/routes/layout.css index 6334050..db1d78c 100644 --- a/src/routes/layout.css +++ b/src/routes/layout.css @@ -179,6 +179,8 @@ /* ── Events scrollable container ── */ .events-scroll { flex: 1; + box-shadow: inset 0px 48px 20px -26px rgba(0, 0, 0, 0.35); + border-radius: 25px; overflow-y: auto; /* max-height: 900px; */ min-height: 0; @@ -193,6 +195,17 @@ gap: 10px; } +.event-status { + align-self: center; + justify-self: end; + text-align: end; + flex: 1; +} + +.event-winner { + color: var(--winner-color); +} + /* ── Event card ── */ .event-card { border-radius: 12px; @@ -200,6 +213,11 @@ overflow: hidden; transition: box-shadow 0.3s ease; } + +.ongoing-event { + background-color: color-mix(in srgb, currentColor 18%, transparent); + color: var(--ctp-latte-peach); +} /* Focus highlight pulse — added/removed by $effect */ .event-card.highlight-pulse { animation: card-pulse 1.2s ease-out forwards; @@ -271,13 +289,40 @@ /* 1 col on small screens, 4 across on large */ @media (max-width: 479px) { + .brackets { + flex-direction: row; + align-items: stretch; /* was flex-start — lets columns fill full height */ + } + .bracket-sep { + width: 1px; + height: auto; + margin: 10px 0; + align-self: stretch; + } .bracket-row { flex-direction: column; + min-width: 0; + flex: 1; } .player-box { max-width: 100%; + flex: 1; /* equal height across all player boxes in the column */ + } + .bracket-row { + flex: 1; + flex-direction: column; + align-items: stretch; /* player boxes fill the full column width */ + } + .brackets-name { + text-align: center; + align-items: center; + } + + .brackets-name-text { + text-align: center; } } + @media (min-width: 700px) { .player-box { max-width: calc(25% - 6px);