Skip to content

Commit

Permalink
Add button for hiding filters sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksamies committed Aug 26, 2024
1 parent 0181e34 commit ff4b527
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

.top {
display: flex;
flex-direction: row-reverse;
align-items: center;
justify-content: space-between;
}
Expand Down Expand Up @@ -35,6 +36,10 @@
gap: var(--gap--24);
}

.packagesIsFiltersVisible {
grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}

.packageCardSkeleton {
aspect-ratio: 3/5;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
gap: var(--gap--16);
}

.sidebarIsHidden {
display: none;
}

.skeletonSearch {
width: auto;
height: 2.75rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { faXmarkLarge, faSlidersUp } from "@fortawesome/pro-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
PackageCategory,
Expand All @@ -15,7 +16,12 @@ import { SectionMenu } from "./FilterMenus/SectionMenu";
import styles from "./PackageSearch.module.css";
import packageListStyles from "./PackageList.module.css";
import { CategorySelection } from "./types";
import { PackageCard, Pagination, TextInput } from "@thunderstore/cyberstorm";
import {
Button,
PackageCard,
Pagination,
TextInput,
} from "@thunderstore/cyberstorm";
import { useNavigation, useSearchParams } from "@remix-run/react";
import { StalenessIndicator } from "@thunderstore/cyberstorm/src/components/StalenessIndicator/StalenessIndicator";
import { PackageCount } from "./PackageCount";
Expand Down Expand Up @@ -199,9 +205,31 @@ export function PackageSearch(props: Props) {
deferredRecentUpdate,
]);

const [isFiltersVisible, setIsFiltersVisible] = useState(true);

return (
<div className={styles.root}>
<div className={styles.searchWrapper}>
<div className={styles.searchRowItemWrapper}>
<label className={styles.searchText} htmlFor="packageOrder">
Sort by
</label>
<Button.Root
iconAlignment="side"
colorScheme="primary"
paddingSize="largeBorderCompensated"
onClick={() => setIsFiltersVisible(!isFiltersVisible)}
>
<Button.ButtonIcon>
<FontAwesomeIcon
icon={isFiltersVisible ? faXmarkLarge : faSlidersUp}
/>
</Button.ButtonIcon>
<Button.ButtonLabel>
{isFiltersVisible ? "Close" : "Open"}
</Button.ButtonLabel>
</Button.Root>
</div>
<div
className={classnames(
styles.searchInputWrapper,
Expand Down Expand Up @@ -248,7 +276,13 @@ export function PackageSearch(props: Props) {
</div>

<div className={styles.contentWrapper}>
<div className={styles.sidebar} id="desktopSidebar">
<div
className={classnames(
styles.sidebar,
isFiltersVisible ? undefined : styles.sidebarIsHidden
)}
id="desktopSidebar"
>
<CollapsibleMenu headerTitle="Date filters" defaultOpen={false}>
<div className={styles.dateFilterInputs}>
<div className={styles.dateFilterInputsSet}>
Expand Down Expand Up @@ -340,10 +374,6 @@ export function PackageSearch(props: Props) {
</div>

<div className={styles.content}>
<CategoryTagCloud
categories={categories}
setCategories={setCategories}
/>
<div className={styles.root}>
<div className={packageListStyles.top}>
<StalenessIndicator
Expand All @@ -356,11 +386,20 @@ export function PackageSearch(props: Props) {
totalCount={listings.count}
/>
</StalenessIndicator>
<CategoryTagCloud
categories={categories}
setCategories={setCategories}
/>
</div>

<StalenessIndicator
isStale={navigation.state === "loading" ? true : false}
className={packageListStyles.packages}
className={classnames(
packageListStyles.packages,
isFiltersVisible
? undefined
: packageListStyles.packagesIsFiltersVisible
)}
>
{listings.results.map((p) => (
<PackageCard key={`${p.namespace}-${p.name}`} package={p} />
Expand Down

0 comments on commit ff4b527

Please sign in to comment.