Skip to content
Open
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
10 changes: 10 additions & 0 deletions website/src/components/homepage-header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "@fontsource/philosopher/400.css"
import React from "react"
import { Button } from "reakit"
import DefaultImage from "../assets/DollieDuncan.jpg"
import * as styles from "./homepage-header.css"
Expand Down Expand Up @@ -40,6 +41,15 @@ export const HomepageHeader = (props: {
as="a"
href={props.button_right.link}
className={styles.actionButton}
onClick={(e: React.MouseEvent) => {
const hash = props.button_right.link
if (hash.startsWith("#")) {
e.preventDefault()
document
.getElementById(hash.slice(1))
?.scrollIntoView({ behavior: "smooth" })
}
}}
>
{props.button_right.text}
</Button>
Expand Down
25 changes: 25 additions & 0 deletions website/src/pages/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ import { DailpPageContents } from "./dailp.page"

/** Lists all documents in our database */
const IndexPage = () => {
// Block vite-plugin-ssr's scroll restoration on the homepage.
// The framework calls window.scrollTo to restore the previous position
// after render, so we temporarily intercept it to only allow scroll-to-top.
React.useEffect(() => {
const originalScrollTo = window.scrollTo
window.scrollTo = ((...args: unknown[]) => {
const isScrollToTop =
(args[0] === 0 && args[1] === 0) ||
(typeof args[0] === "object" &&
args[0] !== null &&
(args[0] as ScrollToOptions).top === 0)
if (isScrollToTop) {
originalScrollTo.call(window, 0, 0)
}
}) as typeof window.scrollTo
originalScrollTo.call(window, 0, 0)
const timer = setTimeout(() => {
window.scrollTo = originalScrollTo
}, 200)
return () => {
clearTimeout(timer)
window.scrollTo = originalScrollTo
}
}, [])

const [{ data: dailp }] = Dailp.useEditedCollectionsQuery()
const userRole = useUserRole()

Expand Down
Loading