|
1 | 1 | <script lang="ts">
|
2 |
| - import { tick } from "svelte"; |
| 2 | + import { onDestroy, onMount, tick } from "svelte"; |
3 | 3 | import {
|
4 | 4 | currentThread,
|
5 | 5 | currentChatThread,
|
|
21 | 21 | import { slide } from "svelte/transition";
|
22 | 22 | import IconClose from "$lib/components/IconClose.svelte";
|
23 | 23 | import CloseButton from "$lib/components/CloseButton.svelte";
|
| 24 | + import { isMobile } from "$lib/utils"; |
24 | 25 |
|
25 | 26 | const sys = getSystem();
|
26 | 27 | let message = "";
|
27 | 28 | let textarea: HTMLTextAreaElement | null = null;
|
28 | 29 |
|
| 30 | + let windowHeight = window.innerHeight; |
| 31 | + function updateWindowHeight() { |
| 32 | + const element = document.querySelector(".your-element"); |
| 33 | + const innerHeight = window.innerHeight; // Get viewport height in pixels |
| 34 | + const targetPct = 100; |
| 35 | + windowHeight = innerHeight * (targetPct / 100); |
| 36 | + console.log({ windowHeight }); |
| 37 | + } |
| 38 | +
|
| 39 | + onMount(() => { |
| 40 | + if (!isMobile()) { |
| 41 | + return; |
| 42 | + } else { |
| 43 | + console.warn("Mobile browser. Manually managing window height."); |
| 44 | + } |
| 45 | + window.addEventListener("DOMContentLoaded", updateWindowHeight, false); |
| 46 | + window.addEventListener("resize", updateWindowHeight, false); |
| 47 | + window.addEventListener("orientationchange", updateWindowHeight, false); |
| 48 | + }); |
| 49 | +
|
| 50 | + onDestroy(() => { |
| 51 | + if (!isMobile()) return; |
| 52 | + window.removeEventListener("DOMContentLoaded", updateWindowHeight, false); |
| 53 | + window.removeEventListener("resize", updateWindowHeight, false); |
| 54 | + window.removeEventListener("orientationchange", updateWindowHeight, false); |
| 55 | + }); |
| 56 | +
|
29 | 57 | const resizeChatInput = () => {
|
30 | 58 | if (!textarea) return;
|
31 | 59 |
|
|
82 | 110 | )}`;
|
83 | 111 | </script>
|
84 | 112 |
|
85 |
| -<div class:dev-container={dev} class={classNames("app-container", {})}> |
| 113 | +<div |
| 114 | + class:dev-container={dev} |
| 115 | + class={classNames("app-container", { |
| 116 | + "rounded-lg": sys.isTauri, |
| 117 | + })} |
| 118 | + style={isMobile() ? `height: ${windowHeight}px;` : ""} |
| 119 | +> |
86 | 120 | <header data-tauri-drag-region class="app-header p-4 pr-3 border-b border-zinc-700 w-full">
|
87 | 121 | <div class="Left flex items-center space-x-4">
|
88 | 122 | {#if sys.isTauri}
|
|
259 | 293 | "bottom";
|
260 | 294 |
|
261 | 295 | /* Not sure where the extra height is from, but the specific calc fixes the layout */
|
| 296 | + /* NOTE This will be overwritten on mobile. See the manual height code above */ |
262 | 297 | height: calc(100vh - 2px);
|
263 | 298 | }
|
264 | 299 | .app-header {
|
|
0 commit comments