example.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>Acme · Team Dashboard</title>
  7. <style>
  8. :root {
  9. --bg: #ffffff;
  10. --bg-soft: #f7f6f3;
  11. --bg-hover: #efeeec;
  12. --ink: #37352f;
  13. --ink-2: #787774;
  14. --ink-3: #9b9a97;
  15. --line: #ececea;
  16. --line-strong: #d3d1cb;
  17. --accent: #2eaadc;
  18. --accent-ink: #0b6e91;
  19. --pill-done-bg: #dbeddb; --pill-done-ink: #2b593f;
  20. --pill-progress-bg: #fdecc8; --pill-progress-ink: #976d23;
  21. --pill-blocked-bg: #ffe2dd; --pill-blocked-ink: #b13b2c;
  22. --pill-todo-bg: #e9e5e3; --pill-todo-ink: #5a534f;
  23. --pill-review-bg: #d3e5ef; --pill-review-ink: #1f5b78;
  24. --shadow-card: 0 1px 0 rgba(15,15,15,0.04), 0 1px 2px rgba(15,15,15,0.04);
  25. --radius-sm: 4px;
  26. --radius-md: 6px;
  27. --radius-lg: 10px;
  28. }
  29. * { box-sizing: border-box; }
  30. html, body {
  31. margin: 0; padding: 0;
  32. background: var(--bg);
  33. color: var(--ink);
  34. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
  35. "Noto Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
  36. font-size: 14px;
  37. line-height: 1.5;
  38. -webkit-font-smoothing: antialiased;
  39. }
  40. a { color: inherit; text-decoration: none; }
  41. /* ---------- App shell ---------- */
  42. .app {
  43. display: grid;
  44. grid-template-columns: 240px 1fr;
  45. min-height: 100vh;
  46. }
  47. /* ---------- Sidebar ---------- */
  48. .side {
  49. background: var(--bg-soft);
  50. border-right: 1px solid var(--line);
  51. padding: 14px 8px;
  52. user-select: none;
  53. }
  54. .ws {
  55. display: flex; align-items: center; gap: 8px;
  56. padding: 6px 8px; border-radius: var(--radius-sm);
  57. cursor: pointer;
  58. }
  59. .ws:hover { background: var(--bg-hover); }
  60. .ws-icon {
  61. width: 22px; height: 22px; border-radius: 4px;
  62. background: linear-gradient(135deg,#1f1f1f,#3a3a3a);
  63. color: #fff; display: grid; place-items: center;
  64. font-weight: 600; font-size: 12px;
  65. }
  66. .ws-name { font-weight: 600; flex: 1; font-size: 14px; }
  67. .ws-caret { color: var(--ink-3); font-size: 12px; }
  68. .side-search {
  69. margin: 12px 4px 6px; padding: 5px 8px;
  70. color: var(--ink-3); font-size: 13px;
  71. display: flex; align-items: center; gap: 8px;
  72. border-radius: var(--radius-sm); cursor: pointer;
  73. }
  74. .side-search:hover { background: var(--bg-hover); }
  75. .side-search kbd {
  76. margin-left: auto; font-family: inherit; font-size: 11px;
  77. color: var(--ink-3); background: #fff; border: 1px solid var(--line);
  78. padding: 1px 5px; border-radius: 3px;
  79. }
  80. .side-section {
  81. margin-top: 14px; padding: 0 8px;
  82. color: var(--ink-3); font-size: 12px; letter-spacing: .02em;
  83. text-transform: uppercase;
  84. }
  85. .nav { margin-top: 4px; display: flex; flex-direction: column; gap: 1px; }
  86. .nav-item {
  87. display: flex; align-items: center; gap: 8px;
  88. padding: 4px 8px; border-radius: var(--radius-sm);
  89. color: var(--ink); cursor: pointer;
  90. }
  91. .nav-item:hover { background: var(--bg-hover); }
  92. .nav-item.active { background: #e8e6e1; font-weight: 500; }
  93. .nav-icon { width: 18px; text-align: center; }
  94. .nav-caret { margin-left: auto; color: var(--ink-3); font-size: 10px; }
  95. /* ---------- Main ---------- */
  96. .main {
  97. display: flex; flex-direction: column;
  98. min-width: 0;
  99. }
  100. .topbar {
  101. height: 44px; padding: 0 16px;
  102. border-bottom: 1px solid var(--line);
  103. display: flex; align-items: center; gap: 12px;
  104. color: var(--ink-2); font-size: 13px;
  105. }
  106. .crumbs span:not(:last-child)::after {
  107. content: "/"; margin: 0 6px; color: var(--ink-3);
  108. }
  109. .topbar-spacer { flex: 1; }
  110. .pill-live {
  111. display: inline-flex; align-items: center; gap: 6px;
  112. padding: 2px 8px 2px 6px; background: #fff;
  113. border: 1px solid var(--line-strong); border-radius: 999px;
  114. font-size: 12px; color: var(--ink-2);
  115. }
  116. .pill-live .dot {
  117. width: 7px; height: 7px; border-radius: 50%;
  118. background: #2ecc71; box-shadow: 0 0 0 0 rgba(46,204,113,.55);
  119. animation: pulse 1.8s infinite;
  120. }
  121. .pill-live.stale .dot { background: #e6a23c; animation: none; }
  122. /* "Sample data" — no real connector is bound. Stays grey and static
  123. so the artifact does not claim a live data source it does not have. */
  124. .pill-live.sample {
  125. background: var(--bg-soft); color: var(--ink-3);
  126. border-color: var(--line);
  127. }
  128. .pill-live.sample .dot {
  129. background: var(--ink-4); animation: none; box-shadow: none;
  130. }
  131. @keyframes pulse {
  132. 0% { box-shadow: 0 0 0 0 rgba(46,204,113,.55); }
  133. 70% { box-shadow: 0 0 0 7px rgba(46,204,113,0); }
  134. 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
  135. }
  136. .page {
  137. padding: 56px max(80px, 8vw) 80px;
  138. max-width: 1100px;
  139. width: 100%;
  140. align-self: center;
  141. }
  142. .page-cover {
  143. height: 24px; /* keep airy like Notion default */
  144. }
  145. .page-emoji {
  146. font-size: 64px; line-height: 1;
  147. margin: -4px 0 12px; cursor: default;
  148. }
  149. h1.page-title {
  150. font-size: 40px; line-height: 1.15;
  151. font-weight: 700; letter-spacing: -0.01em;
  152. margin: 0 0 8px; color: var(--ink);
  153. }
  154. .page-meta {
  155. display: flex; align-items: center; gap: 14px;
  156. color: var(--ink-2); font-size: 13px; margin-bottom: 28px;
  157. }
  158. .page-meta .updated { display: inline-flex; align-items: center; gap: 6px; }
  159. .page-meta .updated .who {
  160. width: 18px; height: 18px; border-radius: 50%;
  161. background: #f1c40f; color: #5a4500;
  162. display: inline-grid; place-items: center;
  163. font-size: 11px; font-weight: 700;
  164. }
  165. .btn {
  166. display: inline-flex; align-items: center; gap: 6px;
  167. padding: 4px 10px; font-size: 13px; color: var(--ink);
  168. background: #fff; border: 1px solid var(--line-strong);
  169. border-radius: var(--radius-sm); cursor: pointer;
  170. transition: background .15s ease, transform .15s ease;
  171. }
  172. .btn:hover { background: var(--bg-hover); }
  173. .btn .ico { width: 14px; height: 14px; display: inline-block; }
  174. .btn .ico.spin { animation: spin .8s linear infinite; }
  175. @keyframes spin { to { transform: rotate(360deg); } }
  176. .btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
  177. .btn.primary:hover { background: var(--accent-ink); }
  178. .btn.ghost { border-color: transparent; }
  179. .btn.ghost:hover { background: var(--bg-hover); }
  180. /* ---------- Callout ---------- */
  181. .callout {
  182. background: var(--bg-soft);
  183. border-radius: var(--radius-md);
  184. padding: 14px 16px;
  185. display: flex; gap: 12px; align-items: flex-start;
  186. margin: 10px 0 28px;
  187. color: var(--ink);
  188. }
  189. .callout .emj { font-size: 18px; line-height: 1.4; }
  190. .callout small { color: var(--ink-2); }
  191. /* ---------- KPI grid ---------- */
  192. .kpis {
  193. display: grid; grid-template-columns: repeat(4, 1fr);
  194. gap: 1px; background: var(--line);
  195. border: 1px solid var(--line); border-radius: var(--radius-md);
  196. overflow: hidden; margin: 8px 0 32px;
  197. }
  198. .kpi {
  199. background: #fff; padding: 18px 20px;
  200. display: flex; flex-direction: column; gap: 4px;
  201. }
  202. .kpi .label {
  203. color: var(--ink-2); font-size: 12px; letter-spacing: .03em;
  204. text-transform: uppercase; font-weight: 500;
  205. }
  206. .kpi .value {
  207. font-size: 32px; font-weight: 600; letter-spacing: -0.01em;
  208. color: var(--ink);
  209. font-variant-numeric: tabular-nums;
  210. transition: color .25s ease;
  211. }
  212. .kpi .value.flash { color: var(--accent-ink); }
  213. .kpi .delta { font-size: 12px; color: var(--ink-2); }
  214. .kpi .delta.up { color: #2b8a3e; }
  215. .kpi .delta.down { color: #c0392b; }
  216. .kpi .delta .arr { display: inline-block; width: 10px; }
  217. /* ---------- Section heading ---------- */
  218. h2.h {
  219. font-size: 18px; font-weight: 600;
  220. margin: 32px 0 8px; letter-spacing: -0.005em;
  221. }
  222. .h-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 12px; }
  223. /* ---------- Two-col block ---------- */
  224. .two-col {
  225. display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px;
  226. margin-bottom: 8px;
  227. }
  228. /* Sparkline card */
  229. .card {
  230. background: #fff; border: 1px solid var(--line);
  231. border-radius: var(--radius-md); padding: 16px 18px;
  232. }
  233. .card-title {
  234. display: flex; align-items: center; justify-content: space-between;
  235. font-size: 13px; color: var(--ink-2); margin-bottom: 8px;
  236. }
  237. .card-title strong { color: var(--ink); font-weight: 600; }
  238. .spark { width: 100%; height: 120px; }
  239. .spark-axis { color: var(--ink-3); font-size: 11px; }
  240. .spark-fill { fill: rgba(46,170,220,.10); }
  241. .spark-line { fill: none; stroke: var(--accent); stroke-width: 2; }
  242. .spark-dot { fill: var(--accent); }
  243. .spark-grid line { stroke: var(--line); stroke-dasharray: 2 3; }
  244. /* Activity feed */
  245. .feed { display: flex; flex-direction: column; }
  246. .feed-row {
  247. display: flex; gap: 12px; padding: 10px 4px;
  248. border-bottom: 1px solid var(--line);
  249. }
  250. .feed-row:last-child { border-bottom: none; }
  251. .feed-row .av {
  252. flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  253. display: grid; place-items: center;
  254. color: #fff; font-size: 11px; font-weight: 700;
  255. }
  256. .feed-row .body { flex: 1; min-width: 0; font-size: 13px; }
  257. .feed-row .body .who { font-weight: 600; }
  258. .feed-row .body .what { color: var(--ink); }
  259. .feed-row .body .target { color: var(--accent-ink); border-bottom: 1px dotted var(--accent); cursor: pointer; }
  260. .feed-row .time { color: var(--ink-3); font-size: 12px; flex: 0 0 auto; }
  261. .feed-row.new { background: rgba(46,170,220,.06); }
  262. .feed-row.new .body .who::before {
  263. content: "•"; color: var(--accent); margin-right: 6px;
  264. }
  265. /* ---------- Database table ---------- */
  266. .db {
  267. border: 1px solid var(--line); border-radius: var(--radius-md);
  268. overflow: hidden; margin-top: 4px;
  269. background: #fff;
  270. }
  271. .db-head, .db-row {
  272. display: grid;
  273. grid-template-columns: 32px 2.4fr 1fr 1fr 0.9fr 0.9fr;
  274. align-items: center;
  275. padding: 8px 12px;
  276. border-bottom: 1px solid var(--line);
  277. font-size: 13px;
  278. }
  279. .db-head {
  280. background: var(--bg-soft); color: var(--ink-2);
  281. font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  282. font-weight: 500;
  283. }
  284. .db-row:last-child { border-bottom: none; }
  285. .db-row:hover { background: var(--bg-soft); }
  286. .db-row.changed { animation: rowflash 1.4s ease; }
  287. @keyframes rowflash {
  288. 0% { background: rgba(46,170,220,.18); }
  289. 100% { background: transparent; }
  290. }
  291. .db-cell.title { font-weight: 500; display: flex; align-items: center; gap: 6px; min-width: 0; }
  292. .db-cell.title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  293. .db-cell .pill {
  294. display: inline-flex; align-items: center; gap: 4px;
  295. padding: 2px 8px; border-radius: 3px;
  296. font-size: 12px; font-weight: 500;
  297. }
  298. .pill.done { background: var(--pill-done-bg); color: var(--pill-done-ink); }
  299. .pill.progress { background: var(--pill-progress-bg); color: var(--pill-progress-ink); }
  300. .pill.blocked { background: var(--pill-blocked-bg); color: var(--pill-blocked-ink); }
  301. .pill.todo { background: var(--pill-todo-bg); color: var(--pill-todo-ink); }
  302. .pill.review { background: var(--pill-review-bg); color: var(--pill-review-ink); }
  303. .person {
  304. display: inline-flex; align-items: center; gap: 6px;
  305. }
  306. .person .av {
  307. width: 18px; height: 18px; border-radius: 50%;
  308. color: #fff; display: grid; place-items: center;
  309. font-size: 10px; font-weight: 700;
  310. }
  311. /* ---------- Footer ---------- */
  312. .footer {
  313. margin-top: 32px; padding-top: 16px;
  314. border-top: 1px solid var(--line);
  315. color: var(--ink-3); font-size: 12px;
  316. display: flex; align-items: center; gap: 8px;
  317. }
  318. .footer .key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  319. background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; color: var(--ink-2); }
  320. /* ---------- Toast ---------- */
  321. .toast {
  322. position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  323. background: #1f1f1f; color: #fff; padding: 8px 14px;
  324. border-radius: 8px; font-size: 13px;
  325. opacity: 0; pointer-events: none;
  326. transition: opacity .2s ease, transform .2s ease;
  327. }
  328. .toast.show { opacity: 1; transform: translateX(-50%) translateY(-2px); }
  329. @media (prefers-reduced-motion: reduce) {
  330. *, *::before, *::after { animation: none !important; transition: none !important; }
  331. }
  332. @media (max-width: 980px) {
  333. .app { grid-template-columns: 1fr; }
  334. .side { display: none; }
  335. .page { padding: 32px 20px 64px; }
  336. .kpis { grid-template-columns: repeat(2, 1fr); }
  337. .two-col { grid-template-columns: 1fr; }
  338. .db-head, .db-row { grid-template-columns: 24px 1.8fr 0.8fr 0.8fr; }
  339. .db-cell.due, .db-cell.priority { display: none; }
  340. }
  341. </style>
  342. </head>
  343. <body>
  344. <div class="app">
  345. <!-- ============ SIDEBAR ============ -->
  346. <!-- Sidebar rows are interactive — every clickable .ws / .side-search /
  347. .nav-item carries role="button" + tabindex="0" so keyboard users
  348. can reach them. Activation handlers are wired in the script below. -->
  349. <aside class="side">
  350. <div class="ws" role="button" tabindex="0">
  351. <div class="ws-icon">A</div>
  352. <div class="ws-name">Acme Studio</div>
  353. <div class="ws-caret">⌄</div>
  354. </div>
  355. <div class="side-search" role="button" tabindex="0">
  356. <span>🔎</span><span>Search</span><kbd>⌘K</kbd>
  357. </div>
  358. <div class="side-search" role="button" tabindex="0">
  359. <span>⌚</span><span>Updates</span>
  360. </div>
  361. <div class="side-search" role="button" tabindex="0">
  362. <span>⚙️</span><span>Settings & members</span>
  363. </div>
  364. <div class="side-section">Workspace</div>
  365. <div class="nav">
  366. <div class="nav-item active" role="button" tabindex="0" aria-current="page">
  367. <span class="nav-icon">📊</span><span>Team Dashboard</span>
  368. </div>
  369. <div class="nav-item" role="button" tabindex="0">
  370. <span class="nav-icon">✅</span><span>Tasks</span>
  371. <span class="nav-caret">›</span>
  372. </div>
  373. <div class="nav-item" role="button" tabindex="0">
  374. <span class="nav-icon">📓</span><span>Docs</span>
  375. <span class="nav-caret">›</span>
  376. </div>
  377. <div class="nav-item" role="button" tabindex="0">
  378. <span class="nav-icon">🚀</span><span>Roadmap</span>
  379. </div>
  380. <div class="nav-item" role="button" tabindex="0">
  381. <span class="nav-icon">🧠</span><span>Brain dump</span>
  382. </div>
  383. </div>
  384. <div class="side-section">Private</div>
  385. <div class="nav">
  386. <div class="nav-item" role="button" tabindex="0"><span class="nav-icon">🗒️</span><span>Daily journal</span></div>
  387. <div class="nav-item" role="button" tabindex="0"><span class="nav-icon">📥</span><span>Inbox</span></div>
  388. </div>
  389. <div class="side-section">Connections</div>
  390. <div class="nav">
  391. <div class="nav-item" role="button" tabindex="0"><span class="nav-icon">🔌</span><span>Notion · acme.so</span></div>
  392. </div>
  393. </aside>
  394. <!-- ============ MAIN ============ -->
  395. <main class="main">
  396. <div class="topbar">
  397. <div class="crumbs">
  398. <span>Acme Studio</span>
  399. <span>Workspace</span>
  400. <span>Team Dashboard</span>
  401. </div>
  402. <div class="topbar-spacer"></div>
  403. <div class="pill-live sample" id="livePill" title="No connector bound — values below are seeded sample data">
  404. <span class="dot"></span>
  405. <span id="liveText">Sample data</span>
  406. </div>
  407. </div>
  408. <div class="page">
  409. <div class="page-cover"></div>
  410. <div class="page-emoji">📊</div>
  411. <h1 class="page-title">Team Dashboard</h1>
  412. <div class="page-meta">
  413. <div class="updated">
  414. <span class="who">SC</span>
  415. <span>Last edited by <strong>Sarah Chen</strong></span>
  416. </div>
  417. <span>·</span>
  418. <span id="updatedAt">Last refreshed just now</span>
  419. <span style="flex:1"></span>
  420. <button class="btn ghost" id="autoBtn" title="Auto refresh every 30s">
  421. <span>⏱</span><span id="autoLbl">Auto · on</span>
  422. </button>
  423. <button class="btn primary" id="refreshBtn" title="Pull latest from Notion (sample mode — refreshes seeded data)">
  424. <span class="ico" id="refreshIco">↻</span>
  425. <span>Refresh from Notion</span>
  426. </button>
  427. </div>
  428. <div class="callout">
  429. <div class="emj">💡</div>
  430. <div>
  431. <div><strong>This page is a Live Artifact running on sample data.</strong>
  432. The shape mirrors what the <strong>Acme Studio</strong> Notion workspace
  433. would return through the Composio connector — but the numbers, names,
  434. tasks and activity below are seeded fixtures, not a real workspace.</div>
  435. <small>When a connector is bound, the pill switches to <em>Live · synced</em>
  436. and the same renderer paints real data. Until then, refreshes only
  437. tween the seeded fixture so the live behaviors stay demo-able offline.</small>
  438. </div>
  439. </div>
  440. <!-- KPI -->
  441. <div class="kpis">
  442. <div class="kpi">
  443. <div class="label">Total tasks</div>
  444. <div class="value" id="kTotal">142</div>
  445. <div class="delta up"><span class="arr">↑</span> 6 vs last week</div>
  446. </div>
  447. <div class="kpi">
  448. <div class="label">Done this week</div>
  449. <div class="value" id="kDone">23</div>
  450. <div class="delta up"><span class="arr">↑</span> 4 vs last week</div>
  451. </div>
  452. <div class="kpi">
  453. <div class="label">Active members</div>
  454. <div class="value" id="kPeople">11<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / 14</span></div>
  455. <div class="delta">· Stable</div>
  456. </div>
  457. <div class="kpi">
  458. <div class="label">Docs awaiting review</div>
  459. <div class="value" id="kReview">7</div>
  460. <div class="delta down"><span class="arr">↓</span> 2 vs last week</div>
  461. </div>
  462. </div>
  463. <!-- Two col -->
  464. <div class="two-col">
  465. <div class="card">
  466. <div class="card-title">
  467. <strong>Tasks created · last 7 days</strong>
  468. <span id="sparkSum">98 total</span>
  469. </div>
  470. <svg class="spark" viewBox="0 0 600 140" preserveAspectRatio="none" id="sparkSvg">
  471. <!-- grid -->
  472. <g class="spark-grid">
  473. <line x1="0" y1="35" x2="600" y2="35"/>
  474. <line x1="0" y1="70" x2="600" y2="70"/>
  475. <line x1="0" y1="105" x2="600" y2="105"/>
  476. </g>
  477. <path class="spark-fill" id="sparkFill" d=""></path>
  478. <path class="spark-line" id="sparkLine" d=""></path>
  479. <g id="sparkDots"></g>
  480. <g id="sparkLabels" class="spark-axis"></g>
  481. </svg>
  482. </div>
  483. <div class="card">
  484. <div class="card-title">
  485. <strong>Recent activity</strong>
  486. <span>From <span style="color:var(--accent-ink)">Notion</span></span>
  487. </div>
  488. <div class="feed" id="feed"></div>
  489. </div>
  490. </div>
  491. <!-- Database -->
  492. <h2 class="h">📋 Tasks · Active sprint</h2>
  493. <div class="h-sub">Linked database · filtered by Status ≠ Done · sorted by Updated time</div>
  494. <div class="db" id="db">
  495. <div class="db-head">
  496. <div></div>
  497. <div>Name</div>
  498. <div>Status</div>
  499. <div>Assignee</div>
  500. <div class="db-cell due">Due</div>
  501. <div class="db-cell priority">Priority</div>
  502. </div>
  503. <!-- rows injected -->
  504. </div>
  505. <div class="footer">
  506. <span>Source: Notion API · workspace <strong>acme.so</strong></span>
  507. <span>·</span>
  508. <span>Connector <span class="key">composio.notion</span></span>
  509. <span>·</span>
  510. <span id="footerTime"></span>
  511. </div>
  512. </div>
  513. </main>
  514. </div>
  515. <div class="toast" id="toast">Synced — 3 changes from Notion</div>
  516. <script>
  517. (function(){
  518. // ---------- Fake data state ----------
  519. const PEOPLE = [
  520. { id: "SC", name: "Sarah Chen", color: "#f1c40f" },
  521. { id: "MK", name: "Mike Park", color: "#3498db" },
  522. { id: "LZ", name: "Lisa Zhao", color: "#e67e22" },
  523. { id: "DT", name: "Dave Torres", color: "#9b59b6" },
  524. { id: "AN", name: "Anna Nakamura",color: "#1abc9c" },
  525. { id: "RJ", name: "Raj Patel", color: "#e74c3c" }
  526. ];
  527. const ROW_POOL = [
  528. { icon: "🚀", title: "Q3 Roadmap planning", status: "progress", who: "SC", due: "May 12", prio: "High" },
  529. { icon: "📐", title: "Design tokens v2 spec", status: "review", who: "LZ", due: "May 14", prio: "Med" },
  530. { icon: "🐛", title: "Fix mobile nav overflow on iOS", status: "blocked", who: "MK", due: "May 09", prio: "High" },
  531. { icon: "📊", title: "Pricing experiment readout", status: "todo", who: "DT", due: "May 18", prio: "Low" },
  532. { icon: "✍️", title: "Launch blog draft · Live Artifacts", status: "progress", who: "AN", due: "May 11", prio: "High" },
  533. { icon: "🔐", title: "Rotate Notion integration token", status: "todo", who: "RJ", due: "May 20", prio: "Med" },
  534. { icon: "🧪", title: "QA onboarding flow regressions", status: "review", who: "MK", due: "May 16", prio: "Med" },
  535. { icon: "🎨", title: "Refresh marketing OG images", status: "progress", who: "LZ", due: "May 13", prio: "Low" }
  536. ];
  537. const ACTIVITY_TEMPLATES = [
  538. (p, t) => ({ who: p, action: "moved", target: t, suffix: "to Done", icon: "✅" }),
  539. (p, t) => ({ who: p, action: "created", target: t, suffix: "in Tasks", icon: "➕" }),
  540. (p, t) => ({ who: p, action: "commented on", target: t, suffix: "", icon: "💬" }),
  541. (p, t) => ({ who: p, action: "updated", target: t, suffix: "properties", icon: "✏️" }),
  542. (p, t) => ({ who: p, action: "shared", target: t, suffix: "with Marketing", icon: "🔗" }),
  543. (p, t) => ({ who: p, action: "added", target: t, suffix: "to sprint", icon: "📌" })
  544. ];
  545. const SEED_FEED = [
  546. { who: "Sarah Chen", action: "moved", target: "Q3 Roadmap planning", suffix: "to In progress", icon: "🚀", mins: 3 },
  547. { who: "Mike Park", action: "commented on", target: "Fix mobile nav overflow on iOS", suffix: "", icon: "💬", mins: 11 },
  548. { who: "Lisa Zhao", action: "created", target: "Design tokens v2 spec", suffix: "in Docs", icon: "📐", mins: 26 },
  549. { who: "Anna Nakamura",action: "shared", target: "Launch blog draft · Live Artifacts", suffix: "with Marketing", icon: "🔗", mins: 41 },
  550. { who: "Dave Torres", action: "updated", target: "Pricing experiment readout", suffix: "properties", icon: "✏️", mins: 58 }
  551. ];
  552. let kpi = { total: 142, done: 23, people: 11, peopleAll: 14, review: 7 };
  553. let series = [8, 12, 15, 9, 18, 22, 14];
  554. let dayLabels = ["Wed","Thu","Fri","Sat","Sun","Mon","Tue"];
  555. let lastRefresh = new Date();
  556. let autoOn = true;
  557. let autoTimer = null;
  558. // ---------- DOM refs ----------
  559. const $ = (id) => document.getElementById(id);
  560. const refreshBtn = $("refreshBtn");
  561. const refreshIco = $("refreshIco");
  562. const autoBtn = $("autoBtn");
  563. const autoLbl = $("autoLbl");
  564. const updatedAt = $("updatedAt");
  565. const liveText = $("liveText");
  566. const livePill = $("livePill");
  567. const toast = $("toast");
  568. const footerTime = $("footerTime");
  569. // ---------- Helpers ----------
  570. // Every dynamic value rendered into innerHTML below goes through e():
  571. // task titles / activity strings / person names can come from a
  572. // connector payload, and unescaped innerHTML is a working XSS sink.
  573. function e(v) {
  574. return String(v == null ? "" : v)
  575. .replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")
  576. .replaceAll('"', "&quot;").replaceAll("'", "&#39;");
  577. }
  578. function avatar(personId) {
  579. const p = PEOPLE.find(x => x.id === personId);
  580. if (!p) return "";
  581. return `<span class="av" style="background:${e(p.color)}">${e(p.id)}</span>`;
  582. }
  583. function personChip(personId) {
  584. const p = PEOPLE.find(x => x.id === personId);
  585. if (!p) return "";
  586. return `<span class="person">${avatar(personId)}<span>${e(p.name)}</span></span>`;
  587. }
  588. function timeAgo(date) {
  589. const s = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
  590. if (s < 5) return "just now";
  591. if (s < 60) return s + "s ago";
  592. const m = Math.floor(s / 60);
  593. if (m < 60) return m + " min ago";
  594. const h = Math.floor(m / 60);
  595. if (h < 24) return h + " h ago";
  596. return Math.floor(h/24) + " d ago";
  597. }
  598. function fmtDateTime(d) {
  599. return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) +
  600. " · " + d.toLocaleDateString([], { month: "short", day: "numeric" });
  601. }
  602. function rand(arr) { return arr[Math.floor(Math.random() * arr.length)]; }
  603. // Reduced-motion gate. The CSS @media block above already neutralizes
  604. // CSS animations/transitions, but tweenText() schedules JS rAF updates
  605. // and flash() toggles a transient highlight class — both keep moving
  606. // for opted-out users unless we short-circuit them here.
  607. function reduceMotion() {
  608. return typeof window !== "undefined"
  609. && typeof window.matchMedia === "function"
  610. && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  611. }
  612. function tween(el, from, to, ms = 600) {
  613. if (!el) return;
  614. if (from === to || reduceMotion()) {
  615. el.firstChild ? (el.childNodes[0].nodeValue = to) : (el.textContent = to);
  616. return;
  617. }
  618. const start = performance.now();
  619. function step(now) {
  620. const t = Math.min(1, (now - start) / ms);
  621. const eased = 1 - Math.pow(1 - t, 3);
  622. const v = Math.round(from + (to - from) * eased);
  623. el.firstChild ? (el.childNodes[0].nodeValue = v) : (el.textContent = v);
  624. if (t < 1) requestAnimationFrame(step);
  625. }
  626. requestAnimationFrame(step);
  627. }
  628. // ---------- Render: KPI ----------
  629. function renderKpi(prev) {
  630. const flash = (el) => {
  631. if (!el || reduceMotion()) return;
  632. el.classList.add("flash");
  633. setTimeout(() => el.classList.remove("flash"), 700);
  634. };
  635. if (prev) {
  636. tweenText($("kTotal"), prev.total, kpi.total); if (prev.total !== kpi.total) flash($("kTotal"));
  637. tweenText($("kDone"), prev.done, kpi.done); if (prev.done !== kpi.done) flash($("kDone"));
  638. tweenText($("kReview"), prev.review, kpi.review); if (prev.review !== kpi.review) flash($("kReview"));
  639. // people render keeps html — numeric values are safe but pass them
  640. // through e() anyway so connector-driven payloads can flow through
  641. // this same path without revisiting the markup.
  642. $("kPeople").innerHTML = e(kpi.people) + `<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / ${e(kpi.peopleAll)}</span>`;
  643. if (prev.people !== kpi.people) flash($("kPeople"));
  644. } else {
  645. $("kTotal").textContent = kpi.total;
  646. $("kDone").textContent = kpi.done;
  647. $("kReview").textContent = kpi.review;
  648. $("kPeople").innerHTML = e(kpi.people) + `<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / ${e(kpi.peopleAll)}</span>`;
  649. }
  650. }
  651. function tweenText(el, from, to, ms = 600) {
  652. if (!el) return;
  653. if (from === to || reduceMotion()) { el.textContent = String(to); return; }
  654. const start = performance.now();
  655. function step(now) {
  656. const t = Math.min(1, (now - start) / ms);
  657. const eased = 1 - Math.pow(1 - t, 3);
  658. const v = Math.round(from + (to - from) * eased);
  659. el.textContent = v;
  660. if (t < 1) requestAnimationFrame(step);
  661. }
  662. requestAnimationFrame(step);
  663. }
  664. // ---------- Render: sparkline ----------
  665. function renderSpark() {
  666. const W = 600, H = 140, padL = 24, padR = 16, padT = 10, padB = 24;
  667. const max = Math.max(...series, 1);
  668. const stepX = (W - padL - padR) / (series.length - 1);
  669. const pts = series.map((v, i) => {
  670. const x = padL + i * stepX;
  671. const y = padT + (1 - v / (max * 1.15)) * (H - padT - padB);
  672. return [x, y];
  673. });
  674. const linePath = "M " + pts.map(p => p.join(" ")).join(" L ");
  675. const fillPath = linePath + ` L ${pts[pts.length-1][0]} ${H - padB} L ${pts[0][0]} ${H - padB} Z`;
  676. $("sparkLine").setAttribute("d", linePath);
  677. $("sparkFill").setAttribute("d", fillPath);
  678. const dots = pts.map(([x,y]) => `<circle class="spark-dot" cx="${x}" cy="${y}" r="3"/>`).join("");
  679. $("sparkDots").innerHTML = dots;
  680. const labels = dayLabels.map((d, i) => {
  681. const x = padL + i * stepX;
  682. return `<text x="${x}" y="${H - 6}" text-anchor="middle">${d}</text>`;
  683. }).join("");
  684. $("sparkLabels").innerHTML = labels;
  685. $("sparkSum").textContent = series.reduce((a,b)=>a+b,0) + " total";
  686. }
  687. // ---------- Render: feed ----------
  688. let feed = SEED_FEED.map(x => ({...x, when: new Date(Date.now() - x.mins * 60 * 1000), id: cryptoRandomId() }));
  689. function cryptoRandomId() { return "f" + Math.random().toString(36).slice(2, 9); }
  690. function renderFeed(highlightId) {
  691. const el = $("feed");
  692. // Drop the transient .new highlight under reduced-motion so the row
  693. // doesn't get a coloured background pulse for users who opted out.
  694. const effectiveHighlight = reduceMotion() ? null : highlightId;
  695. el.innerHTML = feed.slice(0, 6).map(item => {
  696. const initials = String(item.who||"").split(" ").map(s => s[0]).join("").slice(0,2).toUpperCase();
  697. const color = personColor(item.who);
  698. const cls = item.id === effectiveHighlight ? "feed-row new" : "feed-row";
  699. const suffixHtml = item.suffix ? `<span class="what"> ${e(item.suffix)}</span>` : "";
  700. return `
  701. <div class="${cls}" data-id="${e(item.id)}">
  702. <span class="av" style="background:${e(color)}">${e(initials)}</span>
  703. <div class="body">
  704. <span class="who">${e(item.who)}</span>
  705. <span class="what"> ${e(item.action)}</span>
  706. <span class="target"> ${e(item.icon || "")} ${e(item.target)}</span>
  707. ${suffixHtml}
  708. </div>
  709. <div class="time" title="${e(item.when.toLocaleString())}">${e(timeAgo(item.when))}</div>
  710. </div>`;
  711. }).join("");
  712. }
  713. function personColor(name) {
  714. const p = PEOPLE.find(x => x.name === name);
  715. return p ? p.color : "#7f8c8d";
  716. }
  717. // ---------- Render: db rows ----------
  718. let rows = ROW_POOL.slice(0, 6).map((r, i) => ({...r, id: "r"+i, updated: Date.now() - (i+1)*1800000 }));
  719. function renderRows(changedId) {
  720. const head = document.querySelector(".db-head");
  721. const db = $("db");
  722. [...db.querySelectorAll(".db-row")].forEach(n => n.remove());
  723. const sorted = [...rows].sort((a,b) => b.updated - a.updated);
  724. const STATUS_LABEL = { done: "Done", progress: "In progress", blocked: "Blocked", todo: "To do", review: "In review" };
  725. // Same reduced-motion gate as renderFeed: skip the .changed
  726. // row-flash class so we don't paint a transient highlight for
  727. // opted-out users (the rowflash CSS animation is already neutralized
  728. // by the prefers-reduced-motion @media block above, but the class
  729. // would still imply intent).
  730. const effectiveChanged = reduceMotion() ? null : changedId;
  731. sorted.forEach(r => {
  732. const div = document.createElement("div");
  733. div.className = "db-row" + (r.id === effectiveChanged ? " changed" : "");
  734. div.dataset.id = r.id;
  735. const statusKey = STATUS_LABEL[r.status] ? r.status : "todo";
  736. const statusLabel = STATUS_LABEL[statusKey];
  737. div.innerHTML = `
  738. <div class="db-cell">${e(r.icon)}</div>
  739. <div class="db-cell title"><span class="t">${e(r.title)}</span></div>
  740. <div class="db-cell"><span class="pill ${statusKey}">${e(statusLabel)}</span></div>
  741. <div class="db-cell">${personChip(r.who)}</div>
  742. <div class="db-cell due">${e(r.due)}</div>
  743. <div class="db-cell priority">${e(r.prio)}</div>
  744. `;
  745. db.appendChild(div);
  746. });
  747. }
  748. // ---------- Refresh logic (the live bit) ----------
  749. let busy = false;
  750. async function refresh({silent = false} = {}) {
  751. if (busy) return;
  752. busy = true;
  753. refreshIco.classList.add("spin");
  754. livePill.classList.remove("stale");
  755. liveText.textContent = "Syncing…";
  756. // Simulate latency to a Notion API call.
  757. await new Promise(r => setTimeout(r, 700 + Math.random() * 600));
  758. const prev = {...kpi};
  759. const changes = [];
  760. // Mutate state in plausible directions.
  761. const newDone = Math.random() < 0.7 ? 1 : 0;
  762. if (newDone) {
  763. kpi.done += 1;
  764. kpi.total += Math.random() < 0.5 ? 1 : 0;
  765. // flip a row to done
  766. const candidates = rows.filter(r => r.status !== "done");
  767. if (candidates.length) {
  768. const r = rand(candidates);
  769. r.status = "done";
  770. r.updated = Date.now();
  771. changes.push({ kind: "row", id: r.id, row: r });
  772. }
  773. } else {
  774. // a brand new task created
  775. const rest = ROW_POOL.filter(p => !rows.some(r => r.title === p.title));
  776. const tmpl = rest.length ? rand(rest) : rand(ROW_POOL);
  777. const r = { ...tmpl, id: "r" + Date.now(), status: "todo", updated: Date.now() };
  778. rows = [r, ...rows].slice(0, 8);
  779. kpi.total += 1;
  780. changes.push({ kind: "row", id: r.id, row: r });
  781. }
  782. if (Math.random() < 0.4) {
  783. kpi.review = Math.max(0, kpi.review + (Math.random() < 0.5 ? -1 : 1));
  784. }
  785. if (Math.random() < 0.25) {
  786. kpi.people = Math.min(kpi.peopleAll, Math.max(6, kpi.people + (Math.random() < 0.5 ? -1 : 1)));
  787. }
  788. // Series shift: today's bucket gains 1-3
  789. series = series.slice();
  790. series[series.length - 1] = series[series.length - 1] + 1 + Math.floor(Math.random()*2);
  791. // Add a new feed item
  792. const lastChange = changes[changes.length - 1];
  793. const person = rand(PEOPLE);
  794. const tmpl = rand(ACTIVITY_TEMPLATES);
  795. const targetTitle = lastChange ? lastChange.row.title : rand(ROW_POOL).title;
  796. const evt = tmpl(person.name, targetTitle);
  797. evt.when = new Date();
  798. evt.id = cryptoRandomId();
  799. feed = [evt, ...feed].slice(0, 8);
  800. lastRefresh = new Date();
  801. busy = false;
  802. refreshIco.classList.remove("spin");
  803. // Only mock-mode here — keep the "Sample data" badge so the artifact
  804. // never falsely claims a real connector is bound.
  805. liveText.textContent = "Sample data";
  806. livePill.classList.remove("stale");
  807. livePill.classList.add("sample");
  808. renderKpi(prev);
  809. renderSpark();
  810. renderFeed(evt.id);
  811. renderRows(lastChange ? lastChange.id : null);
  812. updateTimes();
  813. if (!silent) showToast("Refreshed sample data · 1 task moved, 1 activity added");
  814. }
  815. function showToast(msg) {
  816. toast.textContent = msg;
  817. toast.classList.add("show");
  818. clearTimeout(showToast._t);
  819. showToast._t = setTimeout(() => toast.classList.remove("show"), 1800);
  820. }
  821. function updateTimes() {
  822. updatedAt.textContent = "Last refreshed " + timeAgo(lastRefresh);
  823. footerTime.textContent = "Last sync · " + fmtDateTime(lastRefresh);
  824. // Sample mode (no connector bound) is sticky — the artifact never
  825. // claims "Live · synced" against fixture data. The pill only escalates
  826. // to "Stale · …" if even the sample-refresh loop has not run for a
  827. // while (e.g. the auto-refresh was paused).
  828. if ((Date.now() - lastRefresh.getTime()) > 90 * 1000) {
  829. livePill.classList.add("stale");
  830. livePill.classList.remove("sample");
  831. liveText.textContent = "Stale · " + timeAgo(lastRefresh);
  832. } else {
  833. livePill.classList.remove("stale");
  834. livePill.classList.add("sample");
  835. liveText.textContent = "Sample data";
  836. }
  837. }
  838. // ---------- Keyboard activation for role=button divs ----------
  839. // .ws / .side-search / .nav-item are styled as clickable rows but they
  840. // are <div>, so keyboard users get nothing for free. Map Enter/Space
  841. // onto a synthetic click and prevent the default Space scroll.
  842. document.addEventListener("keydown", (ev) => {
  843. if (ev.key !== "Enter" && ev.key !== " ") return;
  844. const t = ev.target;
  845. if (!(t instanceof HTMLElement)) return;
  846. if (t.getAttribute("role") !== "button") return;
  847. if (t.matches("button, a, input, select, textarea")) return;
  848. ev.preventDefault();
  849. t.click();
  850. });
  851. // ---------- Init ----------
  852. function init() {
  853. renderKpi();
  854. renderSpark();
  855. renderFeed();
  856. renderRows();
  857. updateTimes();
  858. // "Refresh on open" — the moment the artifact mounts.
  859. setTimeout(() => refresh({silent: true}), 600);
  860. }
  861. // ---------- Wire events ----------
  862. refreshBtn.addEventListener("click", () => refresh());
  863. autoBtn.addEventListener("click", () => {
  864. autoOn = !autoOn;
  865. autoLbl.textContent = "Auto · " + (autoOn ? "on" : "off");
  866. if (autoOn) startAuto(); else stopAuto();
  867. });
  868. function startAuto() { stopAuto(); autoTimer = setInterval(() => refresh({silent: true}), 30 * 1000); }
  869. function stopAuto() { if (autoTimer) clearInterval(autoTimer); autoTimer = null; }
  870. setInterval(updateTimes, 5 * 1000);
  871. // Tick relative timestamps in feed every 15s
  872. setInterval(() => renderFeed(), 15 * 1000);
  873. startAuto();
  874. init();
  875. })();
  876. </script>
  877. </body>
  878. </html>