generated from acdh-oeaw/template-app-next
-
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.
style: make inner content scrollable on all pages
- Loading branch information
1 parent
edc37e9
commit 8aa24b8
Showing
7 changed files
with
135 additions
and
57 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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"use client"; | ||
|
||
import { LayoutGrid, LayoutList } from "lucide-react"; | ||
import { useTranslations } from "next-intl"; | ||
import { type ReactNode, useState } from "react"; | ||
import { Switch } from "react-aria-components"; | ||
import { SearchBox } from "react-instantsearch"; | ||
|
||
import { InfiniteScroll } from "./infinitescroll"; | ||
import { PaginatedTable } from "./paginated-table"; | ||
import { InstantSearchSortBy } from "./sortby"; | ||
import { InstantSearchStats } from "./stats"; | ||
|
||
interface ResultsProps { | ||
className?: string; | ||
children?: ReactNode; | ||
} | ||
|
||
export function Results(props: ResultsProps): ReactNode { | ||
const t = useTranslations("InstantSearch"); | ||
|
||
// TODO encode current state in URL | ||
const [view, setView] = useState<"covers" | "detail">("covers"); | ||
|
||
return ( | ||
<div className="grid h-full grid-rows-[auto_1fr] overflow-y-auto"> | ||
<div className="flex place-content-between items-center"> | ||
<InstantSearchStats /> | ||
<SearchBox placeholder={t("query_placeholder")} /> | ||
<InstantSearchSortBy sortOptions={["year:asc", "year:desc", "title:asc"]} /> | ||
{props.children} | ||
<Switch | ||
isSelected={view === "detail"} | ||
onChange={(isSelected) => { | ||
setView(isSelected ? "detail" : "covers"); | ||
}} | ||
> | ||
<LayoutGrid size={18} /> | ||
<div className="indicator" /> | ||
<LayoutList size={18} /> | ||
<span className="sr-only">{t("view.table")}</span> | ||
</Switch> | ||
</div> | ||
<div className="relative">{view === "covers" ? <InfiniteScroll /> : <PaginatedTable />}</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