1
0
Fork 0

Show No results instead of all cards when search failed

Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
Egor Savkin 2024-08-01 17:37:43 +08:00
parent 580dd1964c
commit ff56f369af
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'}}>