sendou.ink/app/components/Main.tsx
hfcRed 3bfa182c9f
Adjusted side nav (#1524)
* Changed nav and side to be sticky

* Centered calendar

* Adjusted top padding

* Added firefox scrollbar styling

* Adjusted scroll colors to fit theme

* Somehow this broke?? 😭

* Fix lint

* Adjust calendar padding

---------

Co-authored-by: hfcRed <hfcred@gmx.net>
Co-authored-by: Kalle <38327916+Sendouc@users.noreply.github.com>
2023-10-21 13:22:28 +03:00

60 lines
1.5 KiB
TypeScript

import { useCatch, useLocation } from "@remix-run/react";
import clsx from "clsx";
import type * as React from "react";
import { useMatches } from "react-router";
import { useUser } from "~/modules/auth";
import type { RootLoaderData } from "~/root";
import { SideNav } from "app/components/layout/SideNav";
export const Main = ({
children,
className,
classNameOverwrite,
halfWidth,
bigger,
style,
}: {
children: React.ReactNode;
className?: string;
classNameOverwrite?: string;
halfWidth?: boolean;
bigger?: boolean;
style?: React.CSSProperties;
}) => {
const caught = useCatch();
const data = useMatches()[0]?.data as RootLoaderData | undefined;
const user = useUser();
const showLeaderboard = data?.publisherId && !user?.patronTier && !caught;
const location = useLocation();
const isFrontPage = location.pathname === "/";
return (
<div className="layout__main-container">
{!isFrontPage ? <SideNav /> : null}
<main
className={
classNameOverwrite
? clsx(classNameOverwrite, {
"half-width": halfWidth,
"pt-8-forced": showLeaderboard,
})
: clsx(
"layout__main",
"main",
{
"half-width": halfWidth,
bigger,
"pt-8-forced": showLeaderboard,
},
className,
)
}
style={style}
>
{children}
</main>
</div>
);
};