mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-20 18:29:48 -05:00
* Initial * Try npm in deploy script * Progress * Progress * Progress * Add missing index * Title to user results page * Hide SPR before tournament over * Results page and redirect * SPR info * Row bg colors * Laoyut shift fix * Hide Swiss start round button if bracket is in preview * Fix e2e test * Not needed * one more revert
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
import {
|
|
isRouteErrorResponse,
|
|
useLocation,
|
|
useRouteError,
|
|
} from "@remix-run/react";
|
|
import { SideNav } from "app/components/layout/SideNav";
|
|
import clsx from "clsx";
|
|
import type * as React from "react";
|
|
import { useUser } from "~/features/auth/core/user";
|
|
|
|
export const Main = ({
|
|
children,
|
|
className,
|
|
classNameOverwrite,
|
|
halfWidth,
|
|
bigger,
|
|
style,
|
|
}: {
|
|
children: React.ReactNode;
|
|
className?: string;
|
|
classNameOverwrite?: string;
|
|
halfWidth?: boolean;
|
|
bigger?: boolean;
|
|
style?: React.CSSProperties;
|
|
}) => {
|
|
const error = useRouteError();
|
|
const user = useUser();
|
|
const showLeaderboard =
|
|
import.meta.env.VITE_PLAYWIRE_PUBLISHER_ID &&
|
|
!user?.patronTier &&
|
|
!isRouteErrorResponse(error);
|
|
|
|
const location = useLocation();
|
|
const isFrontPage = location.pathname === "/";
|
|
|
|
return (
|
|
<div className="layout__main-container">
|
|
{!isFrontPage ? <SideNav /> : null}
|
|
<main
|
|
className={
|
|
classNameOverwrite
|
|
? clsx(classNameOverwrite, {
|
|
[containerClassName("narrow")]: halfWidth,
|
|
"pt-8-forced": showLeaderboard,
|
|
})
|
|
: clsx(
|
|
"layout__main",
|
|
containerClassName("normal"),
|
|
{
|
|
[containerClassName("narrow")]: halfWidth,
|
|
[containerClassName("wide")]: bigger,
|
|
"pt-8-forced": showLeaderboard,
|
|
},
|
|
className,
|
|
)
|
|
}
|
|
style={style}
|
|
>
|
|
{children}
|
|
</main>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const containerClassName = (width: "narrow" | "normal" | "wide") => {
|
|
if (width === "narrow") {
|
|
return "half-width";
|
|
}
|
|
|
|
if (width === "wide") {
|
|
return "bigger";
|
|
}
|
|
|
|
return "main";
|
|
};
|