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
9 changes: 6 additions & 3 deletions web/src/features/maps/MapList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,15 @@ function MapStatsList({
<li key={map.name}>
<Link
href={`/maps/${map.name}`}
className="hover:bg-surface-raised -mx-2 flex items-center gap-2 rounded-md px-2 py-0.5"
className="group flex items-center gap-2 rounded-sm py-0.5"
>
{map.tier != null && tierCount != null && (
<TierBadge tier={map.tier} tierCount={tierCount} />
)}
<span className="min-w-0 flex-1 truncate" title={map.name}>
<span
className="group-hover:text-accent min-w-0 flex-1 truncate transition-colors duration-(--duration-fast)"
title={map.name}
>
{map.name}
</span>
<span className="text-text-subtle shrink-0">{map.detail}</span>
Expand Down Expand Up @@ -520,7 +523,7 @@ function MapRow({
return (
<Link
href={`/maps/${map.name}`}
className="border-border bg-surface group hover:bg-surface-raised flex h-full min-w-0 flex-col overflow-hidden rounded-md border transition-colors duration-(--duration-fast) focus-visible:-outline-offset-2"
className="border-border bg-surface group hover:border-border-strong flex h-full min-w-0 flex-col overflow-hidden rounded-md border transition-colors duration-(--duration-fast) focus-visible:-outline-offset-2"
>
<span className="relative block">
<MapImage image={map.image} size="card" />
Expand Down
84 changes: 33 additions & 51 deletions web/src/ui/TierSpread.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Tier distribution and filters, with one responsive layout for every screen size.
// Map difficulty filters with matching controls for all tiers and individual tiers.
import type { CSSProperties } from "react";
import { classNames } from "./classNames";
import { Link } from "./Link";
import { TierBadge, tierColor } from "./TierBadge";
import { tierColor } from "./TierBadge";

const number = new Intl.NumberFormat("en");

Expand All @@ -24,70 +24,52 @@ export function TierSpread({
const total = byTier.reduce((sum, count) => sum + count, untiered);
if (total === 0) return null;
const tierCount = byTier.length;
const choices = [
{ tier: null, count: total },
...byTier.map((count, index) => ({ tier: index + 1, count })),
];

return (
<section aria-label="Maps by tier" className="flex min-w-0 flex-col gap-3">
<div className="flex items-center justify-between gap-4">
<h2 className="text-sm font-bold">Difficulty</h2>
<Link
href={tierHref(null)}
scroll={false}
aria-current={selected == null ? "true" : undefined}
className="text-text-muted hover:text-accent rounded-sm text-xs"
>
All tiers{" "}
<span className="ml-1 tabular-nums">{number.format(total)}</span>
</Link>
<span className="text-text-subtle text-xs tabular-nums">
{number.format(total)} maps
</span>
</div>
<div
aria-hidden
className="bg-surface-raised flex h-1.5 gap-px overflow-hidden rounded-sm"
>
{byTier.map(
(count, index) =>
count > 0 && (
<span
key={index}
style={{
backgroundColor: tierColor(index + 1, tierCount),
flex: count,
}}
className={classNames(
"transition-opacity duration-(--duration-fast)",
selected != null && selected !== index + 1 && "opacity-25",
)}
/>
),
)}
{untiered > 0 && <span style={{ flex: untiered }} />}
</div>
<ul className="grid grid-cols-5 gap-2">
{byTier.map((count, index) => {
const tier = index + 1;
const active = selected === tier;
<ul className="grid grid-cols-3 gap-2 sm:grid-cols-6 xl:grid-cols-3">
{choices.map(({ tier, count }) => {
const active = tier === (selected ?? null);
return (
<li key={tier} className="min-w-0">
<li key={tier ?? "all"} className="min-w-0">
<Link
href={tierHref(active ? null : tier)}
href={tierHref(tier)}
scroll={false}
aria-current={active ? "true" : undefined}
aria-label={`Tier ${tier}: ${number.format(count)} maps`}
aria-label={`${tier == null ? "All tiers" : `Tier ${tier}`}: ${number.format(count)} maps`}
style={
{ "--tier": tierColor(tier, tierCount) } as CSSProperties
tier == null
? undefined
: ({
"--tier": tierColor(tier, tierCount),
} as CSSProperties)
}
className={classNames(
"flex min-h-12 flex-col items-center justify-center gap-1 rounded-sm border py-2 transition-colors duration-(--duration-fast)",
"flex h-9 items-center justify-between gap-2 rounded-sm border px-2 text-xs transition-colors duration-(--duration-fast)",
active
? "border-(--tier)/50 bg-(--tier)/10"
: "bg-text/4 hover:border-border-strong hover:bg-text/8 border-transparent",
selected != null && !active && "opacity-50 hover:opacity-100",
? "border-text-muted bg-text/6 text-text"
: "border-border text-text-muted hover:border-text-muted hover:text-text",
)}
>
<TierBadge
tier={tier}
tierCount={tierCount}
className="self-auto"
/>
<span className="text-text-muted text-xs tabular-nums">
<span
className={classNames(
"font-medium",
tier != null && "text-(color:--tier)",
)}
>
{tier == null ? "All tiers" : `T${tier}`}
</span>
<span className="text-text-subtle tabular-nums">
{number.format(count)}
</span>
</Link>
Expand Down