Skip to content

Commit 84755c1

Browse files
Refine landing overlay and library order (#81)
1 parent 5b489d0 commit 84755c1

5 files changed

Lines changed: 78 additions & 16 deletions

File tree

playground/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,9 @@ <h1 class="headline">
177177
<div class="studio-hud"><span id="hero-phase">Drop into the landing</span></div>
178178
</div>
179179

180-
<!-- Contact-phase excerpt, kept below the viewer so it never hides the motion. -->
180+
<!-- Compact contact-phase excerpt, pinned above the motion on wide screens. -->
181181
<pre class="code-chip" aria-hidden="true"># contact-phase excerpt
182-
<span class="t-kw">posecode</span> <span class="t-kind">posture</span> <span class="t-str">"Superhero Three-Point Landing"</span>
183-
<span class="t-kw">pose</span> start <span class="t-punct">=</span> <span class="t-atom">standing</span>
184-
185-
<span class="t-kw">step</span> <span class="t-str">"Make three-point contact"</span> <span class="t-num">0.3s</span> <span class="t-atom">settle</span><span class="t-punct">:</span>
182+
<span class="t-kw">step</span> <span class="t-str">"Make three-point contact"</span> <span class="t-num">0.3s</span> <span class="t-atom">settle</span><span class="t-punct">:</span>
186183
<span class="t-kw">ground-lock</span><span class="t-punct">:</span> <span class="t-atom">foot_right</span>
187184
<span class="t-kw">reach</span><span class="t-punct">:</span> <span class="t-atom">knee_left floor</span>
188185
<span class="t-kw">reach</span><span class="t-punct">:</span> <span class="t-atom">fist_left floor</span>

playground/src/landing.css

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,20 @@ a.dev-card:hover {
775775
.studio-bar { background: #0d0f10; }
776776
.studio-bar .dots { display: none; }
777777
.code-chip {
778-
position: static;
778+
position: absolute;
779+
z-index: 2;
780+
top: 44px;
781+
right: -28px;
782+
bottom: auto;
779783
width: max-content;
780-
max-width: 100%;
784+
max-width: calc(100% - 48px);
781785
box-sizing: border-box;
782-
margin: 14px 0 0 auto;
783-
overflow-x: auto;
786+
margin: 0;
787+
overflow: hidden;
788+
pointer-events: none;
789+
padding: 12px 14px;
790+
font-size: 10.5px;
791+
line-height: 1.6;
784792
border-radius: 2px;
785793
background: #0b0d0e;
786794
backdrop-filter: none;
@@ -847,6 +855,14 @@ a.dev-card:hover {
847855
@media (max-width: 920px) {
848856
.hero { grid-template-columns: 1fr; min-height: auto; }
849857
.headline { max-width: 12ch; }
858+
.code-chip {
859+
position: static;
860+
width: max-content;
861+
max-width: 100%;
862+
margin: 14px 0 0 auto;
863+
overflow-x: auto;
864+
pointer-events: auto;
865+
}
850866
.prop:nth-child(2) { border-left: 1px solid var(--border); }
851867
.example-card:nth-child(3n + 1) { border-left: 0; }
852868
.example-card:nth-child(2n + 1) { border-left: 1px solid var(--border); }

playground/src/library-order.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** Movement promoted to the first visible library group when it matches. */
2+
export const FEATURED_LIBRARY_MOVEMENT_ID = "jumping-jacks";
3+
4+
/** Keep filtering stable while promoting the featured launch movement. */
5+
export function prioritizeFeaturedMovement<T extends { id: string }>(
6+
movements: readonly T[],
7+
): T[] {
8+
const featured: T[] = [];
9+
const remaining: T[] = [];
10+
for (const movement of movements) {
11+
(movement.id === FEATURED_LIBRARY_MOVEMENT_ID ? featured : remaining).push(movement);
12+
}
13+
return [...featured, ...remaining];
14+
}

playground/src/main.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "./nice-share.js";
1919
import type { PosecodeEditor } from "./editor.js";
2020
import { ANIMATION_PROGRESS_MESSAGE, PRESETS } from "./presets.js";
21+
import { prioritizeFeaturedMovement } from "./library-order.js";
2122
import { SHOWCASE_CLIPS } from "./clips.js";
2223

2324
// Open on a deterministic, fully procedural movement. Mocap-backed or
@@ -363,13 +364,15 @@ function fold(s: string): string {
363364

364365
function libraryMatches(): typeof PRESETS {
365366
const q = fold(libQuery.trim());
366-
return PRESETS.filter(
367-
(p) =>
368-
(!libDomain || p.domain === libDomain) &&
369-
(!libLevel || p.difficulty === libLevel) &&
370-
(!libStatus || p.status === libStatus) &&
371-
(!q ||
372-
fold(`${p.label} ${p.target} ${p.domain} ${p.bodyPart} ${p.equipment}`).includes(q)),
367+
return prioritizeFeaturedMovement(
368+
PRESETS.filter(
369+
(p) =>
370+
(!libDomain || p.domain === libDomain) &&
371+
(!libLevel || p.difficulty === libLevel) &&
372+
(!libStatus || p.status === libStatus) &&
373+
(!q ||
374+
fold(`${p.label} ${p.target} ${p.domain} ${p.bodyPart} ${p.equipment}`).includes(q)),
375+
),
373376
);
374377
}
375378

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, expect, it } from "vitest";
2+
import {
3+
FEATURED_LIBRARY_MOVEMENT_ID,
4+
prioritizeFeaturedMovement,
5+
} from "../src/library-order.js";
6+
7+
describe("movement library ordering", () => {
8+
it("promotes Jumping jacks ahead of otherwise stable results", () => {
9+
const movements = [
10+
{ id: "squat" },
11+
{ id: FEATURED_LIBRARY_MOVEMENT_ID },
12+
{ id: "deadlift" },
13+
];
14+
15+
expect(prioritizeFeaturedMovement(movements).map((movement) => movement.id)).toEqual([
16+
"jumping-jacks",
17+
"squat",
18+
"deadlift",
19+
]);
20+
expect(movements.map((movement) => movement.id)).toEqual([
21+
"squat",
22+
"jumping-jacks",
23+
"deadlift",
24+
]);
25+
});
26+
27+
it("preserves result order when Jumping jacks does not match the filters", () => {
28+
const movements = [{ id: "squat" }, { id: "deadlift" }];
29+
30+
expect(prioritizeFeaturedMovement(movements)).toEqual(movements);
31+
});
32+
});

0 commit comments

Comments
 (0)