Skip to content
Merged
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
3 changes: 3 additions & 0 deletions packages/scout-for-lol/packages/app/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
--color-scout-danger-ink: var(--scout-color-danger-text);
--color-scout-success: var(--scout-color-success-on-surface);
--color-scout-success-fill: var(--scout-color-success);
/* `text-scout-warning` was used without being mapped, so it rendered as
inherited text. Like success and danger, the readable-as-text colour. */
--color-scout-warning: var(--scout-color-warning-on-surface);
--color-scout-border: var(--scout-color-border);
--color-scout-focus: var(--scout-color-focus);
/* Match outcomes. `win`/`loss` read as text on a surface; the `-fill`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const ColorsSchema = z.object({
successOnSurface: HexColorSchema,
warning: HexColorSchema,
warningText: HexColorSchema,
// Same split as danger and success: warning-coloured text on an ordinary
// background, where the fill is too dark to read on the dark themes.
warningOnSurface: HexColorSchema,
danger: HexColorSchema,
dangerText: HexColorSchema,
// `danger` fills a surface and `dangerText` is the text on that fill. Danger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { NameText } from "./name-text.tsx";
import {
CHAMPION_FACE_SIZES,
ChampionFace,
type ChampionFaceResult,
} from "./champion-face.tsx";

const meta = {
title: "Domain/ChampionFace",
component: ChampionFace,
tags: ["autodocs"],
args: { champion: "Ahri" },
} satisfies Meta<typeof ChampionFace>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {};

export const Win: Story = { args: { result: "win" } };

export const Loss: Story = { args: { result: "loss" } };

export const ByNumericId: Story = { args: { champion: 103, result: "win" } };

export const Decorative: Story = {
args: { champion: "Syndra", alt: "" },
};

const rows = [
{ key: "Ahri", name: "Ahri" },
{ key: "Syndra", name: "Syndra" },
{ key: "Jinx", name: "Jinx" },
{ key: "Thresh", name: "Thresh" },
{ key: "Nunu", name: "Nunu & Willump" },
{ key: "Renata", name: "Renata Glasc" },
];

export const Sizes: Story = {
parameters: { controls: { disable: true } },
render: () => (
<div style={{ display: "flex", alignItems: "center", gap: "1.5rem" }}>
{CHAMPION_FACE_SIZES.map((size) => (
<ChampionFace key={size} champion="Ahri" size={size} />
))}
</div>
),
};

export const SizesWithResults: Story = {
parameters: { controls: { disable: true } },
render: () => (
<div style={{ display: "grid", gap: "1.5rem" }}>
{(["win", "loss"] satisfies ChampionFaceResult[]).map((result) => (
<div
key={result}
style={{ display: "flex", alignItems: "center", gap: "1.5rem" }}
>
{CHAMPION_FACE_SIZES.map((size) => (
<ChampionFace
key={size}
champion="Jinx"
size={size}
result={result}
/>
))}
</div>
))}
</div>
),
};

function FeedRows(props: { maxWidth?: string }) {
return (
<ul
style={{
display: "grid",
gridTemplateColumns: "minmax(0, 1fr)",
gap: "0.875rem",
listStyle: "none",
margin: 0,
padding: 0,
...(props.maxWidth === undefined ? {} : { maxWidth: props.maxWidth }),
}}
>
{rows.map((row, index) => (
<li
key={row.key}
style={{ display: "flex", alignItems: "center", gap: "1rem" }}
>
<ChampionFace
champion={row.key}
result={index % 3 === 1 ? "loss" : "win"}
alt=""
/>
<span style={{ flex: 1, minWidth: 0 }}>
<NameText>
{`${index % 3 === 1 ? "Lost" : "Won"} as ${row.name}, 9/2/11, +21 LP`}
</NameText>
</span>
</li>
))}
</ul>
);
}

export const InAFeed: Story = {
parameters: { controls: { disable: true } },
render: () => <FeedRows />,
};

export const LongTextInANarrowFeed: Story = {
parameters: { controls: { disable: true } },
render: () => <FeedRows maxWidth="17rem" />,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { ChampionPortrait } from "#src/assets/index.tsx";
import { cn } from "#src/lib/cn.ts";

/** The diameters the redesigned pages use, in CSS pixels. */
export const CHAMPION_FACE_SIZES = [26, 36, 40, 46, 76, 92] as const;
export type ChampionFaceSize = (typeof CHAMPION_FACE_SIZES)[number];

export type ChampionFaceResult = "win" | "loss";

const RESULT_LABEL: Record<ChampionFaceResult, string> = {
win: "Won",
loss: "Lost",
};

export type ChampionFaceProps = {
/** Champion key, name or numeric id, as the asset helpers accept. */
champion: string | number;
size?: ChampionFaceSize;
/** A small mark on the lower right: a check for a win, a dash for a loss. */
result?: ChampionFaceResult;
/** Defaults to the champion's name. Pass "" when the name is beside it. */
alt?: string;
className?: string;
};

