From eb18fd54b6e4beaf8aeddb468e88201ebdab0e72 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 14 Oct 2022 20:16:06 -0700 Subject: [PATCH] SearchFooter visual tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finally playing with this, now that we've been doing paginated search results in the main element! Let's see how it goes 😳 I made a thing to make the pagination toolbar smaller (might want to do that on the mobile view too?), and also to put the search suggestions in a popover floating at the top of the search box. --- src/app/WardrobePage/SearchFooter.js | 20 ++++++++++++++++++-- src/app/WardrobePage/SearchToolbar.js | 21 +++++++++++++++++---- src/app/components/PaginationToolbar.js | 5 ++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/app/WardrobePage/SearchFooter.js b/src/app/WardrobePage/SearchFooter.js index 2c6e2df..ba13b4b 100644 --- a/src/app/WardrobePage/SearchFooter.js +++ b/src/app/WardrobePage/SearchFooter.js @@ -3,6 +3,7 @@ import * as Sentry from "@sentry/react"; import { Box, Flex } from "@chakra-ui/react"; import SearchToolbar, { emptySearchQuery } from "./SearchToolbar"; import { MajorErrorMessage, TestErrorSender, useLocalStorage } from "../util"; +import PaginationToolbar from "../components/PaginationToolbar"; /** * SearchFooter appears on large screens only, to let you search for new items @@ -35,8 +36,23 @@ function SearchFooter() { Add new items: - - + + + + + alert("TODO")} + buildPageUrl={() => null} + size="sm" + /> + diff --git a/src/app/WardrobePage/SearchToolbar.js b/src/app/WardrobePage/SearchToolbar.js index f30cd2b..eeaac4d 100644 --- a/src/app/WardrobePage/SearchToolbar.js +++ b/src/app/WardrobePage/SearchToolbar.js @@ -35,6 +35,17 @@ export function searchQueryIsEmpty(query) { return Object.values(query).every((value) => !value); } +const SUGGESTIONS_PLACEMENT_PROPS = { + inline: { + borderBottomRadius: "md", + }, + top: { + position: "absolute", + bottom: "100%", + borderTopRadius: "md", + }, +}; + /** * SearchToolbar is rendered above both the ItemsPanel and the SearchPanel, * and contains the search field where the user types their query. @@ -53,6 +64,7 @@ function SearchToolbar({ showItemsLabel = false, background = null, boxShadow = null, + suggestionsPlacement = "inline", ...props }) { const [suggestions, setSuggestions] = React.useState([]); @@ -84,7 +96,7 @@ function SearchToolbar({ } }; - const suggestionBgColor = useColorModeValue("transparent", "whiteAlpha.100"); + const suggestionBgColor = useColorModeValue("white", "whiteAlpha.100"); const highlightedBgColor = useColorModeValue("gray.100", "whiteAlpha.300"); const renderSuggestion = React.useCallback( @@ -110,11 +122,11 @@ function SearchToolbar({ {({ css, cx }) => ( {children} {!children && advancedSearchIsOpen && ( @@ -140,7 +153,7 @@ function SearchToolbar({ ); }, - [advancedSearchIsOpen] + [advancedSearchIsOpen, suggestionsPlacement] ); // When we change the query filters, clear out the suggestions. @@ -183,7 +196,7 @@ function SearchToolbar({ const focusBorderColor = useColorModeValue("green.600", "green.400"); return ( - + { diff --git a/src/app/components/PaginationToolbar.js b/src/app/components/PaginationToolbar.js index 4c0b8de..ecafc8a 100644 --- a/src/app/components/PaginationToolbar.js +++ b/src/app/components/PaginationToolbar.js @@ -9,6 +9,7 @@ function PaginationToolbar({ currentPageNumber, goToPageNumber, buildPageUrl, + size = "md", ...props }) { const pagesAreLoaded = currentPageNumber != null && numTotalPages != null; @@ -32,11 +33,12 @@ function PaginationToolbar({ opacity: 0.4, }} isDisabled={!hasPrevPage} + size={size} > ← Prev {numTotalPages > 0 && ( - + Page Next →