Skip to content

Commit

Permalink
Add: Add transition
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Aug 28, 2024
1 parent 0dd454b commit 350bf67
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 55 deletions.
14 changes: 5 additions & 9 deletions frontend/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useRouteLoaderData,
} from "@remix-run/react";
import { useEffect, useMemo, useRef, useState } from "react";
import clsx from "clsx";
import { useTranslation } from "react-i18next";
import favicon from "~/assets/favicon.svg?url";
import DisablePortal from "~/components/DisablePortal";
Expand Down Expand Up @@ -62,13 +63,6 @@ export function Layout({ children }: { children: React.ReactNode }) {
const [serverError, setServerError] = useState<Error | undefined>();
const navigation = useNavigation();
const location = useLocation();
const mainNodeRef = useRef(null);
const prevChildrenRef = useRef<
[React.ReactNode, React.ReactNode | undefined]
>([undefined, children]);
useEffect(() => {
prevChildrenRef.current = [prevChildrenRef.current[1], children];
}, [children]);

const isSubmittingOrTransitioning = useMemo(
() => isSubmitting || navigation.state !== "idle",
Expand Down Expand Up @@ -126,8 +120,10 @@ export function Layout({ children }: { children: React.ReactNode }) {
<DisablePortal isShown={isSubmittingOrTransitioning} />
<Header />
<main
ref={mainNodeRef}
className="py-4 px-4 md:px-40 lg:px-60 max-w-[100vw] flex-grow"
className={clsx(
"py-4 px-4 md:px-40 lg:px-60 max-w-[100vw] flex-grow relative",
"starting:translate-y-2 starting:opacity-0 translate-y-0 opacity-1 motion-reduce:!translate-y-0 transition-[transform_opaicty] duration-300",
)}
key={location.pathname}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/DisablePortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DisablePortal: React.FC<{ isShown: boolean }> = ({ isShown }) => {
return createPortal(
<div
className={clsx(
"fixed inset-0 z-[100] bg-white bg-opacity-50 transition-opacity duration-200",
"fixed inset-0 z-[100] bg-white bg-opacity-50 transition-opacity duration-500",
)}
style={{
pointerEvents: isShown ? "auto" : "none",
Expand Down
45 changes: 0 additions & 45 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 350bf67

Please sign in to comment.