The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): share one hover arc sweep across catalog cards
Brooklyn Nicholson5e5869311e19
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-arc.ts b/apps/desktop/src/app/capabilities/catalog/catalog-arc.tsnew file mode 100644index 00000000000..1d7631e3e4e--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-arc.ts@@ -0,0 +1,97 @@+/** One sweep for every card's hover arc.+ *+ * Each hovered (or focused) card runs the arc rotation on the document timeline+ * with `startTime = 0`, so every card sits at the same angle at the same+ * instant: moving from one card to the next carries the sweep on instead of+ * starting it over. The animation outlives the hover by the CSS fade, then is+ * cancelled, so idle cards cost nothing. */++const CARD = '[data-catalog-card]'+const TURN_MS = 2400+const FADE_MS = 400++const arcs = new WeakMap<HTMLElement, { animation: Animation; timer: number }>()+let installs = 0++const reduced = () => matchMedia('(prefers-reduced-motion: reduce)').matches++function start(card: HTMLElement) {+ const current = arcs.get(card)++ if (current) {+ clearTimeout(current.timer)+ current.timer = 0++ return+ }++ if (reduced()) {+ return+ }++ const animation = card.animate({ '--catalog-arc': ['0deg', '360deg'] }, {+ duration: TURN_MS,+ iterations: Infinity,+ pseudoElement: '::after'+ })++ animation.startTime = 0+ arcs.set(card, { animation, timer: 0 })+}++function stop(card: HTMLElement) {+ const current = arcs.get(card)++ if (!current || current.timer) {+ return+ }++ current.timer = window.setTimeout(() => {+ if (card.matches(':hover, :focus-within')) {+ current.timer = 0++ return+ }++ current.animation.cancel()+ arcs.delete(card)+ }, FADE_MS)+}++const cardOf = (node: EventTarget | null) => (node instanceof Element ? node.closest<HTMLElement>(CARD) : null)++function enter(event: Event) {+ const card = cardOf(event.target)++ if (card) {+ start(card)+ }+}++function leave(event: Event) {+ const card = cardOf(event.target)+ const next = cardOf((event as PointerEvent | FocusEvent).relatedTarget)++ if (card && card !== next) {+ stop(card)+ }+}++/** Installs the shared arc once per document; the returned cleanup drops this caller's hold. */+export function syncCatalogArcs() {+ if (installs++ === 0) {+ document.addEventListener('pointerover', enter)+ document.addEventListener('pointerout', leave)+ document.addEventListener('focusin', enter)+ document.addEventListener('focusout', leave)+ }++ return () => {+ if (--installs === 0) {+ document.removeEventListener('pointerover', enter)+ document.removeEventListener('pointerout', leave)+ document.removeEventListener('focusin', enter)+ document.removeEventListener('focusout', leave)+ }+ }+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog.css b/apps/desktop/src/app/capabilities/catalog/catalog.cssnew file mode 100644index 00000000000..8de419f692e--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog.css@@ -0,0 +1,102 @@+/* Registered so the gradient can glide instead of jump. Written per card by+ `trackCatalogPointer`: x/y is the pointer clamped to the card, near is 0–1. */+@property --catalog-x {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 0%;+}++@property --catalog-y {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 0%;+}++@property --catalog-near {+ syntax: '<number>';+ inherits: false;+ initial-value: 0;+}++/* Each card carries one accent (`--catalog-accent`, set by class). Its gradient+ keeps one shape and strength and only its center drifts toward the pointer,+ onto it when on the card. Light surfaces show tint far more than dark ones,+ so light gets a softer wash from the bottom-left; `:root.dark` restores+ the stronger top-left glow. */+[data-catalog-card] {+ /* How far the gradient leans from its rest point toward the pointer: all the+ way on the card itself, falling off fast with distance to the box. */+ --catalog-follow: calc(var(--catalog-near) * var(--catalog-near));+ --catalog-rest-x: 0%;+ --catalog-rest-y: 100%;+ --catalog-tint: 0%;+ --catalog-edge: 0%;+ border-color: transparent;+ background: var(--ui-chat-bubble-background);+ transition:+ border-color 0.1s ease,+ box-shadow 0.1s ease,+ opacity 0.15s ease,+ filter 0.15s ease,+ --catalog-x 5s cubic-bezier(0.2, 0.8, 0.2, 1),+ --catalog-y 5s cubic-bezier(0.2, 0.8, 0.2, 1),+ --catalog-near 5s ease;+}++:root.dark [data-catalog-card] {+ --catalog-rest-x: 0%;+ --catalog-rest-y: 0%;+ --catalog-tint: 0%;+ --catalog-edge: 0%;+}++[data-catalog-card]:is(:hover, :focus-within) {+ border-color: transparent;+ box-shadow: none;+}++/* The arc lives on every card and only its visibility changes: it fades in on+ hover. Its rotation is driven by `syncCatalogArcs` on the document timeline,+ so every card shares one sweep and hovering the next card continues it. */+[data-catalog-card]::after {+ background: conic-gradient(from var(--catalog-arc), transparent 0deg, var(--color-primary) 60deg, transparent 130deg);+ border-radius: inherit;+ content: '';+ inset: 0;+ mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);+ mask-composite: exclude;+ opacity: 0;+ padding: 1.5px;+ pointer-events: none;+ position: absolute;+ transition: opacity 0.35s ease;+}++[data-catalog-card]:is(:hover, :focus-within)::after {+ opacity: 1;+}++@property --catalog-arc { syntax: '<angle>'; inherits: false; initial-value: 0deg; }++/* Uniform alternative to Masonry: same column tracks, cards in a row share one+ height. Rows start at a complete text card (4-line description, two chip+ rows, dates ≈ 250px) and grow for a card with a hero image, so image and+ description always show in full. */+.catalog-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));+ grid-auto-rows: minmax(16rem, auto);+ gap: calc(var(--spacing) * 3);+}++/* Store-browsing feel: hovering one card dims its siblings in the same group. */+[data-catalog-hover-group]:has([data-catalog-card]:hover) [data-catalog-card]:not(:hover) {+ opacity: 1;+ filter: saturate(0.8);+}++@media (prefers-reduced-motion: reduce) {+ [data-catalog-card] {+ transition: border-color 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease, filter 0.15s ease;+ }+}