sendou.ink/app/components/Main.tsx
Kalle 68aa12414a
New front page (#1938)
* Initial

* Progress

* Recent winners

* Add button

* Progress

* Mobile nav initial

* UI tweaks

* Overflow

* AnythingAdder links to places

* Remove color for tournament showcase

* Adjust SQ top banner based on if season is on right or not

* Tournament participant count fixed

* Log out

* todo

* Progress

* Nav complete

* Done?

* Fix lint

* Translate settings
2024-10-20 09:01:22 +03:00

67 lines
1.4 KiB
TypeScript

import { isRouteErrorResponse, useRouteError } from "@remix-run/react";
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);
return (
<div className="layout__main-container">
<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";
};