Skip to content

Commit

Permalink
(chore): added constants for recent searches
Browse files Browse the repository at this point in the history
  • Loading branch information
adenekan41 committed Jan 5, 2023
1 parent 7464167 commit 7cbe5a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/stem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,18 @@ const RecentSearch: React.FC<{
removeRecentSearch: (search: string) => void;
setInputValue?: (value: string) => void;
}> = memo(({ recents: recentSearch, removeRecentSearch, setInputValue }) => {
const RECENT_SEARCH_NUMBER = 5;

const [isShowMore, setIsShowMore] = useState(false);

return (
<>
{!isEmpty(recentSearch) && (
<div className={classNames([styles.scoutbarSection])}>
<p className={styles.header}>Recent Search</p>
<div className={styles.recentSearch}>
{recentSearch
.slice(0, isShowMore ? recentSearch.length : 5)
.slice(0, isShowMore ? recentSearch.length : RECENT_SEARCH_NUMBER)
?.map((search, index) => (
<div className={styles.recentCell} key={`${search}:${index}`}>
<Icon
Expand Down Expand Up @@ -401,7 +404,8 @@ const RecentSearch: React.FC<{
>
{!isShowMore ? (
<>
Show <b>{recentSearch.length - 5}</b> more...
Show <b>{recentSearch.length - RECENT_SEARCH_NUMBER}</b>{' '}
more...
</>
) : (
<>Show less</>
Expand Down

0 comments on commit 7cbe5a7

Please sign in to comment.