1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-22 12:59:36 +02:00

Normal and live search for bookmarks

This commit is contained in:
unknown 2021-09-06 13:22:47 +02:00
parent fac280ff0a
commit 53d50ca869
4 changed files with 111 additions and 69 deletions

View file

@ -9,30 +9,49 @@ import BookmarkCard from '../BookmarkCard/BookmarkCard';
interface ComponentProps {
categories: Category[];
totalCategories?: number;
searching: boolean;
}
const BookmarkGrid = (props: ComponentProps): JSX.Element => {
let bookmarks: JSX.Element;
if (props.categories.length > 0) {
bookmarks = (
<div className={classes.BookmarkGrid}>
{props.categories.map((category: Category): JSX.Element => <BookmarkCard category={category} key={category.id} />)}
</div>
);
} else {
if (props.totalCategories) {
if (props.searching && props.categories[0].bookmarks.length === 0) {
bookmarks = (
<p className={classes.BookmarksMessage}>There are no pinned categories. You can pin them from the <Link to='/bookmarks'>/bookmarks</Link> menu</p>
<p className={classes.BookmarksMessage}>
No bookmarks match your search criteria
</p>
);
} else {
bookmarks = (
<p className={classes.BookmarksMessage}>You don't have any bookmarks. You can add a new one from <Link to='/bookmarks'>/bookmarks</Link> menu</p>
<div className={classes.BookmarkGrid}>
{props.categories.map(
(category: Category): JSX.Element => (
<BookmarkCard category={category} key={category.id} />
)
)}
</div>
);
}
} else {
if (props.totalCategories) {
bookmarks = (
<p className={classes.BookmarksMessage}>
There are no pinned categories. You can pin them from the{' '}
<Link to="/bookmarks">/bookmarks</Link> menu
</p>
);
} else {
bookmarks = (
<p className={classes.BookmarksMessage}>
You don't have any bookmarks. You can add a new one from{' '}
<Link to="/bookmarks">/bookmarks</Link> menu
</p>
);
}
}
return bookmarks;
}
};
export default BookmarkGrid;
export default BookmarkGrid;