From 65e61bf8993e29288b5f6b351461540d1b1f6cd9 Mon Sep 17 00:00:00 2001 From: skeptrune Date: Tue, 17 Dec 2024 14:49:44 -0800 Subject: [PATCH] cleanup: mobile view of search component modal --- .../src/TrieveModal/index.css | 12 +++++--- .../src/TrieveModal/index.tsx | 28 +++++++++++++++++++ server/src/public/navbar.html | 2 +- server/src/public/page.html | 20 +++++++++---- server/src/public/product.html | 6 ++-- server/static/output.css | 27 ++++++++++++------ 6 files changed, 72 insertions(+), 23 deletions(-) diff --git a/clients/search-component/src/TrieveModal/index.css b/clients/search-component/src/TrieveModal/index.css index 55eb6ff9c..b2fb16621 100644 --- a/clients/search-component/src/TrieveModal/index.css +++ b/clients/search-component/src/TrieveModal/index.css @@ -23,7 +23,7 @@ body { } #trieve-search-modal { - @apply animate-contentShow scroll-smooth fixed top-[calc(40%-30vh)] sm:top-[calc(25vh-225px)] left-[50%] max-h-[60vh] w-[90vw] sm:max-w-[800px] -translate-x-[50%] rounded-lg shadow-2xl focus:outline-none z-[999] overflow-hidden text-base; + @apply animate-contentShow scroll-smooth fixed top-[calc(40%-30vh)] left-[50%] max-h-[60vh] w-[90vw] sm:max-w-[800px] -translate-x-[50%] rounded-lg shadow-2xl focus:outline-none z-[999] overflow-hidden text-base; color: var(--tv-zinc-950); background-color: var(--tv-zinc-50); @@ -56,7 +56,7 @@ body { } &.chat-modal-mobile { - @apply flex flex-col top-0 sm:top-[calc(25vh-225px)] pt-4 max-h-[100vh] w-full sm:w-[90vw] rounded-none sm:rounded-lg; + @apply flex flex-col top-0 sm:top-[calc(40%-30vh)] pt-4 max-h-[100vh] w-full sm:w-[90vw] rounded-none sm:rounded-lg; .chat-outer-wrapper { @apply justify-between w-full h-full mt-10 sm:mt-12; @@ -188,7 +188,7 @@ body { } .trieve-footer { - @apply sticky px-3 items-center bottom-0 flex flex-col; + @apply sticky px-3 items-center bottom-[1px] flex flex-col; background-color: var(--tv-zinc-50); border-color: var(--tv-zinc-200); @@ -651,6 +651,10 @@ body { } } + input.search-input { + @apply pr-8; + } + input.search-input.ecommerce { @apply rounded-sm; } @@ -752,7 +756,7 @@ body { } &.start-chat { - @apply items-center flex max-w-[calc(90vw-70px)] sm:max-w-none; + @apply items-center flex max-w-[calc(90vw)] sm:max-w-none; h4 { @apply pl-0 pt-0 max-w-[calc(90vw-120px)] sm:max-w-[400px]; diff --git a/clients/search-component/src/TrieveModal/index.tsx b/clients/search-component/src/TrieveModal/index.tsx index 70ce614cb..83947f9a5 100644 --- a/clients/search-component/src/TrieveModal/index.tsx +++ b/clients/search-component/src/TrieveModal/index.tsx @@ -22,6 +22,34 @@ const Modal = () => { const { mode, open, setOpen, setMode, props } = useModalState(); const { askQuestion, chatWithGroup } = useChatState(); + useEffect(() => { + const onViewportResize = () => { + const viewportHeight = window.visualViewport?.height; + const trieveSearchModal = document.getElementById("trieve-search-modal"); + if (trieveSearchModal) { + trieveSearchModal.style.maxHeight = `${viewportHeight}px`; + } + + const chatOuterWrapper = document.querySelector( + ".chat-outer-wrapper" + ); + if (chatOuterWrapper) { + (chatOuterWrapper as HTMLElement).style.maxHeight = + `calc(${viewportHeight}px - 100px)`; + } + if (chatOuterWrapper) { + chatOuterWrapper.scrollTop = + chatOuterWrapper.scrollHeight; + } + }; + + window.addEventListener("resize", onViewportResize); + + return () => { + window.removeEventListener("resize", onViewportResize); + }; + }, [open]); + useEffect(() => { const script = document.createElement("script"); script.src = diff --git a/server/src/public/navbar.html b/server/src/public/navbar.html index 0d7cc5bf3..c22a58411 100644 --- a/server/src/public/navbar.html +++ b/server/src/public/navbar.html @@ -1,6 +1,6 @@