[{"data":1,"prerenderedAt":1385},["ShallowReactive",2],{"profile":3,"projects:page:\u002Fprojects\u002Fhighreel\u002Fscenes":22,"projects:docs:\u002Fprojects\u002Fhighreel":1345,"structured-data:current-stack":1371},{"id":4,"alias":5,"current":6,"email":10,"extension":11,"headline":12,"links":13,"location":17,"meta":18,"name":19,"stem":20,"__hash__":21},"profile\u002Fprofile.yml","readonly",{"role":7,"company":8,"companyUrl":9},"Fullstack Engineer — Tech Lead","DataCose","https:\u002F\u002Fdatacose.com","redonemini18@gmail.com","yml","Fullstack Engineer",{"github":14,"linkedin":15,"twitch":16},"https:\u002F\u002Fgithub.com\u002FRedoni18","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fredon-emini\u002F","https:\u002F\u002Fwww.twitch.tv\u002Fr3adonly","Pristina, Kosovo",{},"Redon Emini","profile","Fbb1IAp4nuUOOtgXdwpzcqSmG0CUKtZ4D0ifPqdK5QU",{"id":23,"title":24,"body":25,"description":1330,"extension":1331,"featured":1332,"kind":1333,"links":1334,"meta":1335,"navigation":1336,"order":1338,"path":1339,"period":1340,"preview":1340,"seo":1341,"stack":1342,"stem":1343,"year":1340,"__hash__":1344},"projects\u002Fprojects\u002Fhighreel\u002F3.scenes.md","Animations that are also images",{"type":26,"value":27,"toc":1320},"minimark",[28,37,40,45,56,87,204,211,218,414,421,425,431,440,588,595,598,721,724,729,732,831,835,842,853,1065,1068,1072,1085,1147,1153,1157,1160,1163,1166,1170,1179,1182,1294,1301,1308,1316],[29,30,31,32,36],"p",{},"The page a customer opens is the product. It's a set of story slides that work the way Instagram stories do: a progress bar along the top, tap the right side for the next slide and the left side to go back, press and hold to pause. Each kind of number gets its own ",[33,34,35],"strong",{},"scene",". A count of active days fills in a year of tiny calendar squares. A streak lights up a chain, link by link. A rank shows a hundred dots, lights up the top few, and marks one of them \"You're here\". There are more than twenty scenes, and a business can pick which one each slide uses.",[29,38,39],{},"These pages have a tough audience. They're opened from a chat message, on a phone, often on mobile data, by someone who wasn't expecting them. So they have budgets, checked on a production build: at most 150 KB of gzipped JavaScript, the first slide on screen within 1.5 seconds on 4G, and 60 frames per second on a mid-range Android phone (simulated with a 4× CPU slowdown).",[41,42,44],"h2",{"id":43},"no-animation-library","No animation library",[29,46,47,48,55],{},"The plan was to use ",[49,50,54],"a",{"href":51,"rel":52},"https:\u002F\u002Fmotion.dev",[53],"nofollow","Motion",". While building the first scenes, I switched to plain CSS keyframes, and every scene since has followed the same constraints:",[57,58,59,75,81],"ul",{},[60,61,62,74],"li",{},[33,63,64,65,69,70,73],{},"Only ",[66,67,68],"code",{},"transform"," and ",[66,71,72],{},"opacity"," animate."," Browsers can run those two on the compositor, a separate thread from your JavaScript, so the motion stays smooth even while the main thread is busy, for example while Vue hydrates the page.",[60,76,77,80],{},[33,78,79],{},"The first slide plays from the server-rendered HTML."," CSS animations start as soon as the HTML and CSS arrive. On a slow connection, the cover is already moving while the JavaScript is still downloading.",[60,82,83,86],{},[33,84,85],{},"Pausing is one rule."," Holding a finger on the story freezes every animation in the slide:",[88,89,95],"pre",{"className":90,"code":91,"filename":92,"language":93,"meta":94,"style":94},"language-css shiki shiki-themes vitesse-light vitesse-dark",".recap.is-held .slide *,\n.recap.is-held .slide *::before,\n.recap.is-held .slide *::after {\n  animation-play-state: paused !important;\n}\n","app\u002Fcomponents\u002Frecap\u002Frecap.css","css","",[66,96,97,128,153,178,198],{"__ignoreMap":94},[98,99,102,106,110,112,115,118,121,125],"span",{"class":100,"line":101},"line",1,[98,103,105],{"class":104},"si6no",".",[98,107,109],{"class":108},"s9nN2","recap",[98,111,105],{"class":104},[98,113,114],{"class":108},"is-held",[98,116,117],{"class":104}," .",[98,119,120],{"class":108},"slide",[98,122,124],{"class":123},"sTPum"," *",[98,126,127],{"class":104},",\n",[98,129,131,133,135,137,139,141,143,145,148,151],{"class":100,"line":130},2,[98,132,105],{"class":104},[98,134,109],{"class":108},[98,136,105],{"class":104},[98,138,114],{"class":108},[98,140,117],{"class":104},[98,142,120],{"class":108},[98,144,124],{"class":123},[98,146,147],{"class":104},"::",[98,149,150],{"class":108},"before",[98,152,127],{"class":104},[98,154,156,158,160,162,164,166,168,170,172,175],{"class":100,"line":155},3,[98,157,105],{"class":104},[98,159,109],{"class":108},[98,161,105],{"class":104},[98,163,114],{"class":108},[98,165,117],{"class":104},[98,167,120],{"class":108},[98,169,124],{"class":123},[98,171,147],{"class":104},[98,173,174],{"class":108},"after",[98,176,177],{"class":104}," {\n",[98,179,181,185,188,192,195],{"class":100,"line":180},4,[98,182,184],{"class":183},"sHLBJ","  animation-play-state",[98,186,187],{"class":104},":",[98,189,191],{"class":190},"sfsYZ"," paused",[98,193,194],{"class":123}," !important",[98,196,197],{"class":104},";\n",[98,199,201],{"class":100,"line":200},5,[98,202,203],{"class":104},"}\n",[57,205,206],{},[60,207,208],{},[33,209,210],{},"It costs 0 KB of JavaScript.",[29,212,213,214,217],{},"The one thing CSS used to be bad at is springy motion, and the ",[66,215,216],{},"linear()"," easing function fixes that. Despite the name, it takes a list of points and draws a curve through them, so any easing you can write as a function can become CSS. A small helper samples a JavaScript function into one:",[88,219,224],{"className":220,"code":221,"filename":222,"language":223,"meta":94,"style":94},"language-ts shiki shiki-themes vitesse-light vitesse-dark","export function cssEasing(f: (t: number) => number, points = 24): string {\n  const values = Array.from({ length: points + 1 }, (_, i) => +f(i \u002F points).toFixed(4))\n  return `linear(${values.join(', ')})`\n}\n","shared\u002Futils\u002Fscenes.ts","ts",[66,225,226,284,367,410],{"__ignoreMap":94},[98,227,228,231,235,239,242,245,248,251,254,258,261,263,266,269,272,276,279,282],{"class":100,"line":101},[98,229,230],{"class":123},"export",[98,232,234],{"class":233},"s5TCs"," function",[98,236,238],{"class":237},"s_xSY"," cssEasing",[98,240,241],{"class":104},"(",[98,243,244],{"class":237},"f",[98,246,247],{"class":104},": (",[98,249,250],{"class":108},"t",[98,252,253],{"class":104},": ",[98,255,257],{"class":256},"s_NWU","number",[98,259,260],{"class":104},") => ",[98,262,257],{"class":256},[98,264,265],{"class":104},",",[98,267,268],{"class":108}," points",[98,270,271],{"class":104}," =",[98,273,275],{"class":274},"sqbOQ"," 24",[98,277,278],{"class":104},"):",[98,280,281],{"class":256}," string",[98,283,177],{"class":104},[98,285,286,289,292,294,297,299,302,305,308,310,313,316,319,322,325,328,330,333,336,339,341,343,345,348,351,353,356,359,361,364],{"class":100,"line":130},[98,287,288],{"class":233},"  const ",[98,290,291],{"class":108},"values",[98,293,271],{"class":104},[98,295,296],{"class":108}," Array",[98,298,105],{"class":104},[98,300,301],{"class":237},"from",[98,303,304],{"class":104},"({ ",[98,306,307],{"class":183},"length",[98,309,253],{"class":104},[98,311,312],{"class":108},"points",[98,314,315],{"class":233}," +",[98,317,318],{"class":274}," 1",[98,320,321],{"class":104}," },",[98,323,324],{"class":104}," (",[98,326,327],{"class":108},"_",[98,329,265],{"class":104},[98,331,332],{"class":108}," i",[98,334,335],{"class":104},")",[98,337,338],{"class":104}," =>",[98,340,315],{"class":233},[98,342,244],{"class":237},[98,344,241],{"class":104},[98,346,347],{"class":108},"i",[98,349,350],{"class":233}," \u002F ",[98,352,312],{"class":108},[98,354,355],{"class":104},").",[98,357,358],{"class":237},"toFixed",[98,360,241],{"class":104},[98,362,363],{"class":274},"4",[98,365,366],{"class":104},"))\n",[98,368,369,372,376,380,383,385,387,390,392,395,398,400,402,405,407],{"class":100,"line":155},[98,370,371],{"class":123},"  return",[98,373,375],{"class":374},"scnC2"," `",[98,377,379],{"class":378},"spP0B","linear(",[98,381,382],{"class":123},"${",[98,384,291],{"class":378},[98,386,105],{"class":104},[98,388,389],{"class":237},"join",[98,391,241],{"class":104},[98,393,394],{"class":374},"'",[98,396,397],{"class":378},", ",[98,399,394],{"class":374},[98,401,335],{"class":104},[98,403,404],{"class":123},"}",[98,406,335],{"class":378},[98,408,409],{"class":374},"`\n",[98,411,412],{"class":100,"line":180},[98,413,203],{"class":104},[29,415,416,417,420],{},"The springs in the recap's stylesheet are lists like this, worked out from a stiffness and a damping value, with plain ",[66,418,419],{},"cubic-bezier"," curves as a fallback for older Safari.",[41,422,424],{"id":423},"the-rule-rest-at-the-end","The rule: rest at the end",[29,426,427,428],{},"This is the decision the rest of the post depends on: ",[33,429,430],{},"an element's own style is its final state, and keyframes only describe how it gets there.",[29,432,433,434,437,438,187],{},"Most entrance animations are written the other way around. The element starts hidden (",[66,435,436],{},"opacity: 0",") and an animation brings it into view. Here, an element's CSS describes where it ends up, and its keyframes only have a ",[66,439,301],{},[88,441,443],{"className":90,"code":442,"filename":92,"language":93,"meta":94,"style":94},".recap .rise {\n  animation: rcp-rise 700ms var(--ease-out) both;\n  animation-delay: var(--d, 0ms);\n}\n@keyframes rcp-rise {\n  from { opacity: 0; transform: translateY(calc(5 * var(--u))); }\n}\n",[66,444,445,458,490,514,518,531,583],{"__ignoreMap":94},[98,446,447,449,451,453,456],{"class":100,"line":101},[98,448,105],{"class":104},[98,450,109],{"class":108},[98,452,117],{"class":104},[98,454,455],{"class":108},"rise",[98,457,177],{"class":104},[98,459,460,463,465,469,472,475,478,480,483,485,488],{"class":100,"line":130},[98,461,462],{"class":183},"  animation",[98,464,187],{"class":104},[98,466,468],{"class":467},"s8w-G"," rcp-rise ",[98,470,471],{"class":274},"700",[98,473,474],{"class":233},"ms",[98,476,477],{"class":183}," var",[98,479,241],{"class":104},[98,481,482],{"class":108},"--ease-out",[98,484,335],{"class":104},[98,486,487],{"class":190}," both",[98,489,197],{"class":104},[98,491,492,495,497,499,501,504,506,509,511],{"class":100,"line":155},[98,493,494],{"class":183},"  animation-delay",[98,496,187],{"class":104},[98,498,477],{"class":183},[98,500,241],{"class":104},[98,502,503],{"class":108},"--d",[98,505,265],{"class":104},[98,507,508],{"class":274}," 0",[98,510,474],{"class":233},[98,512,513],{"class":104},");\n",[98,515,516],{"class":100,"line":180},[98,517,203],{"class":104},[98,519,520,523,526,529],{"class":100,"line":200},[98,521,522],{"class":104},"@",[98,524,525],{"class":123},"keyframes",[98,527,528],{"class":108}," rcp-rise",[98,530,177],{"class":104},[98,532,534,537,540,543,545,547,550,553,555,558,560,563,565,568,570,572,574,577,580],{"class":100,"line":533},6,[98,535,536],{"class":237},"  from",[98,538,539],{"class":104}," {",[98,541,542],{"class":183}," opacity",[98,544,187],{"class":104},[98,546,508],{"class":274},[98,548,549],{"class":104},";",[98,551,552],{"class":183}," transform",[98,554,187],{"class":104},[98,556,557],{"class":183}," translateY",[98,559,241],{"class":104},[98,561,562],{"class":183},"calc",[98,564,241],{"class":104},[98,566,567],{"class":274},"5",[98,569,124],{"class":233},[98,571,477],{"class":183},[98,573,241],{"class":104},[98,575,576],{"class":108},"--u",[98,578,579],{"class":104},")));",[98,581,582],{"class":104}," }\n",[98,584,586],{"class":100,"line":585},7,[98,587,203],{"class":104},[29,589,590,591,594],{},"There's no ",[66,592,593],{},"to",". When a keyframe block leaves out the end, the browser animates toward the element's own style. So if you take the animation away, what's left is the finished slide, not an empty one.",[29,596,597],{},"The bigger scenes are built the same way. When a streak is too long to fit, the chain pans so the newest link stays in view. Its resting position is the end of the pan:",[88,599,602],{"className":90,"code":600,"filename":601,"language":93,"meta":94,"style":94},".chain.pans {\n  transform: translateX(var(--pan-end));   \u002F* where it ends up *\u002F\n  animation: pan var(--pan-dur) var(--pan-ease) var(--pan-start) both;\n}\n@keyframes pan {\n  from { transform: none; }\n}\n","app\u002Fcomponents\u002Frecap\u002Fscenes\u002FSceneStreak.vue",[66,603,604,618,645,685,689,700,717],{"__ignoreMap":94},[98,605,606,608,611,613,616],{"class":100,"line":101},[98,607,105],{"class":104},[98,609,610],{"class":108},"chain",[98,612,105],{"class":104},[98,614,615],{"class":108},"pans",[98,617,177],{"class":104},[98,619,620,623,625,628,630,633,635,638,641],{"class":100,"line":130},[98,621,622],{"class":183},"  transform",[98,624,187],{"class":104},[98,626,627],{"class":183}," translateX",[98,629,241],{"class":104},[98,631,632],{"class":183},"var",[98,634,241],{"class":104},[98,636,637],{"class":108},"--pan-end",[98,639,640],{"class":104},"));",[98,642,644],{"class":643},"snYqZ","   \u002F* where it ends up *\u002F\n",[98,646,647,649,651,654,656,658,661,663,665,667,670,672,674,676,679,681,683],{"class":100,"line":155},[98,648,462],{"class":183},[98,650,187],{"class":104},[98,652,653],{"class":467}," pan ",[98,655,632],{"class":183},[98,657,241],{"class":104},[98,659,660],{"class":108},"--pan-dur",[98,662,335],{"class":104},[98,664,477],{"class":183},[98,666,241],{"class":104},[98,668,669],{"class":108},"--pan-ease",[98,671,335],{"class":104},[98,673,477],{"class":183},[98,675,241],{"class":104},[98,677,678],{"class":108},"--pan-start",[98,680,335],{"class":104},[98,682,487],{"class":190},[98,684,197],{"class":104},[98,686,687],{"class":100,"line":180},[98,688,203],{"class":104},[98,690,691,693,695,698],{"class":100,"line":200},[98,692,522],{"class":104},[98,694,525],{"class":123},[98,696,697],{"class":108}," pan",[98,699,177],{"class":104},[98,701,702,704,706,708,710,713,715],{"class":100,"line":533},[98,703,536],{"class":237},[98,705,539],{"class":104},[98,707,552],{"class":183},[98,709,187],{"class":104},[98,711,712],{"class":190}," none",[98,714,549],{"class":104},[98,716,582],{"class":104},[98,718,719],{"class":100,"line":585},[98,720,203],{"class":104},[29,722,723],{},"That one rule pays for itself three times.",[725,726,728],"h3",{"id":727},"_1-reduced-motion-is-one-rule","1. Reduced motion is one rule",[29,730,731],{},"People who turn on \"reduce motion\" in their system settings get each finished scene immediately. Every animation in the slide is switched off, and since every element already rests at its end state, nothing is left invisible or half drawn. No scene needs a second, static version of itself.",[88,733,735],{"className":90,"code":734,"filename":92,"language":93,"meta":94,"style":94},"@media (prefers-reduced-motion: reduce) {\n  .recap .slide *,\n  .recap .slide *::before,\n  .recap .slide *::after {\n    animation: none !important;\n  }\n}\n",[66,736,737,758,773,791,809,822,827],{"__ignoreMap":94},[98,738,739,741,744,746,749,751,754,756],{"class":100,"line":101},[98,740,522],{"class":104},[98,742,743],{"class":123},"media",[98,745,324],{"class":104},[98,747,748],{"class":467},"prefers-reduced-motion",[98,750,187],{"class":104},[98,752,753],{"class":467}," reduce",[98,755,335],{"class":104},[98,757,177],{"class":104},[98,759,760,763,765,767,769,771],{"class":100,"line":130},[98,761,762],{"class":104},"  .",[98,764,109],{"class":108},[98,766,117],{"class":104},[98,768,120],{"class":108},[98,770,124],{"class":123},[98,772,127],{"class":104},[98,774,775,777,779,781,783,785,787,789],{"class":100,"line":155},[98,776,762],{"class":104},[98,778,109],{"class":108},[98,780,117],{"class":104},[98,782,120],{"class":108},[98,784,124],{"class":123},[98,786,147],{"class":104},[98,788,150],{"class":108},[98,790,127],{"class":104},[98,792,793,795,797,799,801,803,805,807],{"class":100,"line":180},[98,794,762],{"class":104},[98,796,109],{"class":108},[98,798,117],{"class":104},[98,800,120],{"class":108},[98,802,124],{"class":123},[98,804,147],{"class":104},[98,806,174],{"class":108},[98,808,177],{"class":104},[98,810,811,814,816,818,820],{"class":100,"line":200},[98,812,813],{"class":183},"    animation",[98,815,187],{"class":104},[98,817,712],{"class":190},[98,819,194],{"class":123},[98,821,197],{"class":104},[98,823,824],{"class":100,"line":533},[98,825,826],{"class":104},"  }\n",[98,828,829],{"class":100,"line":585},[98,830,203],{"class":104},[725,832,834],{"id":833},"_2-saved-images-use-the-same-components","2. Saved images use the same components",[29,836,837,838,841],{},"Customers can save any slide as a 1080×1920 image to post in their own stories. There's no second renderer for that. The save picker renders the slide in its reduced-motion state, so it's already finished, and captures that piece of the page as a PNG with ",[66,839,840],{},"modern-screenshot",", a small library that only loads when the picker opens.",[29,843,844,845,848,849,852],{},"Numbers that count up are the one part driven by JavaScript, so they need to know they're in a still. They read a shared clock through Vue's ",[66,846,847],{},"provide","\u002F",[66,850,851],{},"inject",", and the still provides one that says \"reduced\", which makes them show their final value straight away:",[88,854,859],{"className":855,"code":856,"filename":857,"language":858,"meta":94,"style":94},"language-vue shiki shiki-themes vitesse-light vitesse-dark","\u003Cscript setup lang=\"ts\">\n\u002F\u002F Count-ups and other clocked bits show their final value.\nprovide(RECAP_CLOCK, { held: ref(true), reduced: ref(true) })\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Cdiv class=\"recap still is-reduced\">\n    \u003CRecapSlide :slide=\"slide\" :payload=\"payload\" :tone=\"tone\" :reduced=\"true\" \u002F>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n","app\u002Fcomponents\u002Frecap\u002FRecapStill.vue","vue",[66,860,861,888,893,937,946,952,961,983,1046,1056],{"__ignoreMap":94},[98,862,863,866,869,872,875,878,881,883,885],{"class":100,"line":101},[98,864,865],{"class":104},"\u003C",[98,867,868],{"class":123},"script",[98,870,871],{"class":108}," setup",[98,873,874],{"class":108}," lang",[98,876,877],{"class":104},"=",[98,879,880],{"class":374},"\"",[98,882,223],{"class":378},[98,884,880],{"class":374},[98,886,887],{"class":104},">\n",[98,889,890],{"class":100,"line":130},[98,891,892],{"class":643},"\u002F\u002F Count-ups and other clocked bits show their final value.\n",[98,894,895,897,899,902,904,907,910,912,915,917,920,923,926,928,930,932,934],{"class":100,"line":155},[98,896,847],{"class":237},[98,898,241],{"class":104},[98,900,901],{"class":108},"RECAP_CLOCK",[98,903,265],{"class":104},[98,905,906],{"class":104}," { ",[98,908,909],{"class":183},"held",[98,911,253],{"class":104},[98,913,914],{"class":237},"ref",[98,916,241],{"class":104},[98,918,919],{"class":123},"true",[98,921,922],{"class":104},"), ",[98,924,925],{"class":183},"reduced",[98,927,253],{"class":104},[98,929,914],{"class":237},[98,931,241],{"class":104},[98,933,919],{"class":123},[98,935,936],{"class":104},") })\n",[98,938,939,942,944],{"class":100,"line":180},[98,940,941],{"class":104},"\u003C\u002F",[98,943,868],{"class":123},[98,945,887],{"class":104},[98,947,948],{"class":100,"line":200},[98,949,951],{"emptyLinePlaceholder":950},true,"\n",[98,953,954,956,959],{"class":100,"line":533},[98,955,865],{"class":104},[98,957,958],{"class":123},"template",[98,960,887],{"class":104},[98,962,963,966,969,972,974,976,979,981],{"class":100,"line":585},[98,964,965],{"class":104},"  \u003C",[98,967,968],{"class":123},"div",[98,970,971],{"class":108}," class",[98,973,877],{"class":104},[98,975,880],{"class":374},[98,977,978],{"class":378},"recap still is-reduced",[98,980,880],{"class":374},[98,982,887],{"class":104},[98,984,986,989,992,995,997,999,1001,1003,1005,1007,1010,1012,1014,1016,1018,1020,1023,1025,1027,1029,1031,1033,1035,1037,1039,1041,1043],{"class":100,"line":985},8,[98,987,988],{"class":104},"    \u003C",[98,990,991],{"class":123},"RecapSlide",[98,993,994],{"class":104}," :",[98,996,120],{"class":237},[98,998,877],{"class":104},[98,1000,880],{"class":104},[98,1002,120],{"class":108},[98,1004,880],{"class":104},[98,1006,994],{"class":104},[98,1008,1009],{"class":237},"payload",[98,1011,877],{"class":104},[98,1013,880],{"class":104},[98,1015,1009],{"class":108},[98,1017,880],{"class":104},[98,1019,994],{"class":104},[98,1021,1022],{"class":237},"tone",[98,1024,877],{"class":104},[98,1026,880],{"class":104},[98,1028,1022],{"class":108},[98,1030,880],{"class":104},[98,1032,994],{"class":104},[98,1034,925],{"class":237},[98,1036,877],{"class":104},[98,1038,880],{"class":104},[98,1040,919],{"class":123},[98,1042,880],{"class":104},[98,1044,1045],{"class":104}," \u002F>\n",[98,1047,1049,1052,1054],{"class":100,"line":1048},9,[98,1050,1051],{"class":104},"  \u003C\u002F",[98,1053,968],{"class":123},[98,1055,887],{"class":104},[98,1057,1059,1061,1063],{"class":100,"line":1058},10,[98,1060,941],{"class":104},[98,1062,958],{"class":123},[98,1064,887],{"class":104},[29,1066,1067],{},"Every scene added later works as an image without anyone thinking about it, because following the rule is what makes it work.",[725,1069,1071],{"id":1070},"_3-the-same-highreel-plays-the-same-way-every-time","3. The same Highreel plays the same way every time",[29,1073,1074,1075,1078,1079,397,1082,1084],{},"Scenes also don't use clocks or ",[66,1076,1077],{},"Math.random()",". Their timing comes from the data through CSS variables (",[66,1080,1081],{},"--t",[66,1083,503],{},"), and anything that looks random, like the slight jitter in a pile of tokens or the wrong answers in the optional \"guess first\" quiz, comes from a seeded generator keyed by the slide and its value:",[88,1086,1089],{"className":220,"code":1087,"filename":1088,"language":223,"meta":94,"style":94},"const rand = seeded(`count|${props.slide.key}|${value.value}`)\n","app\u002Fcomponents\u002Frecap\u002Fscenes\u002FSceneCount.vue",[66,1090,1091],{"__ignoreMap":94},[98,1092,1093,1096,1099,1101,1104,1106,1109,1112,1114,1117,1119,1121,1123,1126,1128,1131,1133,1136,1138,1140,1142,1144],{"class":100,"line":101},[98,1094,1095],{"class":233},"const ",[98,1097,1098],{"class":108},"rand",[98,1100,271],{"class":104},[98,1102,1103],{"class":237}," seeded",[98,1105,241],{"class":104},[98,1107,1108],{"class":374},"`",[98,1110,1111],{"class":378},"count|",[98,1113,382],{"class":123},[98,1115,1116],{"class":378},"props",[98,1118,105],{"class":104},[98,1120,120],{"class":378},[98,1122,105],{"class":104},[98,1124,1125],{"class":378},"key",[98,1127,404],{"class":123},[98,1129,1130],{"class":378},"|",[98,1132,382],{"class":123},[98,1134,1135],{"class":378},"value",[98,1137,105],{"class":104},[98,1139,1135],{"class":378},[98,1141,404],{"class":123},[98,1143,1108],{"class":374},[98,1145,1146],{"class":104},")\n",[29,1148,1149,1152],{},[66,1150,1151],{},"seeded"," is a tiny pseudo-random generator (mulberry32) whose seed is a hash of that string. The same key always produces the same sequence. So the preview in the business's editor, the page the customer opens and the image they save all show exactly the same composition. If the business likes how a slide looks in the preview, that's the slide the customer gets. It also prevents a classic server-rendering bug, where the server picks one random value, the browser picks a different one while hydrating, and the page flickers or warns about a mismatch.",[41,1154,1156],{"id":1155},"keeping-the-page-light","Keeping the page light",[29,1158,1159],{},"The recap page's JavaScript is around 131 KB gzipped, against the 150 KB budget. Two things keep it there.",[29,1161,1162],{},"Code that only some visitors need only loads for them. The screenshot library loads when the save picker opens. Sign-in code, toasts and tooltips don't exist on this page at all.",[29,1164,1165],{},"The budget is also checked by a test, because some regressions can't be seen in a code review. At one point, the landing page lazy-loaded the recap player so its example phone wouldn't slow down the first paint. That looked harmless. But lazy-loading the player made the bundler create a small runtime helper, and it put that helper inside one of the workspace's chunks. Every recap page then downloaded 21 KB of the workspace's menus and utilities just to get it. Nothing in the diff hinted at that. The budget test measures the real JavaScript of a production build, which is how it was caught. The landing now lazy-loads a thin wrapper around the player instead.",[41,1167,1169],{"id":1168},"link-previews-drawn-once","Link previews, drawn once",[29,1171,1172,1173,1178],{},"When a link is pasted into WhatsApp or iMessage, the app fetches a preview image for it. Every Highreel has its own: the customer's name, two of their numbers and the business's colors, drawn on the server as SVG and turned into a PNG by ",[49,1174,1177],{"href":1175,"rel":1176},"https:\u002F\u002Fgithub.com\u002Flinebender\u002Fresvg",[53],"resvg"," compiled to WebAssembly. Each one costs about a third of a second of CPU, and every chat app fetches its own copy.",[29,1180,1181],{},"So each preview is drawn once and stored in R2, under a name that includes a hash of everything the image shows:",[88,1183,1186],{"className":220,"code":1184,"filename":1185,"language":223,"meta":94,"style":94},"const key = `${folder}\u002Fog\u002F${token}-${await hashOf(recap, logoPath)}.png`\nconst stored = await getMedia(event, key)\nif (stored)\n  return stored.data\n","server\u002Fapi\u002Fr\u002F[token]\u002Fog.png.get.ts",[66,1187,1188,1244,1271,1282],{"__ignoreMap":94},[98,1189,1190,1192,1194,1196,1198,1200,1203,1205,1208,1210,1213,1215,1218,1220,1223,1226,1228,1230,1232,1235,1237,1239,1242],{"class":100,"line":101},[98,1191,1095],{"class":233},[98,1193,1125],{"class":108},[98,1195,271],{"class":104},[98,1197,375],{"class":374},[98,1199,382],{"class":123},[98,1201,1202],{"class":378},"folder",[98,1204,404],{"class":123},[98,1206,1207],{"class":378},"\u002Fog\u002F",[98,1209,382],{"class":123},[98,1211,1212],{"class":378},"token",[98,1214,404],{"class":123},[98,1216,1217],{"class":378},"-",[98,1219,382],{"class":123},[98,1221,1222],{"class":123},"await",[98,1224,1225],{"class":237}," hashOf",[98,1227,241],{"class":104},[98,1229,109],{"class":378},[98,1231,265],{"class":104},[98,1233,1234],{"class":378}," logoPath",[98,1236,335],{"class":104},[98,1238,404],{"class":123},[98,1240,1241],{"class":378},".png",[98,1243,409],{"class":374},[98,1245,1246,1248,1251,1253,1256,1259,1261,1264,1266,1269],{"class":100,"line":130},[98,1247,1095],{"class":233},[98,1249,1250],{"class":108},"stored",[98,1252,271],{"class":104},[98,1254,1255],{"class":123}," await",[98,1257,1258],{"class":237}," getMedia",[98,1260,241],{"class":104},[98,1262,1263],{"class":108},"event",[98,1265,265],{"class":104},[98,1267,1268],{"class":108}," key",[98,1270,1146],{"class":104},[98,1272,1273,1276,1278,1280],{"class":100,"line":155},[98,1274,1275],{"class":123},"if",[98,1277,324],{"class":104},[98,1279,1250],{"class":108},[98,1281,1146],{"class":104},[98,1283,1284,1286,1289,1291],{"class":100,"line":180},[98,1285,371],{"class":123},[98,1287,1288],{"class":108}," stored",[98,1290,105],{"class":104},[98,1292,1293],{"class":108},"data\n",[29,1295,1296,1297,1300],{},"The hash covers the Highreel's data, minus the signed photo URLs that change every hour without changing the picture, plus a ",[66,1298,1299],{},"DESIGN"," number that gets bumped whenever the image's layout changes. There's no cache invalidation to write. When the business changes the wording, the colors or a number, the hash changes, so the next fetch draws a new image and deletes the old one. The first fetch takes about 300 ms, and every one after it about 15.",[29,1302,1303,1304,1307],{},"This is ",[33,1305,1306],{},"content-addressed caching",": name things after what's in them, and a stale copy can't be served, because nothing will ever ask for its name again.",[1309,1310,1313],"callout",{"title":1311,"type":1312},"The takeaway","tip",[29,1314,1315],{},"Choosing what a scene looks like when nothing is moving turned out to be the most useful decision in the player. Reduced motion, saved images and identical previews all came from that one rule, instead of three features to build and keep in sync.",[1317,1318,1319],"style",{},"html pre.shiki code .sTPum, html code.shiki .sTPum{--shiki-default:#1E754F;--shiki-dark:#4D9375}html pre.shiki code .s5TCs, html code.shiki .s5TCs{--shiki-default:#AB5959;--shiki-dark:#CB7676}html pre.shiki code .s_xSY, html code.shiki .s_xSY{--shiki-default:#59873A;--shiki-dark:#80A665}html pre.shiki code .si6no, html code.shiki .si6no{--shiki-default:#999999;--shiki-dark:#666666}html pre.shiki code .s9nN2, html code.shiki .s9nN2{--shiki-default:#B07D48;--shiki-dark:#BD976A}html pre.shiki code .s_NWU, html code.shiki .s_NWU{--shiki-default:#2E8F82;--shiki-dark:#5DA994}html pre.shiki code .sqbOQ, html code.shiki .sqbOQ{--shiki-default:#2F798A;--shiki-dark:#4C9A91}html pre.shiki code .sHLBJ, html code.shiki .sHLBJ{--shiki-default:#998418;--shiki-dark:#B8A965}html pre.shiki code .scnC2, html code.shiki .scnC2{--shiki-default:#B5695977;--shiki-dark:#C98A7D77}html pre.shiki code .spP0B, html code.shiki .spP0B{--shiki-default:#B56959;--shiki-dark:#C98A7D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfsYZ, html code.shiki .sfsYZ{--shiki-default:#A65E2B;--shiki-dark:#C99076}html pre.shiki code .s8w-G, html code.shiki .s8w-G{--shiki-default:#393A34;--shiki-dark:#DBD7CAEE}html pre.shiki code .snYqZ, html code.shiki .snYqZ{--shiki-default:#A0ADA0;--shiki-dark:#758575DD}",{"title":94,"searchDepth":130,"depth":155,"links":1321},[1322,1323,1328,1329],{"id":43,"depth":130,"text":44},{"id":423,"depth":130,"text":424,"children":1324},[1325,1326,1327],{"id":727,"depth":155,"text":728},{"id":833,"depth":155,"text":834},{"id":1070,"depth":155,"text":1071},{"id":1155,"depth":130,"text":1156},{"id":1168,"depth":130,"text":1169},"How Highreel's story slides animate in plain CSS, and how one rule (every element rests at its final frame) gives reduced motion, saved images and the same Highreel every time for free.","md",false,"personal",{},{},{"title":1337},"The recap",999,"\u002Fprojects\u002Fhighreel\u002Fscenes",null,{"title":24,"description":1330},[],"projects\u002Fhighreel\u002F3.scenes","GT8QRpxU2BegoYKR4Pwad92OOuDrVPOWZPEFWKMIvCw",[1346,1355,1362,1369],{"path":1347,"title":1348,"stem":1349,"navigation":950,"description":1350,"preview":1351},"\u002Fprojects\u002Fhighreel","Highreel","projects\u002Fhighreel\u002Findex","Spotify Wrapped for any small business. Upload a spreadsheet of customer stats, and every customer gets their own animated year in review to tap through and share.",{"src":1352,"alt":1353,"og":1354},"\u002Fprojects\u002Fhighreel\u002Fpreview.webp","Highreel: 'Give your customers their highlight reel.' surrounded by recap stickers such as '212 days in the app' and 'Top 6% of all readers', and two messages from a business","\u002Fprojects\u002Fhighreel\u002Fog.png",{"path":1356,"title":1357,"stem":1358,"navigation":1359,"description":1361,"preview":1340},"\u002Fprojects\u002Fhighreel\u002Farchitecture","Keeping businesses apart without row-level security","projects\u002Fhighreel\u002F1.architecture",{"title":1360},"Architecture","Why Highreel runs on a single Cloudflare Worker, and how one data layer, a test that reads the SQL and a script that attacks the API keep every business inside its own data.",{"path":1363,"title":1364,"stem":1365,"navigation":1366,"description":1368,"preview":1340},"\u002Fprojects\u002Fhighreel\u002Fbig-sheets","50,000 rows in 128 MB","projects\u002Fhighreel\u002F2.big-sheets",{"title":1367},"Big sheets","How Highreel handles big customer sheets inside a Worker's memory limit, by measuring first, paging every route, packing rows into one JSON parameter, and adding one character to a query.",{"path":1339,"title":24,"stem":1343,"navigation":1370,"description":1330,"preview":1340},{"title":1337},[1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384],"TypeScript","Vue 3","Nuxt","Pinia","Tailwind CSS","Python","FastAPI","SQLAlchemy","Pydantic","PostgreSQL","Supabase","GCP","Firebase",1792035553939]