Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(news): /markets/news reader UI
nirholas8db2b5391b07
diff --git a/pages/markets-news.html b/pages/markets-news.htmlnew file mode 100644index 000000000..3fd83d156--- /dev/null+++ b/pages/markets-news.html@@ -0,0 +1,140 @@+<!doctype html>+<html lang="en" class="cv-page">+ <head>+ <script>+ /* three.ws theme boot — no-flash; runtime in /theme-switcher.js */ (function () {+ try {+ var m = localStorage.getItem('twx_theme');+ var l =+ m === 'auto'+ ? window.matchMedia &&+ window.matchMedia('(prefers-color-scheme: light)').matches+ : m === 'light';+ document.documentElement.setAttribute('data-theme', l ? 'light' : 'dark');+ } catch (e) {+ document.documentElement.setAttribute('data-theme', 'dark');+ }+ })();+ </script>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>Crypto News · three.ws</title>+ <meta+ name="description"+ content="Live crypto news aggregated from 37 publisher feeds — CoinDesk, The Block, Decrypt, CoinTelegraph and more. Filter by category, search headlines, and open any story in a rich reader."+ />+ <meta property="og:type" content="website" />+ <meta property="og:site_name" content="three.ws" />+ <meta property="og:url" content="https://three.ws/markets/news" />+ <meta property="og:title" content="Crypto News · three.ws" />+ <meta+ property="og:description"+ content="Live crypto news aggregated from 37 publisher feeds, filterable by category and searchable — with a rich reader for every story."+ />+ <meta+ property="og:image"+ content="https://three.ws/api/page-og?s=crypto&t=Crypto+News&d=Live+crypto+news+aggregated+from+37+publisher+feeds+%E2%80%94+filter+by+category%2C+search+headlines%2C+and+open+any+story+in+a+rich+reader.&p=%2Fmarkets%2Fnews"+ />+ <meta property="og:image:width" content="1200" />+ <meta property="og:image:height" content="630" />+ <meta name="twitter:card" content="summary_large_image" />+ <meta name="twitter:site" content="@trythreews" />+ <meta name="twitter:title" content="Crypto News · three.ws" />+ <meta+ name="twitter:description"+ content="Live crypto news aggregated from 37 publisher feeds, filterable by category and searchable."+ />+ <meta+ name="twitter:image"+ content="https://three.ws/api/page-og?s=crypto&t=Crypto+News&d=Live+crypto+news+aggregated+from+37+publisher+feeds+%E2%80%94+filter+by+category%2C+search+headlines%2C+and+open+any+story+in+a+rich+reader.&p=%2Fmarkets%2Fnews"+ />+ <meta name="theme-color" content="#09090b" />+ <link rel="icon" href="/favicon.ico" sizes="any" />+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ <link rel="manifest" href="/site.webmanifest" />+ <link rel="stylesheet" href="/fonts/fonts.css" />+ <link rel="stylesheet" href="/nav.css" />+ <link rel="stylesheet" href="/src/coin-pages.css" />+ <link rel="stylesheet" href="/footer.css" />+ <link rel="canonical" href="https://three.ws/markets/news" />+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />+ <meta property="og:locale" content="en_US" />+ <meta property="og:image:alt" content="Crypto News — three.ws" />+ <script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebPage","name":"Crypto News","description":"Live crypto news aggregated from 37 publisher feeds — filterable by category, searchable, with a rich reader for every story.","url":"https://three.ws/markets/news","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}]}</script>+ </head>+ <body>+ <header><div id="nav-container"></div></header>+ <script src="/nav.js"></script>++ <main class="cv-container">+ <nav class="cv-crumbs" aria-label="Breadcrumb">+ <a href="/markets">Markets</a><span class="sep">/</span><span class="here">News</span>+ </nav>+ <h1 class="cv-h1">Crypto News</h1>+ <p class="cv-sub">+ Live headlines aggregated from 37 publisher feeds across the industry — majors,+ research desks, on-chain analysts, exchanges, and regulators. Click any story for a+ rich reader with summary, key points, and related coverage.+ </p>++ <!-- Sibling market surfaces. -->+ <nav class="cv-tools" aria-label="Market tools">+ <a class="cv-pill" href="/markets">Markets Hub</a>+ <a class="cv-pill" href="/markets/news" aria-current="page">News</a>+ <a class="cv-pill" href="/markets/archive">Archive</a>+ <a class="cv-pill" href="/coins">Coins</a>+ <a class="cv-pill" href="/heatmap">Heatmap</a>+ <a class="cv-pill" href="/screener">Screener</a>+ <a class="cv-pill" href="/fear-greed">Fear & Greed</a>+ <a class="cv-pill" href="/gas">Gas</a>+ </nav>++ <!-- Category tabs. Hydrated by src/markets-news.js. -->+ <div id="nw-tabs" class="nw-tabs" role="group" aria-label="News categories"></div>++ <!-- Search + source filter. -->+ <div class="nw-toolbar">+ <div class="cv-search">+ <input+ id="nw-search"+ type="search"+ placeholder="Search headlines — bitcoin etf, solana, hack…"+ aria-label="Search news"+ autocomplete="off"+ />+ </div>+ <select id="nw-source" class="nw-select" aria-label="Filter by source">+ <option value="">All sources</option>+ </select>+ </div>++ <p id="nw-count" class="nw-count" role="status"></p>++ <!-- Lead story + article grid. Hydrated by src/markets-news.js. -->+ <section id="nw-feed" class="cv-section" aria-label="News feed" aria-live="polite"></section>++ <div style="display: flex; justify-content: center; margin: 1.5rem 0 0">+ <button id="nw-more" class="cv-load-more" type="button" hidden>Load more stories</button>+ </div>++ <!-- Archive cross-link. -->+ <section class="cv-section" aria-label="Historical archive">+ <div class="art-preview-note" style="margin-top: 2rem">+ <span aria-hidden="true">🗞</span>+ <span>+ Looking for older coverage? The+ <a href="/markets/archive">news archive</a> holds+ <strong>662,047 articles back to September 2017</strong> — searchable by+ ticker, date, source, sentiment, and language.+ </span>+ </div>+ </section>+ </main>++ <script type="module" src="/src/markets-news.js"></script>+ <script src="/brand.js" defer></script>+ <div id="footer-container"></div>+ <script src="/footer.js"></script>+ </body>+</html>diff --git a/src/coin-pages.css b/src/coin-pages.cssindex 6c7be93c7..dbf05d370 100644--- a/src/coin-pages.css+++ b/src/coin-pages.css@@ -1718,3 +1718,737 @@ a.cv-liq-item:focus-visible {max-width: none;}}++/* ═══════════════════════════════════════════════════════════════════════════+ Crypto News — /markets/news, /markets/news/article, /markets/archive+ Same token/card system as the coin pages and market tools above.+ ═══════════════════════════════════════════════════════════════════════════ */++/* ── Filter tabs (scrollable pill row) ─────────────────────────────────── */++.nw-tabs {+ display: flex;+ gap: 0.5rem;+ overflow-x: auto;+ padding: 0.25rem 0.125rem 0.625rem;+ margin: 0 0 0.75rem;+ scrollbar-width: thin;+ -webkit-overflow-scrolling: touch;+}+.nw-tab {+ flex-shrink: 0;+ padding: 0.375rem 0.875rem;+ border-radius: 999px;+ border: 1px solid var(--cv-border);+ background: var(--cv-surface);+ color: var(--cv-text-2);+ font-size: 0.8125rem;+ font-weight: 500;+ cursor: pointer;+ transition: color 0.15s, border-color 0.15s, background 0.15s;+}+.nw-tab:hover {+ color: var(--cv-text);+ border-color: var(--cv-border-hover);+}+.nw-tab:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 2px;+}+.nw-tab[aria-pressed='true'] {+ background: var(--cv-text);+ color: var(--cv-surface);+ border-color: var(--cv-text);+}++.nw-toolbar {+ display: flex;+ flex-wrap: wrap;+ gap: 0.75rem;+ align-items: center;+ margin: 0 0 1.25rem;+}+.nw-toolbar .cv-search {+ flex: 1 1 240px;+}+.nw-select {+ appearance: none;+ padding: 0.5rem 2rem 0.5rem 0.875rem;+ border-radius: var(--cv-radius-md);+ border: 1px solid var(--cv-border);+ background: var(--cv-surface)+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")+ no-repeat right 0.75rem center;+ color: var(--cv-text);+ font: inherit;+ font-size: 0.875rem;+ cursor: pointer;+ transition: border-color 0.15s;+}+.nw-select:hover {+ border-color: var(--cv-border-hover);+}+.nw-select:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 1px;+}++/* ── Lead story + card grid ────────────────────────────────────────────── */++.nw-hero {+ display: grid;+ gap: 1.25rem;+ margin: 0 0 1.5rem;+ padding: 0;+ background: var(--cv-surface);+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-xl);+ box-shadow: var(--cv-shadow-card);+ overflow: hidden;+ cursor: pointer;+ transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;+}+.nw-hero:hover {+ box-shadow: var(--cv-shadow-card-hover);+ border-color: var(--cv-border-hover);+ transform: translateY(-2px);+}+.nw-hero:focus-within {+ border-color: var(--cv-accent);+}+@media (min-width: 760px) {+ .nw-hero {+ grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);+ }+}+.nw-hero-media {+ min-height: 220px;+ background: var(--cv-surface-2);+}+.nw-hero-media img {+ width: 100%;+ height: 100%;+ max-height: 340px;+ object-fit: cover;+ display: block;+}+.nw-hero-body {+ padding: 1.25rem 1.5rem 1.5rem;+ display: flex;+ flex-direction: column;+ gap: 0.625rem;+ justify-content: center;+}+.nw-hero-body h2 {+ font-size: 1.375rem;+ line-height: 1.3;+ margin: 0;+ font-family: var(--cv-font-serif, inherit);+}+.nw-hero-body h2 a {+ color: inherit;+ text-decoration: none;+}+.nw-hero-body h2 a:hover {+ text-decoration: underline;+ text-underline-offset: 3px;+}++.nw-grid {+ display: grid;+ gap: 1rem;+ grid-template-columns: 1fr;+}+@media (min-width: 640px) {+ .nw-grid {+ grid-template-columns: repeat(2, 1fr);+ }+}+@media (min-width: 1024px) {+ .nw-grid {+ grid-template-columns: repeat(3, 1fr);+ }+}++.nw-card {+ display: flex;+ flex-direction: column;+ background: var(--cv-surface);+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-lg);+ box-shadow: var(--cv-shadow-card);+ overflow: hidden;+ cursor: pointer;+ transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;+}+.nw-card:hover {+ box-shadow: var(--cv-shadow-card-hover);+ border-color: var(--cv-border-hover);+ transform: translateY(-2px);+}+.nw-card:focus-within {+ border-color: var(--cv-accent);+}+.nw-media {+ position: relative;+ aspect-ratio: 16 / 9;+ background: var(--cv-surface-2);+ overflow: hidden;+}+.nw-media img {+ width: 100%;+ height: 100%;+ object-fit: cover;+ display: block;+ transition: transform 0.3s;+}+.nw-card:hover .nw-media img {+ transform: scale(1.03);+}+.nw-fallback {+ position: absolute;+ inset: 0;+ display: flex;+ align-items: center;+ justify-content: center;+ font-size: 2.25rem;+ font-weight: 700;+ color: var(--cv-text-3);+ background: linear-gradient(135deg, var(--cv-surface-2), var(--cv-surface-3));+ letter-spacing: 0.05em;+}+.nw-body {+ display: flex;+ flex-direction: column;+ gap: 0.5rem;+ padding: 0.875rem 1rem 1rem;+ flex: 1;+}+.nw-meta {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ font-size: 0.75rem;+ color: var(--cv-text-3);+ min-width: 0;+}+.nw-src {+ font-weight: 600;+ color: var(--cv-text-2);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}+.nw-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ flex-shrink: 0;+ background: var(--cv-text-3);+}+.nw-dot.pos {+ background: var(--cv-green, #22c55e);+}+.nw-dot.neg {+ background: var(--cv-red, #ef4444);+}+.nw-title {+ font-size: 0.9375rem;+ font-weight: 600;+ line-height: 1.35;+ margin: 0;+ display: -webkit-box;+ -webkit-line-clamp: 3;+ -webkit-box-orient: vertical;+ overflow: hidden;+}+.nw-title a {+ color: inherit;+ text-decoration: none;+}+.nw-title a:hover {+ text-decoration: underline;+ text-underline-offset: 3px;+}+.nw-desc {+ font-size: 0.8125rem;+ color: var(--cv-text-2);+ line-height: 1.5;+ margin: 0;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ -webkit-box-orient: vertical;+ overflow: hidden;+}+.nw-chips {+ display: flex;+ flex-wrap: wrap;+ gap: 0.375rem;+ margin-top: auto;+ padding-top: 0.25rem;+}+.nw-chip {+ font-size: 0.6875rem;+ font-weight: 600;+ padding: 0.125rem 0.5rem;+ border-radius: 999px;+ background: var(--cv-surface-2);+ border: 1px solid var(--cv-border);+ color: var(--cv-text-2);+ cursor: pointer;+ transition: border-color 0.15s, color 0.15s;+}+.nw-chip:hover {+ border-color: var(--cv-border-hover);+ color: var(--cv-text);+}+.nw-chip:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 1px;+}++.nw-count {+ font-size: 0.8125rem;+ color: var(--cv-text-3);+ margin: 0 0 1rem;+}++/* ── Article reader ────────────────────────────────────────────────────── */++.art-hero {+ border-radius: var(--cv-radius-xl);+ overflow: hidden;+ margin: 0 0 1.25rem;+ border: 1px solid var(--cv-border);+ background: var(--cv-surface-2);+}+.art-hero img {+ width: 100%;+ max-height: 420px;+ object-fit: cover;+ display: block;+}+.art-title {+ font-size: clamp(1.5rem, 3.5vw, 2.25rem);+ line-height: 1.2;+ margin: 0 0 0.75rem;+ font-family: var(--cv-font-serif, inherit);+}+.art-byline {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 0.5rem 1rem;+ font-size: 0.8125rem;+ color: var(--cv-text-3);+ margin: 0 0 1.5rem;+}+.art-byline .src {+ font-weight: 600;+ color: var(--cv-text-2);+}+.art-badge {+ display: inline-flex;+ align-items: center;+ gap: 0.375rem;+ padding: 0.1875rem 0.625rem;+ border-radius: 999px;+ font-size: 0.75rem;+ font-weight: 600;+ border: 1px solid var(--cv-border);+ background: var(--cv-surface-2);+ color: var(--cv-text-2);+}+.art-badge.bullish {+ color: var(--cv-green, #22c55e);+ border-color: color-mix(in srgb, var(--cv-green, #22c55e) 35%, transparent);+ background: color-mix(in srgb, var(--cv-green, #22c55e) 10%, transparent);+}+.art-badge.bearish {+ color: var(--cv-red, #ef4444);+ border-color: color-mix(in srgb, var(--cv-red, #ef4444) 35%, transparent);+ background: color-mix(in srgb, var(--cv-red, #ef4444) 10%, transparent);+}+.art-layout {+ display: grid;+ gap: 2rem;+ grid-template-columns: 1fr;+}+@media (min-width: 960px) {+ .art-layout {+ grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);+ align-items: start;+ }+}+.art-summary-card {+ background: var(--cv-surface);+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-xl);+ box-shadow: var(--cv-shadow-card);+ padding: 1.25rem 1.5rem;+ margin: 0 0 1.5rem;+}+.art-summary-card h2 {+ font-size: 0.75rem;+ text-transform: uppercase;+ letter-spacing: 0.08em;+ color: var(--cv-text-3);+ margin: 0 0 0.625rem;+}+.art-summary-card p {+ margin: 0 0 0.75rem;+ line-height: 1.6;+}+.art-keypoints {+ margin: 0;+ padding: 0 0 0 1.125rem;+ display: flex;+ flex-direction: column;+ gap: 0.5rem;+ line-height: 1.5;+ font-size: 0.9375rem;+}+.art-provider {+ font-size: 0.6875rem;+ color: var(--cv-text-3);+ margin: 0.75rem 0 0;+}+.art-prose {+ font-size: 1.0625rem;+ line-height: 1.75;+ max-width: 70ch;+}+.art-prose p {+ margin: 0 0 1.125rem;+}+.art-preview-note {+ display: flex;+ gap: 0.75rem;+ align-items: flex-start;+ padding: 1rem 1.25rem;+ border: 1px solid var(--cv-border);+ border-left: 3px solid var(--cv-accent);+ border-radius: var(--cv-radius-lg);+ background: var(--cv-surface-2);+ font-size: 0.9375rem;+ line-height: 1.55;+ margin: 0 0 1.5rem;+}+.art-cta {+ display: inline-flex;+ align-items: center;+ gap: 0.5rem;+ padding: 0.625rem 1.25rem;+ border-radius: var(--cv-radius-md);+ background: var(--cv-text);+ color: var(--cv-surface);+ font-weight: 600;+ font-size: 0.9375rem;+ text-decoration: none;+ transition: opacity 0.15s, transform 0.15s;+}+.art-cta:hover {+ opacity: 0.85;+}+.art-cta:active {+ transform: scale(0.98);+}+.art-cta:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 2px;+}+.art-rail h2 {+ font-size: 1rem;+ margin: 0 0 0.875rem;+}+.art-rail .nw-grid {+ grid-template-columns: 1fr;+}++/* ── Archive explorer ──────────────────────────────────────────────────── */++.arc-stats {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));+ gap: 0.75rem;+ margin: 0 0 1.5rem;+}+.arc-filters {+ display: grid;+ gap: 0.75rem;+ grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));+ align-items: end;+ background: var(--cv-surface);+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-xl);+ box-shadow: var(--cv-shadow-card);+ padding: 1rem 1.25rem 1.25rem;+ margin: 0 0 1rem;+}+.arc-field {+ display: flex;+ flex-direction: column;+ gap: 0.3125rem;+ min-width: 0;+}+.arc-field label {+ font-size: 0.6875rem;+ font-weight: 600;+ text-transform: uppercase;+ letter-spacing: 0.06em;+ color: var(--cv-text-3);+}+.arc-field input,+.arc-field select {+ padding: 0.5rem 0.75rem;+ border-radius: var(--cv-radius-md);+ border: 1px solid var(--cv-border);+ background: var(--cv-surface-2);+ color: var(--cv-text);+ font: inherit;+ font-size: 0.875rem;+ min-width: 0;+ transition: border-color 0.15s;+}+.arc-field input:hover,+.arc-field select:hover {+ border-color: var(--cv-border-hover);+}+.arc-field input:focus-visible,+.arc-field select:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 1px;+}+.arc-actions {+ display: flex;+ gap: 0.5rem;+}+.arc-btn {+ padding: 0.5rem 1.125rem;+ border-radius: var(--cv-radius-md);+ border: 1px solid var(--cv-text);+ background: var(--cv-text);+ color: var(--cv-surface);+ font: inherit;+ font-size: 0.875rem;+ font-weight: 600;+ cursor: pointer;+ transition: opacity 0.15s, transform 0.1s;+}+.arc-btn:hover {+ opacity: 0.85;+}+.arc-btn:active {+ transform: scale(0.97);+}+.arc-btn:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 2px;+}+.arc-btn.ghost {+ background: transparent;+ color: var(--cv-text-2);+ border-color: var(--cv-border);+}+.arc-btn.ghost:hover {+ border-color: var(--cv-border-hover);+ color: var(--cv-text);+ opacity: 1;+}+.arc-years {+ display: flex;+ flex-wrap: wrap;+ gap: 0.375rem;+ margin: 0 0 1.25rem;+}+.arc-coverage {+ font-size: 0.8125rem;+ color: var(--cv-text-3);+ margin: 0 0 0.875rem;+ line-height: 1.5;+}+.arc-list {+ display: flex;+ flex-direction: column;+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-xl);+ background: var(--cv-surface);+ box-shadow: var(--cv-shadow-card);+ overflow: hidden;+}+.arc-row {+ display: grid;+ grid-template-columns: 92px 10px minmax(0, 1fr) auto;+ gap: 0.75rem;+ align-items: baseline;+ padding: 0.75rem 1.125rem;+ border-bottom: 1px solid var(--cv-border);+ font-size: 0.875rem;+ transition: background 0.12s;+}+.arc-row:last-child {+ border-bottom: 0;+}+.arc-row:hover {+ background: var(--cv-surface-2);+}+.arc-date {+ font-size: 0.75rem;+ color: var(--cv-text-3);+ font-variant-numeric: tabular-nums;+ white-space: nowrap;+}+.arc-row .nw-dot {+ align-self: center;+}+.arc-title {+ min-width: 0;+ line-height: 1.45;+}+.arc-title a {+ color: var(--cv-text);+ text-decoration: none;+ font-weight: 500;+}+.arc-title a:hover {+ text-decoration: underline;+ text-underline-offset: 3px;+}+.arc-title .lang {+ font-size: 0.625rem;+ font-weight: 700;+ vertical-align: 2px;+ margin-left: 0.375rem;+ padding: 0.0625rem 0.3125rem;+ border-radius: 4px;+ border: 1px solid var(--cv-border);+ color: var(--cv-text-3);+}+.arc-src {+ font-size: 0.75rem;+ color: var(--cv-text-3);+ white-space: nowrap;+}+@media (max-width: 640px) {+ .arc-row {+ grid-template-columns: 10px minmax(0, 1fr);+ }+ .arc-date,+ .arc-src {+ display: none;+ }+}++/* ── /markets hub ──────────────────────────────────────────────────────── */++.mkt-suite {+ display: grid;+ gap: 0.875rem;+ grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));+ margin: 0 0 2rem;+}+.mkt-hero-card {+ display: flex;+ flex-direction: column;+ gap: 0.375rem;+ padding: 1rem 1.125rem 1.125rem;+ background: var(--cv-surface);+ border: 1px solid var(--cv-border);+ border-radius: var(--cv-radius-lg);+ box-shadow: var(--cv-shadow-card);+ color: inherit;+ text-decoration: none;+ transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;+}+.mkt-hero-card:hover {+ box-shadow: var(--cv-shadow-card-hover);+ border-color: var(--cv-border-hover);+ transform: translateY(-2px);+}+.mkt-hero-card:focus-visible {+ outline: 2px solid var(--cv-accent);+ outline-offset: 2px;+}+.mkt-hero-card .glyph {+ width: 34px;+ height: 34px;+ border-radius: var(--cv-radius-md);+ display: flex;+ align-items: center;+ justify-content: center;+ background: var(--cv-surface-2);+ border: 1px solid var(--cv-border);+ color: var(--cv-text-2);+ margin-bottom: 0.25rem;+}+.mkt-hero-card .glyph svg {+ width: 18px;+ height: 18px;+}+.mkt-hero-card h3 {+ font-size: 0.9375rem;+ margin: 0;+}+.mkt-hero-card p {+ font-size: 0.8125rem;+ color: var(--cv-text-2);+ line-height: 1.45;+ margin: 0;+}+.mkt-hero-card .stat {+ margin-top: auto;+ padding-top: 0.5rem;+ font-size: 0.8125rem;+ font-weight: 600;+ color: var(--cv-text);+ font-variant-numeric: tabular-nums;+}+.mkt-hero-card .stat .dim {+ color: var(--cv-text-3);+ font-weight: 500;+}+.mkt-cols {+ display: grid;+ gap: 2rem;+ grid-template-columns: 1fr;+ align-items: start;+}+@media (min-width: 1024px) {+ .mkt-cols {+ grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);+ }+}+.mkt-rail {+ display: flex;+ flex-direction: column;+ gap: 1rem;+}+.mkt-rail .nw-grid {+ grid-template-columns: 1fr;+}+.mkt-more {+ display: inline-flex;+ align-items: center;+ gap: 0.375rem;+ font-size: 0.875rem;+ font-weight: 600;+ color: var(--cv-text-2);+ text-decoration: none;+ transition: color 0.15s;+}+.mkt-more:hover {+ color: var(--cv-text);+ text-decoration: underline;+ text-underline-offset: 3px;+}++/* Reduced motion: news/hub cards stay still. */+@media (prefers-reduced-motion: reduce) {+ .nw-card,+ .nw-hero,+ .mkt-hero-card,+ .nw-card:hover .nw-media img {+ transition: none;+ transform: none;+ }+}diff --git a/src/markets-news.js b/src/markets-news.jsnew file mode 100644index 000000000..b6f2630fc--- /dev/null+++ b/src/markets-news.js@@ -0,0 +1,243 @@+// /markets/news — live aggregated crypto news over /api/news/feed (native+// three.ws aggregator, 37 publisher feeds). Category tabs, debounced search,+// source filter, lead-story hero, card grid with sentiment + ticker chips,+// offset pagination. Every story opens the rich reader at+// /markets/news/article; the source link goes straight to the publisher.++import { timeAgo, escapeHtml as esc } from './shared/coin-format.js';+import {+ newsCard,+ newsMedia,+ sentimentDot,+ tickerChips,+ readerHref,+ wireNewsContainer,+} from './shared/news-render.js';++const $ = (id) => document.getElementById(id);+const PAGE_SIZE = 24;++const CATEGORY_LABELS = {+ all: 'All',+ general: 'Top',+ bitcoin: 'Bitcoin',+ ethereum: 'Ethereum',+ layer2: 'Layer 2',+ solana: 'Solana',+ defi: 'DeFi',+ nft: 'NFT',+ trading: 'Trading',+ research: 'Research',+ onchain: 'On-chain',+ institutional: 'Institutional',+ mainstream: 'Mainstream',+ asia: 'Asia',+ regulation: 'Regulation',+ journalism: 'Journalism',+};++const state = {+ category: 'all',+ q: '',+ source: '',+ offset: 0,+ articles: [],+ total: 0,+ sourcesOk: 0,+ sourcesTotal: 0,+ loading: false,+ meta: null,+};++async function getJson(url) {+ const res = await fetch(url, { headers: { accept: 'application/json' } });+ if (!res.ok) {+ const err = new Error(`fetch ${url} → ${res.status}`);+ err.status = res.status;+ throw err;+ }+ return res.json();+}++function feedUrl(offset) {+ const p = new URLSearchParams();+ if (state.category && state.category !== 'all') p.set('category', state.category);+ if (state.q) p.set('q', state.q);+ if (state.source) p.set('source', state.source);+ p.set('limit', String(PAGE_SIZE));+ p.set('offset', String(offset));+ if (!state.meta) p.set('meta', '1');+ return `/api/news/feed?${p}`;+}++function syncUrl() {+ const p = new URLSearchParams();+ if (state.category !== 'all') p.set('category', state.category);+ if (state.q) p.set('q', state.q);+ if (state.source) p.set('source', state.source);+ const qs = p.toString();+ history.replaceState(null, '', qs ? `/markets/news?${qs}` : '/markets/news');+}++function heroHtml(a) {+ return `+ <article class="nw-hero" data-href="${esc(readerHref(a))}">+ ${newsMedia(a, { heroic: true })}+ <div class="nw-hero-body">+ <div class="nw-meta">${sentimentDot(a)}<span class="nw-src">${esc(a.source)}</span><span>·</span><time datetime="${esc(a.pub_date || '')}">${a.pub_date ? esc(timeAgo(a.pub_date)) : ''}</time></div>+ <h2><a href="${esc(readerHref(a))}">${esc(a.title)}</a></h2>+ ${a.description ? `<p class="nw-desc" style="-webkit-line-clamp:3">${esc(a.description)}</p>` : ''}+ ${tickerChips(a)}+ </div>+ </article>`;+}++function skeleton() {+ const card = `<div class="nw-card" aria-hidden="true"><div class="nw-media cv-skel"></div>+ <div class="nw-body"><div class="cv-skel" style="height:0.75rem;width:40%"></div>+ <div class="cv-skel" style="height:1rem"></div><div class="cv-skel" style="height:1rem;width:80%"></div></div></div>`;+ return `<div class="nw-grid">${card.repeat(9)}</div>`;+}++function render() {+ const feedEl = $('nw-feed');+ const { articles } = state;+ if (!articles.length) {+ feedEl.innerHTML = `+ <div class="cv-empty">+ <p><strong>No stories match.</strong></p>+ <p>Try a different search, another category, or browse the+ <a href="/markets/archive">662k-article archive</a> for older coverage.</p>+ </div>`;+ $('nw-count').textContent = '';+ $('nw-more').hidden = true;+ return;+ }+ const showHero = !state.q && !state.source && articles[0]?.image;+ const heroA = showHero ? articles[0] : null;+ const rest = showHero ? articles.slice(1) : articles;+ feedEl.innerHTML = `${heroA ? heroHtml(heroA) : ''}<div class="nw-grid">${rest.map((a) => newsCard(a)).join('')}</div>`;+ const src = state.meta?.sources?.find((s) => s.key === state.source);+ $('nw-count').textContent =+ `${state.total.toLocaleString()} stories · ${state.sourcesOk}/${state.sourcesTotal} feeds live` ++ (state.category !== 'all' ? ` · ${CATEGORY_LABELS[state.category] || state.category}` : '') ++ (src ? ` · ${src.name}` : '') ++ (state.q ? ` · “${state.q}”` : '');+ $('nw-more').hidden = state.articles.length >= state.total;+}++async function load({ append = false } = {}) {+ if (state.loading) return;+ state.loading = true;+ const feedEl = $('nw-feed');+ const moreBtn = $('nw-more');+ if (!append) {+ state.offset = 0;+ feedEl.innerHTML = skeleton();+ $('nw-count').textContent = '';+ } else {+ moreBtn.disabled = true;+ moreBtn.textContent = 'Loading…';+ }+ try {+ const data = await getJson(feedUrl(append ? state.offset : 0));+ if (data.categories && data.sources) {+ state.meta = { categories: data.categories, sources: data.sources };+ hydrateFilters();+ }+ state.total = data.total;+ state.sourcesOk = data.sources_ok;+ state.sourcesTotal = data.sources_total;+ state.articles = append ? state.articles.concat(data.articles) : data.articles;+ state.offset = state.articles.length;+ render();+ } catch (err) {+ feedEl.innerHTML = `+ <div class="cv-empty">+ <p><strong>Couldn’t load the news feed.</strong></p>+ <p>${err.status === 429 ? 'You’re moving fast — give it a few seconds and retry.' : 'The aggregator didn’t respond. It usually recovers on its own.'}</p>+ <p><button class="arc-btn" type="button" id="nw-retry">Retry</button></p>+ </div>`;+ document.getElementById('nw-retry')?.addEventListener('click', () => load());+ } finally {+ state.loading = false;+ moreBtn.disabled = false;+ moreBtn.textContent = 'Load more stories';+ }+}++function renderTabs() {+ const cats = state.meta?.categories ? ['all', ...state.meta.categories] : Object.keys(CATEGORY_LABELS);+ $('nw-tabs').innerHTML = cats+ .map(+ (c) =>+ `<button class="nw-tab" type="button" data-cat="${esc(c)}" aria-pressed="${String(c === state.category)}">${esc(CATEGORY_LABELS[c] || c)}</button>`,+ )+ .join('');+}++function hydrateFilters() {+ renderTabs();+ const sel = $('nw-source');+ const current = state.source;+ sel.innerHTML =+ '<option value="">All sources</option>' ++ (state.meta?.sources || [])+ .slice()+ .sort((a, b) => a.name.localeCompare(b.name))+ .map((s) => `<option value="${esc(s.key)}"${s.key === current ? ' selected' : ''}>${esc(s.name)}</option>`)+ .join('');+}++function applyTicker(ticker) {+ state.q = ticker;+ $('nw-search').value = ticker;+ syncUrl();+ load();+}++function wireEvents() {+ $('nw-tabs').addEventListener('click', (e) => {+ const btn = e.target.closest('[data-cat]');+ if (!btn) return;+ state.category = btn.dataset.cat;+ for (const t of $('nw-tabs').querySelectorAll('.nw-tab')) {+ t.setAttribute('aria-pressed', String(t.dataset.cat === state.category));+ }+ syncUrl();+ load();+ });++ let debounce;+ $('nw-search').addEventListener('input', (e) => {+ clearTimeout(debounce);+ debounce = setTimeout(() => {+ state.q = e.target.value.trim();+ syncUrl();+ load();+ }, 300);+ });++ $('nw-source').addEventListener('change', (e) => {+ state.source = e.target.value;+ syncUrl();+ load();+ });++ $('nw-more').addEventListener('click', () => load({ append: true }));+ wireNewsContainer($('nw-feed'), { onTicker: applyTicker });+}++function init() {+ const p = new URLSearchParams(location.search);+ state.category = p.get('category') || 'all';+ state.q = p.get('q') || '';+ state.source = p.get('source') || '';+ if (state.q) $('nw-search').value = state.q;+ if (!CATEGORY_LABELS[state.category]) state.category = 'all';+ renderTabs();+ wireEvents();+ load();+}++init();diff --git a/src/shared/news-render.js b/src/shared/news-render.jsnew file mode 100644index 000000000..0d416a371--- /dev/null+++ b/src/shared/news-render.js@@ -0,0 +1,90 @@+// Shared renderers for crypto-news cards — used by /markets/news,+// /markets/news/article (related rail), and the /markets hub news column.+// Pure functions + one event wirer; no module side effects.++import { timeAgo, escapeHtml as esc } from './coin-format.js';++/** Reader-page href carrying enough metadata for instant first paint. */+export function readerHref(a) {+ const p = new URLSearchParams({ url: a.link, title: a.title, source: a.source });+ if (a.image) p.set('image', a.image);+ return `/markets/news/article?${p}`;+}++export function sentimentDot(a) {+ const label = a.sentiment?.label || 'neutral';+ const cls = label.includes('positive') ? 'pos' : label.includes('negative') ? 'neg' : '';+ return `<span class="nw-dot ${cls}" title="Sentiment: ${esc(label.replace('_', ' '))}"></span>`;+}++export function tickerChips(a, { max = 4 } = {}) {+ if (!a.tickers?.length) return '';+ return `<div class="nw-chips">${a.tickers+ .slice(0, max)+ .map(+ (t) =>+ `<button class="nw-chip" type="button" data-ticker="${esc(t)}" aria-label="Search news for ${esc(t)}">${esc(t)}</button>`,+ )+ .join('')}</div>`;+}++export function newsMedia(a, { heroic = false } = {}) {+ const cls = heroic ? 'nw-hero-media' : 'nw-media';+ const initials = esc((a.source || '?').slice(0, 2).toUpperCase());+ if (a.image) {+ return `<div class="${cls}" style="position:relative"><img src="${esc(a.image)}" alt="" loading="lazy" decoding="async" data-fallback="${initials}" /></div>`;+ }+ return `<div class="${cls}" style="position:relative"><div class="nw-fallback">${initials}</div></div>`;+}++export function newsCard(a, { chips = true, desc = true } = {}) {+ return `+ <article class="nw-card" data-href="${esc(readerHref(a))}">+ ${newsMedia(a)}+ <div class="nw-body">+ <div class="nw-meta">${sentimentDot(a)}<span class="nw-src">${esc(a.source)}</span><span>·</span><time datetime="${esc(a.pub_date || '')}">${a.pub_date ? esc(timeAgo(a.pub_date)) : ''}</time></div>+ <h3 class="nw-title"><a href="${esc(readerHref(a))}">${esc(a.title)}</a></h3>+ ${desc && a.description ? `<p class="nw-desc">${esc(a.description)}</p>` : ''}+ ${chips ? tickerChips(a) : ''}+ </div>+ </article>`;+}++/**+ * Broken/hotlink-blocked thumbnails become a source-initials tile. Image+ * error events don't bubble, so listen in the capture phase. Also makes+ * data-href cards behave as links (click + Enter) without swallowing real+ * anchors/buttons inside them.+ */+export function wireNewsContainer(container, { onTicker } = {}) {+ container.addEventListener(+ 'error',+ (e) => {+ const img = e.target;+ if (img?.tagName !== 'IMG' || !img.dataset.fallback) return;+ const tile = document.createElement('div');+ tile.className = 'nw-fallback';+ tile.textContent = img.dataset.fallback;+ img.replaceWith(tile);+ },+ true,+ );+ container.addEventListener('click', (e) => {+ const chip = e.target.closest('[data-ticker]');+ if (chip) {+ e.preventDefault();+ e.stopPropagation();+ if (onTicker) onTicker(chip.dataset.ticker);+ else window.location.href = `/markets/news?q=${encodeURIComponent(chip.dataset.ticker)}`;+ return;+ }+ if (e.target.closest('a, button')) return;+ const card = e.target.closest('[data-href]');+ if (card) window.location.href = card.dataset.href;+ });+ container.addEventListener('keydown', (e) => {+ if (e.key !== 'Enter') return;+ const card = e.target.closest('[data-href]');+ if (card && !e.target.closest('a, button')) window.location.href = card.dataset.href;+ });+}