sendou.ink/app/components/Main.tsx
Kalle c8ea75ebb6
SQL solution migration to Kysely + getting rid of routes folder (#1530)
* Kysely initial

* Badges initial

* Badge routes migrated

* Badges migrated

* Calendar work

* Fix one type problem

* Calendar work

* findResultsByUserId work

* Calendar reworking finished

* PlusSuggestions work

* Migrated suggestions

* Builds progress

* Migrated builds

* Admin migrated

* Migrate articles

* User search

* Faster getUser

* Selectable/insertable as global

* Refresh prod db script + patronTier index

* identifierToUserId

* updateProfile

* findByIdentifier

* More indexes

* User upsert

* upsertLite

* findAllPlusMembers

* updateResultHighlights

* updateMany

* User finished migration

* Fix types

* Fix PlusVotingResult typing

* PlusVotingRepository WIP

* Migrated resultsByMonthYear

* Migrated plusVotes (done with db. related migrations)

* Plus code to features folder

* Fix TODOs

* Export

* Fix range

* Migrate some user pages

* Move rest user routes

* Move /play

* Map list generator

* Front page

* Move map list generation logic

* Move plus voting logic

* Info

* API

* Adjust TODOs

* theme

* Auth

* Remove TODO
2023-11-04 13:15:36 +02: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 "~/features/auth/core";
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>
);
};