From a1f1fa4e442476f54ce4cd7bb9e506856074cb74 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Wed, 4 Dec 2024 10:49:31 -0500 Subject: [PATCH 1/2] Fix search tab in reading toolbar --- src/langs/json/en.json | 2 +- .../components/viewer/ReadingToolbar.svelte | 36 ++++++++++++------- src/lib/components/viewer/Search.svelte | 5 +-- .../viewer/stories/Search.stories.svelte | 2 -- .../viewer/stories/Viewer.stories.svelte | 26 +++++++++++++- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/langs/json/en.json b/src/langs/json/en.json index 484fbec88..cffe80ee6 100644 --- a/src/langs/json/en.json +++ b/src/langs/json/en.json @@ -325,7 +325,7 @@ "notes": "Notes", "annotating": "Annotate", "redacting": "Redact", - "search": "Search" + "search": "Results" }, "zoom": { "zoom": "Zoom", diff --git a/src/lib/components/viewer/ReadingToolbar.svelte b/src/lib/components/viewer/ReadingToolbar.svelte index 6481e5453..8aaaacc36 100644 --- a/src/lib/components/viewer/ReadingToolbar.svelte +++ b/src/lib/components/viewer/ReadingToolbar.svelte @@ -54,7 +54,14 @@ Assumes it's a child of a ViewerContext SEARCH_MENU: width < remToPx(24), }; - const readModes: Map = new Map([ + const readModeTabs: Map = new Map([ + ["document", $_("mode.document")], + ["text", $_("mode.text")], + ["grid", $_("mode.grid")], + ["notes", $_("mode.notes")], + ]); + + const readModeDropdownItems: Map = new Map([ ["document", $_("mode.document")], ["text", $_("mode.text")], ["grid", $_("mode.grid")], @@ -74,6 +81,7 @@ Assumes it's a child of a ViewerContext notes: Note16, annotating: Comment16, redacting: EyeClosed16, + search: Search16, }; @@ -81,7 +89,7 @@ Assumes it's a child of a ViewerContext {#if BREAKPOINTS.READ_MENU}
- {#each readModes.entries() as [value, name]} + {#each readModeTabs.entries() as [value, name]} - {Array.from(readModes ?? []).find(([value]) => value === $mode)?.[1]} + {Array.from(readModeDropdownItems ?? []).find( + ([value]) => value === $mode, + )?.[1]} - {#each readModes.entries() as [value, name]} - - - {name} - + {#each readModeDropdownItems.entries() as [value, name]} + {#if value !== "search"} + + + {name} + + {/if} {/each} {#if BREAKPOINTS.WRITE_MENU && canWrite} {#each writeModes as [value, name]} diff --git a/src/lib/components/viewer/Search.svelte b/src/lib/components/viewer/Search.svelte index 06e94060c..01db41d56 100644 --- a/src/lib/components/viewer/Search.svelte +++ b/src/lib/components/viewer/Search.svelte @@ -74,10 +74,11 @@ Assumes it's a child of a ViewerContext display: flex; flex-flow: column; align-items: center; - gap: 2rem; + gap: 1rem; margin: 0 auto; + width: 100%; max-width: 38.0625rem; - padding: 2rem 0; + padding: 1rem 1rem; min-height: 100%; } .card { diff --git a/src/lib/components/viewer/stories/Search.stories.svelte b/src/lib/components/viewer/stories/Search.stories.svelte index e18c448f5..10e0f3b92 100644 --- a/src/lib/components/viewer/stories/Search.stories.svelte +++ b/src/lib/components/viewer/stories/Search.stories.svelte @@ -13,10 +13,8 @@ import text from "@/test/fixtures/documents/document.txt.json"; import ViewerContext from "../ViewerContext.svelte"; - import type { APIResponse, Highlights } from "@/lib/api/types"; const query = "Trump"; - const empty: APIResponse = { data: {} }; + ({ ...note, edit_access: true })), + }, + }} +/>