Show "No results" instead of all cards when search failed #146

Merged
sb10q merged 1 commits from esavkin/web2019:144-no-results into master 2024-08-02 15:50:54 +08:00
3 changed files with 13 additions and 5 deletions

View File

@ -186,6 +186,13 @@ button {
.catalog-container {
padding-bottom: 4rem;
.no-results {
color: rgba(255, 255, 255, 0.58);
display: inline-block;
padding: 0rem 1.5rem;
font-size: 1rem;
}
.catalog-bar {
display: flex;
width: 100%;

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,8 @@ export function Catalog() {
const onClickToggleMobileSideMenu = useShopStore((state) => state.switchSideMenu);
const isMobile = useShopStore((state) => state.isMobile);
const showSearch = useShopStore((state) => state.listed_cards.length > 0);
const showSearch = useShopStore((state) => state.listed_cards.length > 0 && state.search_bar_value.length > 0);
const noResults = useShopStore((state) => state.listed_cards.length === 0 && state.search_bar_value.length > 0);
// #!render_count
console.log("Catalog renders: ", renderCount)
@ -36,8 +37,6 @@ export function Catalog() {
ref={provided.innerRef}
{...provided.droppableProps}>
<div className="catalog-bar">
<SearchBar/>
@ -50,7 +49,9 @@ export function Catalog() {
) : null}
</div>
{showSearch ? <CatalogSearchResult/> : <CatalogGroups/>}
{(showSearch && <CatalogSearchResult/>) ||
(noResults && <p className="no-results">No results</p>) ||
<CatalogGroups/>}
{provided.placeholder && (
<div style={{display: 'none'}}>