mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
refactor: simplify the menu-container
This commit is contained in:
parent
b7e77417b4
commit
6e73d56da2
2 changed files with 54 additions and 66 deletions
|
|
@ -127,53 +127,45 @@ const SearchBar = React.memo(({ className, query, active }) => {
|
|||
</Button>
|
||||
}
|
||||
{
|
||||
historyOpen ?
|
||||
historyOpen && searchHistory?.items?.length > 0 || localSearch?.items?.length > 0 ?
|
||||
<div className={styles['menu-container']}>
|
||||
{
|
||||
localSearch.items.length === 0 && searchHistory.items.length === 0 ?
|
||||
<div className={styles['label']}>{ t('Start typing ...') }</div>
|
||||
searchHistory?.items?.length > 0 ?
|
||||
<div className={styles['items']}>
|
||||
<div className={styles['title']}>
|
||||
<div className={styles['label']}>{ t('STREMIO_TV_SEARCH_HISTORY_TITLE') }</div>
|
||||
<button className={styles['search-history-clear']} onClick={searchHistory.clear}>
|
||||
{ t('CLEAR_HISTORY') }
|
||||
</button>
|
||||
</div>
|
||||
{
|
||||
searchHistory.items.slice(0, 8).map(({ query, deepLinks }, index) => (
|
||||
<Button key={index} className={styles['item']} href={deepLinks.search} onClick={closeHistory}>
|
||||
{query}
|
||||
</Button>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
<div className={styles['content']}>
|
||||
{
|
||||
searchHistory?.items?.length > 0 ?
|
||||
<div className={styles['items']}>
|
||||
<div className={styles['title']}>
|
||||
<div className={styles['label']}>{ t('STREMIO_TV_SEARCH_HISTORY_TITLE') }</div>
|
||||
<button className={styles['search-history-clear']} onClick={searchHistory.clear}>
|
||||
{ t('CLEAR_HISTORY') }
|
||||
</button>
|
||||
</div>
|
||||
{
|
||||
searchHistory.items.slice(0, 8).map(({ query, deepLinks }, index) => (
|
||||
<Button key={index} className={styles['item']} href={deepLinks.search} onClick={closeHistory}>
|
||||
{query}
|
||||
</Button>
|
||||
))
|
||||
}
|
||||
{
|
||||
localSearch?.items?.length ?
|
||||
<div className={styles['items']}>
|
||||
<div className={styles['title']}>
|
||||
<div className={styles['label']}>{ t('Recommendations') }</div>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
{
|
||||
localSearch?.items?.length ?
|
||||
<div className={styles['items']}>
|
||||
<div className={styles['title']}>
|
||||
<div className={styles['label']}>{ t('Recommendations') }</div>
|
||||
</div>
|
||||
{
|
||||
localSearch.items.map(({ query, deepLinks }, index) => (
|
||||
<Button key={index} className={styles['item']} href={deepLinks.search} onClick={closeHistory}>
|
||||
{query}
|
||||
</Button>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
{
|
||||
localSearch.items.map(({ query, deepLinks }, index) => (
|
||||
<Button key={index} className={styles['item']} href={deepLinks.search} onClick={closeHistory}>
|
||||
{query}
|
||||
</Button>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
:
|
||||
null
|
||||
|
|
|
|||
|
|
@ -51,12 +51,18 @@
|
|||
|
||||
.menu-container {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
z-index: 10;
|
||||
padding: 1rem;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
background-color: var(--modal-background-color);
|
||||
border-radius: var(--border-radius);
|
||||
|
||||
|
|
@ -83,37 +89,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.items {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
|
||||
.items {
|
||||
.item {
|
||||
width: 90%;
|
||||
color: var(--primary-foreground-color);
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: var(--border-radius);
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
|
||||
.item {
|
||||
width: 90%;
|
||||
color: var(--primary-foreground-color);
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: var(--border-radius);
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--secondary-background-color);
|
||||
}
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--secondary-background-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue