8000 feat(solo): the Solo screen on one screen by alexiscolin · Pull Request #2 · alexiscolin/gnogolf · GitHub
[go: up one dir, main page]

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
13 changes: 11 additions & 2 deletions web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2034,15 +2034,18 @@ body .toast.toast--center { top: max(14px, env(safe-area-inset-top)); width: max
/* a front section's heading: the records to beat' */
.podium__head h3 { margin: 0; } /* (.h-section: a section's title, as the rival's) */
/* the course's records to beat: a slim strip under the cups' title, seen without scrolling */
.podium { margin: 4px auto 32px; width: 100%; max-width: var(--front-w); text-align: left; }
.podium { position: relative; margin: 4px auto 32px; width: 100%; max-width: var(--front-w); text-align: left; }
/* with the community's tile: four across, the row as wide as the cups' under it, their edges in line */
.podium--more { max-width: none; }
.podium--more .podium__row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.podium__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.podium__links { display: flex; gap: 16px; }
/* the records to beat as the rival board's stickers (title.css .sticker), three across at any width */
.podium__row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px var(--gap-grid); }
/* a place: a disc (--m across), in its metal for the first three, paper for the others */
.podium__medal { --m: 24px; display: inline-grid; place-items: center; min-width: var(--m); height: var(--m); padding: 0 4px; border: var(--edge); border-radius: var(--pill); background: var(--paper); font-size: 13px; font-weight: 800; color: var(--ink); }
.podium__medal--1 { background: var(--gold); } .podium__medal--2 { background: var(--silver); } .podium__medal--3 { background: var(--bronze); }
.podium__empty { margin: 6px 0 0; }
.podium__empty { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; } /* (in the gap over the cups: no room of its own) */
/* a full board: name over address, the first three's metal discs, your pinned place */
.who { display: grid; line-height: 1.15; }
.who small { font-size: 11px; opacity: .6; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
Expand Down Expand Up @@ -2076,7 +2079,13 @@ body .toast.toast--center { top: max(14px, env(safe-area-inset-top)); width: max
@media (max-width: 700px) { .podium .sticker__tag { left: 50%; translate: -50% 0; max-width: calc(100% + 6px); padding: 1px 5px; } }
.podium__head small, .podium__links .linkish { white-space: nowrap; }
/* a phone: the title on its line (its mode beside it), the links on the next, both in line with the cards */
/* a narrow window: two tiles a row; a phone: the three records as they are, the community's tile across under them */
@media (max-width: 1000px) { .podium--more .podium__row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
.podium--more .podium__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.podium--more .podium__row { row-gap: 20px; } /* (its tag clear of the records' drop, as theirs of the heading) */
.podium--more .podium__row > li:last-child { grid-column: 1 / -1; }
.podium .sticker.sticker--community { min-height: 72px; padding: 8px 14px 8px 8px; }
.podium__head { flex-wrap: wrap; row-gap: 6px; padding: 0 8px; margin-bottom: 16px; }
.podium__head h3 { flex: 1 0 100%; }
.podium__links { gap: 20px; }
Expand Down
34 changes: 11 additions & 23 deletions web/app/title.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,29 +300,17 @@ body:has(.sheet) .front__veil { display: none; } body:has(.sheet) .front .front_
.worlds--v2 .world:focus-visible .world__ribbon { transform: rotate(-6deg) scale(1.18); }
.worlds--v2 .world:active:not([disabled]), .mode:active:not([disabled]) { transform: translateY(2px) scale(.98); box-shadow: 0 2px 0 var(--ink); }
.worlds--v2 .world[disabled] { background: #c9d2cd; }
/* the community's holes: a long band under the cups, a card of another kind (paper and a blueprint, not a
cup's colour and diorama), leaping as a cup does; a tap opens their screen */
.cband {
display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-4); width: 100%; margin: var(--gap-grid) 0 0;
padding: 10px 26px 10px 12px; border: var(--edge-bold); border-radius: var(--r-panel); background: var(--panel-dots), var(--paper);
box-shadow: var(--deep-card); font: inherit; color: var(--ink); text-align: left; cursor: pointer;
transition: transform var(--t-pop) var(--spring), box-shadow .2s;
}
.cband:hover, .cband:focus-visible { transform: translateY(-6px) rotate(-.4deg); box-shadow: 0 0 0 4px var(--glow), 0 0 34px 8px rgba(var(--glow-rgb), .75), 0 13px 0 var(--ink); }
.cband:active { transform: translateY(2px) scale(.99); box-shadow: 0 2px 0 var(--ink); }
.cband__art { display: grid; place-items: center; width: 132px; aspect-ratio: 5 / 4; border: var(--edge-bold); border-radius: 18px; background: #dbe8f5; overflow: hidden; }
.cband__art .mode__sketch { width: 92%; }
.cband__text { display: grid; gap: 4px; min-width: 0; }
.cband__name { display: flex; align-items: center; gap: 10px; font-size: var(--fs-name); font-weight: 800; }
.cband__name .tag { font-size: 12px; }
.cband__stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.cband__stats b { font-size: 20px; color: var(--ink); }
.cband__go { padding: 8px 16px; border: var(--edge-bold); border-radius: var(--pill); background: var(--gold); font-weight: 800; white-space: nowrap; box-shadow: 0 3px 0 var(--ink); }
@media (max-width: 700px) {
.cband { grid-template-columns: auto 1fr; padding-right: 14px; }
.cband__art { width: 88px; }
.cband__go { grid-column: 1 / -1; justify-self: stretch; text-align: center; }
}
/* the community's holes, the records row's last tile: a sticker as a player's (its shape, height, edge, shadow,
tilt and lift: below), in the blueprint's blue (the Builder's sheet: a way in, not a record), its sketch where a
face is, an arrow at its end; "Not ranked" its top tag, in ink (gold is a record's) */
.sticker.sticker--community { grid-template: auto auto / auto minmax(0, 1fr) auto; justify-items: start; padding-right: 14px; background: #2f6db3; color: var(--paper); text-align: left; }
.sticker.sticker--community .sticker__face { grid-area: 1 / 1 / 3 / 2; display: grid; place-items: center; width: 50px; border: var(--edge); border-radius: 10px; background: #dbe8f5; overflow: hidden; }
.sticker--community .mode__sketch { width: 92%; }
.sticker--community .sticker__who { grid-area: 1 / 2; }
.sticker.sticker--community .sticker__sub { grid-area: 2 / 2; opacity: 1; } /* (paper on the blue: 4.9:1) */
.sticker.sticker--community .sticker__tag { left: 10px; translate: none; background: var(--ink); color: var(--paper); letter-spacing: .08em; text-transform: uppercase; }
.sticker--community .sticker__go { grid-area: 1 / 3 / 3 / 4; font-size: 20px; color: var(--paper); transition: transform .2s; }
.sticker--community:hover .sticker__go { transform: translateX(3px); }
/* the cup's diorama in a round inked window, as a game's panel shows its gnome */
/* sized by the window's height too, so a laptop's cards fit its window */
.worlds--v2 .world__art { width: min(80%, 20vh); margin: 4px auto 0; aspect-ratio: 1 / 1; border-radius: 50%; }
Expand Down
6 changes: 3 additions & 3 deletions web/components/Golf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { Card, Cup } from "@/lib/card";
import type { Feel } from "@/lib/feel";
import { hasAdena, connect, current, onWalletChange, type Account } from "@/lib/adena";
import Title, { Hat, choresOf } from "@/components/Title";
import Worlds, { WORLDS, Emblem, worldOf } from "@/components/Worlds";
import Worlds, { CommunityTile, WORLDS, Emblem, worldOf } from "@/components/Worlds";
import Community from "@/components/Community";
import Share, { ShareClip, type Clip } from "@/components/Share";
import Gnokey from "@/components/Gnokey";
Expand Down Expand Up @@ -902,16 +902,16 @@ export default function Golf() {
current={s.world}
=> setScreen(BACK.worlds)}
=> setAbout(true)}
community={s.community}
racing={racingNote}
next={(c) => toPlay[c][0]?.name}
podium={<Podium chain={game.current && game.current.chain} me={me} mode={aim} gnome={gnome} => setBoard(true)}
holes={toPlay[guessCup(s.world || "")].slice(0, 6)} id) => (raceWith(p), openHole(id))}
// anyone can register a hole: those outside the course are playable from here, in no cup and on no ranking
more={s.community.length > 0 && <CommunityTile community={s.community} => (sound("select"), setScreen("community"))} />}
extra={<>
<button className="linkish" => (sound("blip"), setBadgesOpen(true))}>Badges {badgesEarned().length}/{BADGES.length} →</button>
{shopOn && <button className="linkish" => (sound("blip"), openShop())}>Gnomes →</button>}
</>} />}
=> setScreen("community")}
>
/>
)}
Expand Down
27 changes: 17 additions & 10 deletions web/components/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ function Who({ chain, addr, me, link, title = "See this round on gno.land" }: {
* (holePicks, as its board picks them, none you beat already), a tap racing it there (onRace); none:
* the course's (coursePicks, never its top three), a tap opening the board. A read again keeps the
* cards there until it lands: the cups below never move. */
export function Podium({ chain, me, mode = "pro", gnome, onOpen, extra, holes = [], onRace }: { chain: Chain | null; me?: string | null; mode?: Mode; gnome: string; onOpen: () => void; extra?: ReactNode; holes?: readonly HoleRow[]; onRace?: (player: string, hole: string) => void }) {
// more: a fourth tile after the records (the community's holes), the row then as wide as the cups'
export function Podium({ chain, me, mode = "pro", gnome, onOpen, extra, more, holes = [], onRace }: { chain: Chain | null; me?: string | null; mode?: Mode; gnome: string; onOpen: () => void; extra?: ReactNode; more?: ReactNode; holes?: readonly HoleRow[]; onRace?: (player: string, hole: string) => void }) {
const [top, setTop] = useState<{ cards: { player: string; name?: string; tag: string; sub: string; hole?: string }[]; flagged: boolean } | null>(null);
const next = holes.map((h) => h.id).join(" ");
useEffect(() => {
Expand Down Expand Up @@ -1035,7 +1036,7 @@ export function Podium({ chain, me, mode = "pro", gnome, onOpen, extra, holes =
if (!chain) return null;
const empty = !!top && !top.cards.length;
return (
<section className="podium" aria-label="Records to beat today">
<section className={more ? "podium podium--more" : "podium"} aria-label="Records to beat today">
<header className="podium__head">
<h3 className="h-section">Records to beat <small>{AIM_NAMES[mode]} · today</small></h3>
<span className="podium__links">
Expand All @@ -1057,9 +1058,10 @@ export function Podium({ chain, me, mode = "pro", gnome, onOpen, extra, holes =
</li>
);
})}
{more && <li>{more}</li>}
</ol>
{/* (its line kept, unseen, while the board is read or has players: the cards below never move) */}
<p className="real__fine podium__empty" style={empty ? undefined : { visibility: "hidden" }} aria-hidden={!empty}>{top && top.flagged ? "Every record here is flagged: All players lists them." : "Nobody yet: save a round on-chain and be the first record here."}</p>
{/* (said in the gap under the row, when nobody is there: the cups below never move) */}
<p className="real__fine podium__empty" hidden={!empty}>{top && top.flagged ? "Every record here is flagged: All players lists them." : "Nobody yet: save a round on-chain and be the first record here."}</p>
</section>
);
}
Expand All @@ -1082,16 +1084,21 @@ const StickerGhost = ({ at = 0, free }: { at?: number; free?: string }) =>
export function Sticker({ player, tag, sub, chain, me, gnome, onClick, say, go = "Race" }: { player: string; tag?: string; sub: string; chain: Chain | null; me?: string | null; gnome: string; onClick?: () => void; say?: string; go?: string }) {
const { label } = useWho(chain, player, me), mine = player === me;
useWorn(chain, mine ? "" : player);
return <Tile face={<Face skin={mine ? gnomeById(gnome) : rivalSkin(player, gnome)} />} tag={tag} name={<><Collector chain={chain} player={player} />{label}</>} sub={sub} go={tag && onClick && !say ? `${go} ▸` : undefined}
label={`${say ? `${label}: ${say}` : mine ? "Race your best" : go === "Race" ? `Race ${label}'s ghost` : `${label}: ${go.toLowerCase()}`}: ${tag ? `${tag}, ` : ""}${sub}`} />;
}
/** A sticker's card, whoever it shows: a face, why it is there over its corner (tag), a name, a line under it (sub),
* what a tap starts (go); with a tap it is a button, label said to a reader. */
export function Tile({ face, tag, name, sub, go, label, onClick, className = "" }: { face: ReactNode; tag?: string; name: ReactNode; sub: string; go?: string; label: string; onClick?: () => void; className?: string }) {
const body = (<>
<Face skin={mine ? gnomeById(gnome) : rivalSkin(player, gnome)} />
{face}
{tag && <span className="sticker__tag">{tag}</span>}
<span className="sticker__who"><Collector chain={chain} player={player} />{label}</span>
<span className="sticker__who">{name}</span>
<span className="sticker__sub">{sub}</span>
{tag && onClick && !say && <span className="sticker__go" aria-hidden="true">{go} ▸</span>}
{go && <span className="sticker__go" aria-hidden="true">{go}</span>}
</>);
return onClick
? <button className="sticker" aria-label={`${say ? `${label}: ${say}` : mine ? "Race your best" : go === "Race" ? `Race ${label}'s ghost` : `${label}: ${go.toLowerCase()}`}: ${tag ? `${tag}, ` : ""}${sub}`} >
: <div className="sticker">{body}</div>;
const cls = `sticker ${className}`.trim();
return onClick ? <button className={cls} aria-label={label} : <div className={cls}>{body}</div>;
}
/** A board's face wears the gnome its player wears for everyone (SHOP): asked with the page's other faces in
* one read (wear.ts askWorn), drawn again once it is known. */
Expand Down
36 changes: 11 additions & 25 deletions web/components/Worlds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { stillsOnly } from "@/lib/prefs";
import { CLIP, Green, canHover, cupStill, stillsReady, warmClips } from "@/components/Title";
import { FrontScreen } from "@/components/About";
import { Button, Frame, VsPar } from "@/components/ui";
import { Tile } from "@/components/Leaderboard";
import { plural } from "@/lib/words";
import { Sketch } from "@/components/Sketch";
import { authorOf } from "@/lib/builder/holes";
Expand Down Expand Up @@ -201,10 +202,7 @@ interface WorldsProps {
/** the connected wallet's saved holes back on the card (none: no wallet), and while it reads */
onRestore?: () => void;
restoring?: boolean;
community?: readonly HoleRow[];
/** the community's holes on their own screen (the band under the cups) */
onCommunity?: () => void;
/** the course's records to beat, under the cups */
/** the course's records to beat, over the cups (the community's holes their last tile) */
podium?: ReactNode;
/** a cup's next hole to play, said on its card once begun */
next?: (cup: Cup) => string | undefined;
Expand All @@ -214,7 +212,7 @@ interface WorldsProps {
const NOT_PLAYED: Pick<CupTotal, "done" | "strokes" | "par" | "clean"> = { done: 0, strokes: 0, par: 0, clean: false };
let shownOnce = false;

export default function Worlds({ counts = {}, stats, current, onPick, onBack, onAbout, onReset, onResetAll, onRestore, restoring = false, community = [], => {}, podium, racing, next = () => undefined }: WorldsProps) {
export default function Worlds({ counts = {}, stats, current, onPick, onBack, onAbout, onReset, onResetAll, onRestore, restoring = false, podium, racing, next = () => undefined }: WorldsProps) {
const [wipe, setWipe] = useState<string | null>(null); // what was asked to be cleared, before the second tap
const [resets, setResets] = useState(false); // the little reset menu at the top
const [hot, setHot] = useState<string | null>(null); // the cup under the pointer or the focus: the backdrop takes its colours
Expand Down Expand Up @@ -315,28 +313,16 @@ export default function Worlds({ counts = {}, stats, current, onPick, onBack, on
);
})}
</ul>
{/* anyone can register a hole: those outside the course are playable here, in no cup and on no ranking */}
{community.length > 0 && <CommunityBand community={community} => (sound("select"), onCommunity())} />}
EC5B </FrontScreen>
);
}

/** The community's holes as a long band under the cups, a card of another kind (a blueprint, not a diorama; not
* ranked): how many holes, by how many makers, in how many worlds; a tap opens their screen. */
function CommunityBand({ community, onOpen }: { community: readonly HoleRow[]; onOpen: () => void }) {
const makers = new Set(community.map((h) => authorOf(h.id)).filter(Boolean)).size, worlds = new Set(community.map((h) => h.world)).size;
return (
<button className="cband" aria-label={`Community holes: ${community.length} ${plural("hole", community.length)} by ${makers} ${plural("maker", makers)}, not ranked. See them all`}>
<span className="cband__art"><Sketch /></span>
<span className="cband__text">
<span className="cband__name">Community holes <span className="tag">Not ranked</span></span>
<span className="cband__stats">
<span><b>{community.length}</b> {plural("hole", community.length)} published</span>
<span><b>{makers}</b> {plural("maker", makers)}</span>
<span><b>{worlds}</b> {plural("world", worlds)}</span>
</span>
</span>
<span className="cband__go" aria-hidden="true">See them all ▸</span>
</button>
);
/** The community's holes as the records row's last tile: a sticker as a player's (Leaderboard.tsx Tile), in the
* blueprint's blue (a way in, not a record; not ranked), its sketch where a face is: how many holes, by how many
* makers; a tap opens their screen. */
export function CommunityTile({ community, onOpen }: { community: readonly HoleRow[]; onOpen: () => void }) {
const n = community.length, makers = new Set(community.map((h) => authorOf(h.id)).filter(Boolean)).size;
const sub = `${n} ${plural("hole", n)} · ${makers} ${plural("maker", makers)}`;
return <Tile className="sticker--community" face={<span className="sticker__face"><Sketch /></span>} tag="Not ranked" name="Community holes" sub={sub} go="→"
label={`Community holes: ${sub.replace(" · ", " by ")}, not ranked. See them all`} />;
}
2 changes: 1 addition & 1 deletion web/test/golf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void test("finished_shown waits for this round's best: the hole played again in

void test("the community's holes, a screen of the game's: its title focused as it comes, Escape and Back to the cups, its own address", () => {
assert.ok(/const SCREENS = \[[^\]]*"community"/.test(golf) && golf.includes(`community: "worlds"`), "a screen, the cups before it");
assert.ok(golf.includes(`>() => setScreen("community")}`), "the band under the cups opens it");
assert.ok(golf.includes(`<CommunityTile community={s.community} >() => (sound("select"), setScreen("community"))} />`), "the records row's last tile opens it");
assert.ok(/\|\| screen === "community"\) q\.set\("screen", screen\)/.test(golf) && golf.includes(`p.get("screen") === "community" ? "community"`), "?screen=community: a step Back returns to it, a reload lands on it");
assert.ok(title.includes("screen=(cups|rival|community)\\b"), "its address a link past the title, as the cups': the loader alone, no scene built behind it");
});
Expand Down
Loading
0