Tournament logo+name in breadcrumbs

This commit is contained in:
Kalle
2024-03-16 17:02:57 +02:00
parent 18d5d38368
commit 7248a1ddb1
5 changed files with 53 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ import { LinkButton } from "../Button";
import { SUPPORT_PAGE } from "~/utils/urls";
import { HeartIcon } from "../icons/Heart";
import { useIsMounted } from "~/hooks/useIsMounted";
import clsx from "clsx";
function useBreadcrumbs() {
const { t } = useTranslation();
@@ -66,7 +67,7 @@ export const Layout = React.memo(function Layout({
key={`${breadcrumb.href}-sep`}
className="layout__breadcrumb-separator"
>
/
»
</span>,
<BreadcrumbLink key={breadcrumb.href} data={breadcrumb} />,
];
@@ -119,8 +120,22 @@ export const Layout = React.memo(function Layout({
function BreadcrumbLink({ data }: { data: Breadcrumb }) {
if (data.type === "IMAGE") {
return (
<Link to={data.href} className="layout__breadcrumb">
<Image alt="" path={data.imgPath} width={30} height={30} />
<Link
to={data.href}
className={clsx("layout__breadcrumb", {
"stack horizontal sm items-center": data.text,
})}
>
<Image
className={clsx("layout__breadcrumb__image", {
"rounded-full": data.rounded,
})}
alt=""
path={data.imgPath}
width={24}
height={24}
/>
{data.text}
</Link>
);
}

View File

@@ -37,16 +37,10 @@ import { useAutoRerender } from "~/hooks/useAutoRerender";
import { useIsMounted } from "~/hooks/useIsMounted";
import type { ModeShort, StageId } from "~/modules/in-game-lists";
import { rankedModesShort } from "~/modules/in-game-lists/modes";
import {
notFoundIfFalsy,
parseRequestFormData,
validate,
type SendouRouteHandle,
} from "~/utils/remix";
import { notFoundIfFalsy, parseRequestFormData, validate } from "~/utils/remix";
import { booleanToInt } from "~/utils/sql";
import { assertUnreachable } from "~/utils/types";
import {
CALENDAR_PAGE,
LOG_IN_URL,
SENDOU_INK_BASE_URL,
navIconUrl,
@@ -86,14 +80,6 @@ import { filterOutFalsy } from "~/utils/arrays";
import { MapPoolStages } from "~/components/MapPoolSelector";
import { Section } from "~/components/Section";
export const handle: SendouRouteHandle = {
breadcrumb: () => ({
imgPath: navIconUrl("calendar"),
href: CALENDAR_PAGE,
type: "IMAGE",
}),
};
export const action: ActionFunction = async ({ request, params }) => {
const user = await requireUser(request);
const data = await parseRequestFormData({ request, schema: registerSchema });

View File

@@ -22,11 +22,15 @@ import { type SendouRouteHandle } from "~/utils/remix";
import { makeTitle } from "~/utils/strings";
import { assertUnreachable } from "~/utils/types";
import { streamsByTournamentId } from "../core/streams.server";
import { tournamentIdFromParams } from "../tournament-utils";
import {
HACKY_resolvePicture,
tournamentIdFromParams,
} from "../tournament-utils";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import * as TournamentRepository from "~/features/tournament/TournamentRepository.server";
import { databaseTimestampToDate } from "~/utils/dates";
import { isAdmin } from "~/permissions";
import { tournamentPage } from "~/utils/urls";
import "../tournament.css";
import "~/styles/maps.css";
@@ -42,6 +46,21 @@ export const meta: MetaFunction = (args) => {
export const handle: SendouRouteHandle = {
i18n: ["tournament", "calendar"],
breadcrumb: ({ match }) => {
const data = match.data as TournamentLoaderData | undefined;
if (!data) return [];
return [
{
imgPath: HACKY_resolvePicture(data.tournament.ctx),
href: tournamentPage(data.tournament.ctx.id),
type: "IMAGE",
text: data.tournament.ctx.name,
rounded: true,
},
];
},
};
export type TournamentLoaderData = SerializeFrom<typeof loader>;

View File

@@ -18,18 +18,24 @@
overflow: hidden;
max-width: 350px;
color: var(--text);
font-size: var(--fonts-sm);
font-size: var(--fonts-xs);
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
.layout__breadcrumb__image {
min-width: 24px;
}
.layout__breadcrumb.logo {
overflow: initial;
}
.layout__breadcrumb-separator {
font-size: 20px;
opacity: 0.4;
margin-inline-start: -1px;
}
.layout__item_size {

View File

@@ -195,7 +195,13 @@ export function validate(
}
export type Breadcrumb =
| { imgPath: string; type: "IMAGE"; href: string }
| {
imgPath: string;
type: "IMAGE";
href: string;
text?: string;
rounded?: boolean;
}
| { text: string; type: "TEXT"; href: string };
/**