From ed4cac466ed307f9d7adf658542625242e10e02d Mon Sep 17 00:00:00 2001 From: Maggie Date: Sat, 30 Nov 2024 19:17:02 -0800 Subject: [PATCH] feat: make filter options collapsible (#815) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## PR Checklist - [x] Addresses an existing open issue: fixes #5 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/tidelift-me-up-site/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/tidelift-me-up-site/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Previously, the filter options were always visible and could not be collapsed. Now, the filter options can be collapsed, and the behavior is as follows: - By default, the filter options are visible when the site loads: filter-options-visible - Users can toggle the filter options open and closed by clicking on the "Filter options by v" button: filter-options-hidden - The filter options automatically close when a search is submitted: search-results Lastly, another fav emoji of mine: 🌱! --- src/components/OptionsForm.module.css | 15 +++++ src/components/OptionsForm.tsx | 96 ++++++++++++++++----------- 2 files changed, 74 insertions(+), 37 deletions(-) diff --git a/src/components/OptionsForm.module.css b/src/components/OptionsForm.module.css index bbf5760f..a7a3c7d5 100644 --- a/src/components/OptionsForm.module.css +++ b/src/components/OptionsForm.module.css @@ -106,6 +106,7 @@ .secondaryOptions { flex-direction: column; gap: 3rem; + margin-top: 1.25rem; } @media screen and (width >= 700px) { @@ -138,3 +139,17 @@ height: 2rem; padding: 0.5rem; } + +.optionsSummary { + align-items: center; + cursor: pointer; + display: flex; + font-style: italic; + gap: 4px; + justify-content: center; + list-style: none; +} + +.optionsDetails[open] .chevronIcon { + transform: rotate(180deg); +} diff --git a/src/components/OptionsForm.tsx b/src/components/OptionsForm.tsx index 26ce9e56..4c75629d 100644 --- a/src/components/OptionsForm.tsx +++ b/src/components/OptionsForm.tsx @@ -1,3 +1,5 @@ +"use client"; + import { PackageOwnership } from "tidelift-me-up"; import { CallToAction } from "./CallToAction"; @@ -16,6 +18,8 @@ export interface OptionsFormProps { export function OptionsForm({ options }: OptionsFormProps) { const ownerships = new Set(options.ownership); + const optionsExpanded = !options.username; + return (
@@ -39,44 +43,62 @@ export function OptionsForm({ options }: OptionsFormProps) {
-

optionally, filter by:

-
-
- - -
- -
- - Relationship to Project - -
- {(["author", "maintainer", "publisher"] as const).map( - (ownershipForm) => ( -
- - -
- ), - )} +
+ + optionally, filter by{" "} + + + + +
+
+ +
-
-
+ +
+ + Relationship to Project + +
+ {(["author", "maintainer", "publisher"] as const).map( + (ownershipForm) => ( +
+ + +
+ ), + )} +
+
+
+
);