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

Frontend facets #314

Merged
merged 2 commits into from
Nov 7, 2023
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
1 change: 0 additions & 1 deletion apps/researcher/src/messages/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"accessibilityTypeToFilter": "Type to filter on text.",
"accessibilitySelectToFilter": "Select a checkbox to filter",
"accessibilityClickToSearch": "Click to search",
"selectAll": "Select all items with \"{searchValue}\"",
"filterPlaceholder": "Filter {filterName}",
"orderAlphabetically": "Order alphabetically",
"orderByCount": "Order by count",
Expand Down
1 change: 0 additions & 1 deletion apps/researcher/src/messages/nl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"accessibilityTypeToFilter": "Typ om op tekst te filteren",
"accessibilitySelectToFilter": "Selecteer een selectievakje om te filteren",
"accessibilityClickToSearch": "Klik om te zoeken",
"selectAll": "Selecteer alles met \"{searchValue}\"",
"filterPlaceholder": "Filter {filterName}",
"orderAlphabetically": "Sorteer alfabetisch",
"orderByCount": "Sorteer op aantal",
Expand Down
25 changes: 4 additions & 21 deletions packages/ui/list/searchable-multi-select-facet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
useSearchableMultiSelectFacet,
FacetSortBy,
FacetProvider,
useListStore,
} from '@colonial-collections/list-store';

interface ExpandedFacetProps {
Expand All @@ -35,18 +34,6 @@ function ExpandedFacet({filterKey}: ExpandedFacetProps) {
} = useSearchableMultiSelectFacet();

const t = useTranslations('Filters');
const listStore = useListStore();

function selectAllClick() {
const selectedFilters = [
...((listStore.selectedFilters[filterKey] as (string | number)[]) || []),
...filteredFilters.map(filter => filter.id),
];

const uniqueFilters = Array.from(new Set(selectedFilters));

listStore.filterChange(filterKey, uniqueFilters);
}

return (
<div className="flex flex-col md:flex-row gap-4 md:gap-10 max-h-[95%]">
Expand All @@ -62,14 +49,6 @@ function ExpandedFacet({filterKey}: ExpandedFacetProps) {
value={searchValue}
onChange={e => setSearchValue(e.target.value)}
/>
{searchValue && (
<button
onClick={() => selectAllClick()}
className="px-4 py-2 text-sm rounded-full bg-neutral-100 hover:bg-neutral-200 transition text-neutral-800 flex items-center gap-1"
>
{t('selectAll', {searchValue})}
</button>
)}
</div>
<div className="py-4 my-4 border-y flex flex-col lg:flex-row justify-between">
<div className="flex flex-row gap-2">
Expand Down Expand Up @@ -175,6 +154,10 @@ export function SearchableMultiSelectFacet({
}: Props) {
const t = useTranslations('Filters');

if (!filters.length) {
return null;
}

return (
<FacetWrapper testId={testId}>
<div className="flex items-center w-full my-1">
Expand Down