Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { DiscordGuildId } from "@scout-for-lol/data";
import { Input } from "@scout-for-lol/design-system/components/input";
import { HeroPanel } from "@scout-for-lol/design-system/domain/profile/hero-panel";
import { PageState } from "@scout-for-lol/design-system/domain/profile/page-states";
import { Search } from "lucide-react";
import {
PopularList,
YoursList,
} from "#src/components/champions/champions-index-lists.tsx";
import { HeroSearch } from "#src/components/hero-search.tsx";
import { ChampionsShell } from "#src/components/champions/champions-shell.tsx";
import { HeroWords } from "#src/components/champions/hero-words.tsx";
import { ServerChips } from "#src/components/champions/server-chips.tsx";
Expand Down Expand Up @@ -70,34 +69,12 @@ export function ChampionsIndexView(props: {
lead={lines.lead}
sub={lines.sub}
>
<form
role="search"
className="relative mt-6 block w-full max-w-[380px] text-scout-subtle"
onSubmit={(event) => {
event.preventDefault();
}}
>
<label className="scout-sr-only" htmlFor="find-champion">
Find a champion
</label>
<Search
aria-hidden="true"
size={18}
className="pointer-events-none absolute top-1/2 left-5 -mt-[9px]"
/>
<Input
id="find-champion"
name="find"
type="search"
placeholder="Find a champion"
autoComplete="off"
value={props.find}
onChange={(event) => {
props.onFind(event.currentTarget.value);
}}
className="h-[52px] rounded-full border-0 bg-[var(--scout-surface-inset)] pr-5 pl-12 text-base font-semibold shadow-[var(--scout-ring)] hover:bg-[var(--scout-surface-inset-strong)]"
/>
</form>
<HeroSearch
id="find-champion"
label="Find a champion"
value={props.find}
onChange={props.onFind}
/>
</HeroWords>
</HeroPanel>
{showPopular ? null : servers}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Class strings the redesigned pages share. The design system owns the domain
* components; these are the small pieces of page layout around them.
*/

/** A section heading inside a panel. */
export const SECTION_HEADING =
"m-0 font-display text-2xl leading-tight font-bold";

/** The page title in a hero. */
export const HERO_TITLE =
"m-0 font-display text-5xl leading-none font-bold [overflow-wrap:anywhere] sm:text-6xl";

/** A text link: brand colour, underlined, firmer on hover. */
export const TEXT_LINK =
"font-semibold text-scout-brand underline decoration-scout-brand/35 underline-offset-4 hover:decoration-current";

/** A small label beside a name, such as "Small sample". */
export const NOTE =
"rounded-full bg-[var(--scout-surface-inset-strong)] px-3 text-[13px] leading-5 font-semibold text-scout-subtle";

/** The column every redesigned page sits in. */
export const PAGE_COLUMN =
"mx-auto grid max-w-[1128px] gap-7 px-4 py-5 sm:px-8 sm:pt-8 sm:pb-14";

/** Two columns from the width where the mockups switch to them. */
export const TWO_COLUMNS =
"grid items-start gap-7 min-[1181px]:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]";
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { chipVariants } from "@scout-for-lol/design-system/components/surfaces/chip";
import {
PageLoading,
PageState,
} from "@scout-for-lol/design-system/domain/profile/page-states";
import type { ReactNode } from "react";
import { PAGE_COLUMN } from "#src/components/friendly-classes.ts";

/** The column a redesigned page sits in. */
export function FriendlyPage(props: { children: ReactNode }) {
return <div className={PAGE_COLUMN}>{props.children}</div>;
}

/** Soft placeholders in the shape of a page of rows, while it loads. */
export function FriendlyPageLoading(props: { rows?: number }) {
return (
<FriendlyPage>
<PageLoading shape="list" rows={props.rows ?? 6} label="Loading…" />
</FriendlyPage>
);
}

/** The page could not be read: say so, and offer the retry. */
export function FriendlyPageUnavailable(props: {
id: string;
title: string;
lead: string;
onRetry: () => void;
/** A way out, beside Retry. */
also?: ReactNode;
}) {
return (
<FriendlyPage>
<PageState
kind="unavailable"
level={1}
id={props.id}
title={props.title}
lead={props.lead}
actions={
<>
<button
type="button"
className={chipVariants({ variant: "default" })}
onClick={props.onRetry}
>
Retry
</button>
{props.also}
</>
}
/>
</FriendlyPage>
);
}
41 changes: 41 additions & 0 deletions packages/scout-for-lol/packages/app/src/components/hero-search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Input } from "@scout-for-lol/design-system/components/input";
import { Search } from "lucide-react";

/** The search field in a hero: a pill with a lens, labelled for assistive technology. */
export function HeroSearch(props: {
id: string;
label: string;
value: string;
onChange: (value: string) => void;
}) {
return (
<form
role="search"
className="relative mt-6 block w-full max-w-[380px] text-scout-subtle"
onSubmit={(event) => {
event.preventDefault();
}}
>
<label className="scout-sr-only" htmlFor={props.id}>
{props.label}
</label>
<Search
aria-hidden="true"
size={18}
className="pointer-events-none absolute top-1/2 left-5 -mt-[9px]"
/>
<Input
id={props.id}
name="find"
type="search"
placeholder={props.label}
autoComplete="off"
value={props.value}
onChange={(event) => {
props.onChange(event.currentTarget.value);
}}
className="h-[52px] rounded-full border-0 bg-[var(--scout-surface-inset)] pr-5 pl-12 text-base font-semibold shadow-[var(--scout-ring)] hover:bg-[var(--scout-surface-inset-strong)]"
/>
</form>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Fold } from "@scout-for-lol/design-system/components/surfaces/fold";
import { Panel } from "@scout-for-lol/design-system/components/surfaces/panel";
import { Link } from "react-router";
import {
SECTION_HEADING,
TEXT_LINK,
} from "#src/components/friendly-classes.ts";
import {
accountsSentence,
masterySentence,
playTimesSentence,
} from "#src/lib/player/player-about.ts";
import type { PlayerSummary } from "#src/lib/player/player-page.ts";

const FACT = "m-0 text-scout-subtle";

/** A challenge run the player is in, as the fold lists it. */
export type ChallengeRun = {
id: string;
title: string;
status: string;
recomputing: boolean;
};

/** The player's challenge runs: a fold of links, or nothing without any. */
function ChallengesFold(props: { runs: readonly ChallengeRun[] }) {
if (props.runs.length === 0) return null;
return (
<Fold summary={`Challenges (${props.runs.length.toString()})`}>
<ul className="m-0 grid list-none gap-1 p-0">
{props.runs.map((run) => (
<li key={run.id} className="flex min-h-11 items-center gap-3">
<Link to={`/challenge-runs/${run.id}`} className={TEXT_LINK}>
{run.title}
</Link>
<span className="text-scout-subtle">
{run.recomputing ? "Updating now" : run.status}
</span>
</li>
))}
</ul>
</Fold>
);
}

/** Accounts, mastery, when they play and challenges: each a fold with one fact. */
export function AboutMore(props: {
summary: PlayerSummary;
challenges: readonly ChallengeRun[];
}) {
const { summary } = props;
const mastery = masterySentence(summary.accounts);
const times = playTimesSentence(summary.behavior?.activityTimes ?? []);
return (
<Panel variant="open" asChild>
<section aria-labelledby="about-h">
<h2 id="about-h" className={SECTION_HEADING}>
More about {summary.alias}
</h2>
<div className="mt-3.5 grid gap-2">
<Fold summary={`Accounts (${summary.accounts.length.toString()})`}>
<p className={FACT}>{accountsSentence(summary.accounts)}</p>
</Fold>
{mastery === undefined ? null : (
<Fold summary="Mastery">
<p className={FACT}>{mastery}</p>
</Fold>
)}
{times === undefined ? null : (
<Fold summary="When they play">
<p className={FACT}>{times}</p>
</Fold>
)}
<ChallengesFold runs={props.challenges} />
</div>
</section>
</Panel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Panel } from "@scout-for-lol/design-system/components/surfaces/panel";
import { ChampionFace } from "@scout-for-lol/design-system/domain/profile/champion-face";
import { useState } from "react";
import { Link } from "react-router";
import {
NOTE,
SECTION_HEADING,
TEXT_LINK,
} from "#src/components/friendly-classes.ts";
import { wholePercent } from "#src/lib/format/percent.ts";
import { gamesText } from "#src/lib/champions/champion-pages.ts";
import {
BEST_CHAMPIONS_PREVIEW,
type BestChampion,
} from "#src/lib/player/player-page.ts";

function Tile(props: { champion: BestChampion }) {
const { champion } = props;
return (
<Link
to={`/champions/${champion.championId.toString()}`}
className="grid justify-items-center rounded-lg px-1.5 pt-3.5 pb-4 text-center text-scout-ink no-underline hover:bg-scout-surface"
>
<ChampionFace champion={champion.championId} size={92} alt="" />
<b className="mt-3 font-display text-[21px] leading-tight">
{champion.name}
</b>
<span className="text-scout-subtle">{gamesText(champion.games)}</span>
<span className="text-scout-subtle">
Won {wholePercent(champion.winRate)}
</span>
{champion.lowSample ? (
<span className={`${NOTE} mt-2`}>Small sample</span>
) : null}
</Link>
);
}

/** The champions this player does most with, three to a row. */
export function BestChampionsPanel(props: {
champions: readonly BestChampion[];
}) {
const [all, setAll] = useState(false);
const shown = all
? props.champions
: props.champions.slice(0, BEST_CHAMPIONS_PREVIEW);
const more = props.champions.length > BEST_CHAMPIONS_PREVIEW && !all;
return (
<Panel variant="open" asChild>
<section aria-labelledby="best-h">
<div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2">
<h2 id="best-h" className={SECTION_HEADING}>
Best champions
</h2>
{more ? (
<button
type="button"
className={`${TEXT_LINK} inline-flex min-h-11 items-center`}
onClick={() => {
setAll(true);
}}
>
See all {props.champions.length.toString()}
</button>
) : null}
</div>
<ul className="m-0 mt-3.5 grid list-none grid-cols-3 gap-2 p-0 max-sm:gap-0">
{shown.map((champion) => (
<li key={champion.championId}>
<Tile champion={champion} />
</li>
))}
</ul>
</section>
</Panel>
);
}
Loading