/**
* A round champion portrait, with an optional result mark. A face is always a
* face: a champion here, a person in `PersonInitial`.
*
* Rows that change the ground colour on hover set `--scout-face-ground` so the
* ring around the mark follows it.
*/
export function ChampionFace({
champion,
size = 46,
result,
alt,
className,
}: ChampionFaceProps) {
return (
<span className={cn("scout-face", className)} data-size={size}>
<ChampionPortrait
champion={champion}
{...(alt === undefined ? {} : { alt })}
className="scout-face__image"
/>
{result === undefined ? null : (
<span className="scout-face__mark" data-result={result}>
{result === "win" ? (
<svg
aria-hidden="true"
width="12"
height="12"
viewBox="0 0 20 20"
fill="none"
stroke="currentColor"
strokeWidth="2.6"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="m5 10.5 3.2 3.2L15 6.5" />
</svg>
) : null}
<span className="scout-sr-only">{RESULT_LABEL[result]}</span>
</span>
)}
</span>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Chip } from "#src/components/surfaces/chip.tsx";
import { ChampionFace } from "./champion-face.tsx";
import { DuelHero } from "./duel-hero.tsx";

const meta = {
title: "Domain/DuelHero",
component: DuelHero,
tags: ["autodocs"],
parameters: { layout: "fullscreen" },
decorators: [
(story) => (
<div style={{ maxWidth: "70rem", margin: "0 auto", padding: "1rem" }}>
{story()}
</div>
),
],
} satisfies Meta<typeof DuelHero>;

export default meta;

type Story = StoryObj<typeof meta>;

const h1 = {
margin: 0,
font: "700 clamp(1.75rem, 4.5vw, 3.125rem)/1.05 var(--scout-font-display)",
overflowWrap: "anywhere",
} as const;

function Verdict(props: { a: string; b: string; id: string }) {
return (
<>
<h1 id={props.id} style={h1}>
{props.a}{" "}
<span
style={{ fontWeight: 500, color: "var(--scout-color-text-muted)" }}
>
against
</span>{" "}
{props.b}
</h1>
<p
style={{
margin: "0.875rem 0 0",
font: "500 clamp(1.25rem, 2.5vw, 2rem)/1.2 var(--scout-font-display)",
}}
>
{props.b} has the edge.
</p>
<p className="scout-muted" style={{ margin: "0.5rem 0 0" }}>
{props.a} wins 47.8% of 1,050 games against her.
</p>
<div
style={{
display: "flex",
flexWrap: "wrap",
justifyContent: "center",
gap: "0.5rem",
marginTop: "1.125rem",
}}
>
<Chip pressed>
<ChampionFace champion="Ahri" size={26} alt="" />
I&apos;m playing Ahri
</Chip>
<Chip>
<ChampionFace champion="Syndra" size={26} alt="" />
I&apos;m playing Syndra
</Chip>
</div>
</>
);
}

export const Default: Story = {
args: {
start: { champion: "Ahri", face: "left" },
end: { champion: "Syndra", face: "left" },
"aria-labelledby": "duel-default",
children: <Verdict a="Ahri" b="Syndra" id="duel-default" />,
},
};

export const ArtFacingAway: Story = {
args: {
start: { champion: "Jinx", face: "right" },
end: { champion: "Thresh", face: "right" },
"aria-labelledby": "duel-away",
children: <Verdict a="Jinx" b="Thresh" id="duel-away" />,
},
};

export const MirroredByFlag: Story = {
args: {
start: { champion: "Ahri", mirrored: false },
end: { champion: "Syndra", mirrored: true },
"aria-labelledby": "duel-flag",
children: <Verdict a="Ahri" b="Syndra" id="duel-flag" />,
},
};

export const LongNames: Story = {
args: {
start: { champion: "Nunu", face: "left" },
end: { champion: "Renata", face: "left" },
"aria-labelledby": "duel-long",
children: <Verdict a="Nunu & Willump" b="Renata Glasc" id="duel-long" />,
},
};

export const WordsOnly: Story = {
args: {
start: { champion: "Ahri" },
end: { champion: "Syndra" },
"aria-labelledby": "duel-short",
children: (
<h1 id="duel-short" style={h1}>
Ahri against Syndra
</h1>
),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { HTMLAttributes, ReactNode } from "react";
import { Panel } from "#src/components/surfaces/panel.tsx";
import { cn } from "#src/lib/cn.ts";
import { HeroArtImage, type HeroArt } from "./hero-art.tsx";

export type DuelHeroProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
/** The verdict, centred between the champions: heading, lead, controls. */
children: ReactNode;
/** The champion on the left, looking right. */
start: HeroArt;
/** The champion on the right, looking left. */
end: HeroArt;
};

/**
* Two champions facing each other across a centred verdict, as on a matchup
* page. Each one fades in from its own edge. Give it `aria-labelledby` and the
* heading's id so it is a landmark.
*/
export function DuelHero({
children,
start,
end,
className,
...props
}: DuelHeroProps) {
return (
<Panel variant="hero" asChild>
<section {...props} className={cn("scout-duel-hero", className)}>
<HeroArtImage art={start} side="start" />
<HeroArtImage art={end} side="end" />
<div className="scout-duel-hero__text">{children}</div>
</section>
</Panel>
);
}
Loading