-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into erik/add-at-fair-page
- Loading branch information
Showing
34 changed files
with
4,092 additions
and
901 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use client" | ||
|
||
import { Filter, FilterItem } from "@/app/student/lib/filters" | ||
import { FilterSelectionItem } from "@/app/student/map/_components/FilterSelectionItem" | ||
import { useState } from "react" | ||
|
||
export default function FilterSection({ | ||
filter, | ||
onChange | ||
}: { | ||
filter: Filter | ||
onChange: (selected: FilterItem[]) => void | ||
}) { | ||
const { items, selected, label } = filter | ||
|
||
const maxDisplayed = 7 | ||
const [numDisplayed, setNumDisplayed] = useState(maxDisplayed) | ||
|
||
function isSelected(item: FilterItem) { | ||
return selected.some(s => s.id === item.id) | ||
} | ||
|
||
function onSelectionChange(item: FilterItem) { | ||
if (isSelected(item)) { | ||
onChange(selected.filter(s => s.id !== item.id)) // remove item | ||
} else { | ||
onChange([...selected, item]) // add item | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col justify-between"> | ||
<div> | ||
<h2 className="m-2 text-left text-xl text-stone-200">{label}</h2> | ||
<div className="m-1 mt-3 flex flex-wrap gap-4"> | ||
{items.slice(0, numDisplayed).map(item => ( | ||
<div className="" key={item.id}> | ||
<FilterSelectionItem | ||
name={item.name} | ||
isSelected={filter.selected.includes(item)} | ||
onClick={() => onSelectionChange(item)} | ||
/> | ||
</div> | ||
))} | ||
{maxDisplayed < items.length && ( | ||
<button | ||
onClick={() => | ||
setNumDisplayed( | ||
numDisplayed < items.length ? items.length : maxDisplayed | ||
) | ||
} | ||
className="flex w-auto rounded-3xl border border-neutral-400 px-3 py-2 text-center text-xs text-neutral-400 xs:px-4 xs:py-2 xs:text-base"> | ||
{numDisplayed < items.length ? ( | ||
<span>Show all {items.length}</span> | ||
) : ( | ||
<span>Show less</span> | ||
)} | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function FilterSelectionItem({ | ||
name, | ||
isSelected, | ||
onClick | ||
}: { | ||
name: string | ||
isSelected: boolean | ||
onClick: () => void | ||
}) { | ||
return ( | ||
<div | ||
className={`flex w-auto cursor-pointer text-ellipsis whitespace-nowrap rounded-3xl border px-3 py-2 text-center transition xs:px-4 xs:py-2 ${ | ||
isSelected | ||
? "border-1 border-melon-700 text-melon-700 shadow-md shadow-melon-700/30" | ||
: "border-emerald-700 text-emerald-700" | ||
}`} | ||
onClick={onClick}> | ||
<span className="text-xs xs:text-base">{name}</span> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.