-
Notifications
You must be signed in to change notification settings - Fork 0
tig-126-tigerjunction-the-handlebar-of-death #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
766325d
Weird space bug fix (dark mode issue)
ang-cai 53c6859
Completely vibe coded handle bar of death
ang-cai 6817895
Weird space bug fix (dark mode issue)
ang-cai f213c54
Merge branch 'resizable-window' of https://github.com/TigerAppsOrg/ti…
ang-cai d168be8
Weird space bug fix (dark mode issue)
ang-cai 286f531
Merge branch 'resizable-window' of https://github.com/TigerAppsOrg/ti…
ang-cai 772c7f8
Revert "Completely vibe coded handle bar of death"
ang-cai 55e7158
accidental typo
ang-cai 67888b5
Merge branch 'main' into resizable-window
joshuamotoaki c3d4133
basic handlebar
joshuamotoaki 7e612f0
Fix scrolling isseu
joshuamotoaki 3b9fa2c
So incredibly close
joshuamotoaki 6c97110
Fix base height with no handlebar
joshuamotoaki 7e14a80
stablize scrollbar gutter
joshuamotoaki 1566592
Fix type errors and fmt
joshuamotoaki 44d0beb
Fix Top.svelte not changing colors on theme change
joshuamotoaki cc314d4
New themes
joshuamotoaki 9cb426a
Rename original to legacy
joshuamotoaki a4de8e4
Let text overflow CalBox container instead of scrolling
joshuamotoaki a81348f
Fix handlebar during resizing
joshuamotoaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,158 @@ | ||
| <script lang="ts"> | ||
| import { onMount, tick } from "svelte"; | ||
| import Saved from "./left/Saved.svelte"; | ||
| import SearchResults from "./left/SearchResults.svelte"; | ||
| import SearchBar from "./left/SearchBar.svelte"; | ||
| import Events from "./left/Events.svelte"; | ||
| import Handlebar from "./left/Handlebar.svelte"; | ||
| import { searchResults, recal } from "$lib/stores/recal"; | ||
| import { sectionRatio, isMobile, isEventOpen } from "$lib/stores/styles"; | ||
|
|
||
| // Element refs | ||
| let sectionEl: HTMLElement; | ||
| let eventsWrapperEl: HTMLElement; | ||
|
|
||
| // Height tracking | ||
| let availableHeight = 0; | ||
|
|
||
| // Content heights from children (dynamic measurement) | ||
| let savedContentHeight = 0; | ||
| let searchContentHeight = 0; | ||
| let eventsHeight = 0; | ||
|
|
||
| // Constants | ||
| const HANDLEBAR_HEIGHT = 16; | ||
| const BASE_MIN_RATIO = 0.1; | ||
| const BASE_MAX_RATIO = 0.9; | ||
| const GAP_SIZE = 16; // Two gaps of 8px each | ||
| const INNER_GAP = 8; | ||
|
|
||
| // Force update on window resize | ||
| function handleWindowResize() { | ||
| if (sectionEl) { | ||
| availableHeight = sectionEl.getBoundingClientRect().height; | ||
| } | ||
| $recal = !$recal; // Force re-render like CalBox click does | ||
| } | ||
|
|
||
| onMount(() => { | ||
| const resizeObserver = new ResizeObserver(entries => { | ||
| for (const entry of entries) { | ||
| availableHeight = entry.contentRect.height; | ||
| } | ||
| }); | ||
|
|
||
| resizeObserver.observe(sectionEl); | ||
| return () => resizeObserver.disconnect(); | ||
| }); | ||
|
|
||
| // Measure events section when it changes (collapsed/expanded) | ||
| $: if (eventsWrapperEl && $isEventOpen !== undefined) { | ||
| tick().then(() => { | ||
| eventsHeight = eventsWrapperEl?.offsetHeight ?? 0; | ||
| }); | ||
| } | ||
|
|
||
| // Calculate total content heights from dynamic measurements | ||
| $: topContentHeight = eventsHeight + INNER_GAP + savedContentHeight; | ||
| $: bottomContentHeight = searchContentHeight; | ||
|
|
||
| // Show handlebar when there are search results AND content would overflow | ||
| $: hasSearchResults = $searchResults.length > 0; | ||
| $: totalContent = topContentHeight + bottomContentHeight + INNER_GAP; | ||
| $: showHandlebar = | ||
| !$isMobile && hasSearchResults && totalContent > availableHeight; | ||
|
|
||
| // Calculate usable height (minus handlebar and gaps when shown) | ||
| $: usableHeight = showHandlebar | ||
| ? Math.max(0, availableHeight - HANDLEBAR_HEIGHT - GAP_SIZE) | ||
| : availableHeight; | ||
|
|
||
| // Content-based ratio constraints (using measured heights) | ||
| $: maxRatio = | ||
| usableHeight > 0 | ||
| ? Math.min(BASE_MAX_RATIO, topContentHeight / usableHeight) | ||
| : BASE_MAX_RATIO; | ||
| $: minRatio = | ||
| usableHeight > 0 | ||
| ? Math.max(BASE_MIN_RATIO, 1 - bottomContentHeight / usableHeight) | ||
| : BASE_MIN_RATIO; | ||
|
|
||
| // Default ratio based on content proportions | ||
| function getDefaultRatio(): number { | ||
| if (topContentHeight + bottomContentHeight === 0) return 0.5; | ||
| const ratio = | ||
| topContentHeight / (topContentHeight + bottomContentHeight); | ||
| return Math.max(minRatio, Math.min(maxRatio, ratio)); | ||
| } | ||
|
|
||
| // Get effective ratio (user-set or default), clamped to valid range | ||
| $: effectiveRatio = Math.max( | ||
| minRatio, | ||
| Math.min(maxRatio, $sectionRatio ?? getDefaultRatio()) | ||
| ); | ||
|
|
||
| // Calculate heights | ||
| $: rawTopHeight = Math.round(usableHeight * effectiveRatio); | ||
|
|
||
| // Cap at measured content height to prevent gaps | ||
| $: topHeight = Math.min(rawTopHeight, topContentHeight); | ||
| $: bottomHeight = usableHeight - topHeight; | ||
|
|
||
| // Style strings | ||
| $: topSectionStyle = showHandlebar ? `height: ${topHeight}px;` : ""; | ||
| $: bottomSectionStyle = showHandlebar ? `height: ${bottomHeight}px;` : ""; | ||
|
|
||
| function handleResize(e: CustomEvent<{ ratio: number }>) { | ||
| if (e.detail.ratio === -1) { | ||
| sectionRatio.reset(); | ||
| } else { | ||
| // Constrain to content-based bounds | ||
| const clampedRatio = Math.max( | ||
| minRatio, | ||
| Math.min(maxRatio, e.detail.ratio) | ||
| ); | ||
| sectionRatio.set(clampedRatio); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <svelte:window on:resize={handleWindowResize} /> | ||
|
|
||
| <div class="w-full flex flex-col h-full overflow-y-hidden"> | ||
| <div> | ||
| <SearchBar /> | ||
| </div> | ||
| <section class="flex-1 overflow-y-hidden mt-2"> | ||
| <div class="min-h-[24px]"> | ||
| <Events /> | ||
| </div> | ||
| <div> | ||
| <Saved /> | ||
| </div> | ||
| <div> | ||
| <SearchResults /> | ||
| <section | ||
| bind:this={sectionEl} | ||
| class="flex-1 overflow-y-hidden mt-2 flex flex-col gap-2"> | ||
| <!-- Top Section: Events + Saved --> | ||
| <div | ||
| class="flex flex-col gap-2 overflow-y-hidden min-h-0 shrink-0" | ||
| style={topSectionStyle}> | ||
| <div bind:this={eventsWrapperEl} class="shrink-0"> | ||
| <Events /> | ||
| </div> | ||
| <div class="flex-1 overflow-y-hidden min-h-0 flex flex-col"> | ||
| <Saved bind:contentHeight={savedContentHeight} /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| </div> | ||
|
|
||
| <style lang="postcss"> | ||
| /* | ||
| This took hours to figure out. It allows the children to take up | ||
| the remaining space in the container while maintaining a max-height | ||
| proportional to the parent container. This is a lesson that | ||
| StackOverflow is almost always better than AI for complex problems. | ||
|
|
||
| Credit: | ||
| https://stackoverflow.com/questions/70324159/how-to-set-up-an-element-with-max-height-so-that-the-elements-inside-it-will-tak | ||
| */ | ||
|
|
||
| section { | ||
| display: grid; | ||
| grid-template-rows: repeat(auto-fit, minmax(0, min-content)); | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| section > *:last-child { | ||
| grid-row-end: span 2; | ||
| } | ||
| <!-- Handlebar --> | ||
| {#if showHandlebar} | ||
| <Handlebar | ||
| on:resize={handleResize} | ||
| containerHeight={usableHeight} /> | ||
| {/if} | ||
|
|
||
| section > div { | ||
| /* height: fit-content; */ | ||
| max-height: 100%; | ||
| @apply overflow-y-hidden flex flex-col; | ||
| } | ||
| </style> | ||
| <!-- Bottom Section: SearchResults --> | ||
| {#if hasSearchResults} | ||
| <div | ||
| class="overflow-y-hidden min-h-0 flex flex-col shrink-0" | ||
| class:flex-1={showHandlebar} | ||
| style={bottomSectionStyle}> | ||
| <SearchResults bind:contentHeight={searchContentHeight} /> | ||
| </div> | ||
| {/if} | ||
| </section> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
showHandlebaris forced tofalsewhen$isMobileis true (lines 61‑64), the search results container here never gets theflex-1height or any explicit sizing and inheritsoverflow-y-hiddenfrom its parent section. On small screens, a long list of search results therefore expands beyond the fixed section height and the overflow is simply clipped with no scrollbar, making part of the results unreachable on mobile devices.Useful? React with 👍 / 👎.