Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3813] Fixes to SearchBar on the Control Center UI #3818

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
align-items: center;
justify-content: space-between;
svg {
margin-left: 16px;
color: var(--color-text-gray);

&:hover {
cursor: pointer;
color: var(--color-airy-blue);
}
}

.filterIcon {
margin-left: 16px;
}

.filterIconSelected {
transition: background 0.5s ease;
color: var(--color-background-white);
margin-left: 16px;
background: var(--color-airy-logo-blue);
border-radius: 24px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,32 @@ export const CatalogSearchBar = (props: CatalogSearchBarProps) => {
props.setCurrentFilter(currentFilter);
}, [currentFilter]);

const handleSearchClick = () => {
setShowingSearchField(true);
};
const handleSearchClick = () => setShowingSearchField(!showSearchField);

return (
<div className={styles.container}>
<div className={styles.iconContainer}>
{showSearchField ? (
<SearchField
autoFocus
className={styles.searchField}
placeholder={t('searchByNamePlaceholder')}
value={query}
setValue={(value: string) => {
setQuery(value), props.setQuery(value);
}}
/>
<ListenOutsideClick onOuterClick={showSearchField && handleSearchClick}>
<SearchField
autoFocus
className={styles.searchField}
placeholder={t('searchByNamePlaceholder')}
value={query}
setValue={(value: string) => {
setQuery(value), props.setQuery(value);
}}
/>
</ListenOutsideClick>
) : (
<SearchIcon height={20} width={20} className={styles.searchIcon} onClick={handleSearchClick} />
)}
<FilterIcon
height={24}
width={24}
className={currentFilter !== FilterTypes.all ? styles.filterIcon : ''}
className={
currentFilter !== FilterTypes.all ? `${styles.filterIcon} ${styles.filterIconSelected}` : styles.filterIcon
}
onClick={toggleShowFilter}
/>
<div>
Expand Down
8 changes: 4 additions & 4 deletions frontend/control-center/src/pages/Catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Catalog = (props: ConnectedProps<typeof connector>) => {
useLayoutEffect(() => {
if (query && currentFilter === FilterTypes.all) {
const filteredCatalogByName = [...catalogList].filter((component: ComponentInfo) =>
component?.displayName?.toLowerCase().includes(query)
component?.displayName?.toLowerCase().startsWith(query.toLowerCase())
);
setOrderedCatalogList(filteredCatalogByName);
} else {
Expand All @@ -73,7 +73,7 @@ const Catalog = (props: ConnectedProps<typeof connector>) => {
query !== ''
? setOrderedCatalogList(
sortedByInstalled.filter((component: ComponentInfo) =>
component?.displayName?.toLowerCase().includes(query)
component?.displayName?.toLowerCase().startsWith(query.toLowerCase())
)
)
: setOrderedCatalogList(sortedByInstalled);
Expand All @@ -82,7 +82,7 @@ const Catalog = (props: ConnectedProps<typeof connector>) => {
query !== ''
? setOrderedCatalogList(
sortedByAccess.filter((component: ComponentInfo) =>
component?.displayName?.toLowerCase().includes(query)
component?.displayName?.toLowerCase().startsWith(query.toLowerCase())
)
)
: setOrderedCatalogList(sortedByAccess);
Expand All @@ -91,7 +91,7 @@ const Catalog = (props: ConnectedProps<typeof connector>) => {
query !== ''
? setOrderedCatalogList(
sortedByUninstalled.filter((component: ComponentInfo) =>
component?.displayName?.toLowerCase().includes(query)
component?.displayName?.toLowerCase().startsWith(query.toLowerCase())
)
)
: setOrderedCatalogList(sortedByUninstalled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@
color: var(--color-dark-elements-gray);
}

.searchInput {
background: var(--color-background-white);
border: 1px solid var(--color-airy-blue);
border-radius: 4px;
}

.animateIn {
animation: searchfieldAnimIn 300ms ease;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ const ConnectedChannelsList = (props: ConnectedChannelsListProps) => {
<div className={styles.searchField}>
{showingSearchField && (
<SearchField
className={animationAction ? styles.animateIn : styles.animateOut}
className={`${styles.searchInput} ${animationAction ? styles.animateIn : styles.animateOut}`}
placeholder={t('search')}
value={searchText}
setValue={(value: string) => setSearchText(value)}
autoFocus={true}
style={{height: '32px', borderRadius: '32px'}}
resetClicked={() => setSearchText('')}
/>
)}
Expand Down