Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
style: format us-map and world-map after stagger change
Miguel Ángel8b4c994611b7
diff --git a/registry/blocks/us-map/us-map.html b/registry/blocks/us-map/us-map.htmlindex c555f01f0e..3a8c59a3b6 100644--- a/registry/blocks/us-map/us-map.html+++ b/registry/blocks/us-map/us-map.html@@ -158,8 +158,7 @@<script>(function () {- const US_TOPO_URL =- "https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json";+ const US_TOPO_URL = "https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json";const stateData = {"01": { name: "Alabama", abbr: "AL", density: 99.2 },@@ -169,49 +168,49 @@"06": { name: "California", abbr: "CA", density: 253.9 },"08": { name: "Colorado", abbr: "CO", density: 56.5 },"09": { name: "Connecticut", abbr: "CT", density: 738.1 },- "10": { name: "Delaware", abbr: "DE", density: 508.0 },- "12": { name: "Florida", abbr: "FL", density: 410.5 },- "13": { name: "Georgia", abbr: "GA", density: 185.6 },- "15": { name: "Hawaii", abbr: "HI", density: 226.6 },- "16": { name: "Idaho", abbr: "ID", density: 22.8 },- "17": { name: "Illinois", abbr: "IL", density: 228.2 },- "18": { name: "Indiana", abbr: "IN", density: 186.7 },- "19": { name: "Iowa", abbr: "IA", density: 57.1 },- "20": { name: "Kansas", abbr: "KS", density: 35.9 },- "21": { name: "Kentucky", abbr: "KY", density: 113.2 },- "22": { name: "Louisiana", abbr: "LA", density: 107.7 },- "23": { name: "Maine", abbr: "ME", density: 43.8 },- "24": { name: "Maryland", abbr: "MD", density: 636.1 },- "25": { name: "Massachusetts", abbr: "MA", density: 901.2 },- "26": { name: "Michigan", abbr: "MI", density: 176.4 },- "27": { name: "Minnesota", abbr: "MN", density: 71.7 },- "28": { name: "Mississippi", abbr: "MS", density: 63.5 },- "29": { name: "Missouri", abbr: "MO", density: 89.5 },- "30": { name: "Montana", abbr: "MT", density: 7.6 },- "31": { name: "Nebraska", abbr: "NE", density: 25.3 },- "32": { name: "Nevada", abbr: "NV", density: 28.3 },- "33": { name: "New Hampshire", abbr: "NH", density: 153.2 },- "34": { name: "New Jersey", abbr: "NJ", density: 1263.0 },- "35": { name: "New Mexico", abbr: "NM", density: 17.4 },- "36": { name: "New York", abbr: "NY", density: 415.3 },- "37": { name: "North Carolina", abbr: "NC", density: 214.7 },- "38": { name: "North Dakota", abbr: "ND", density: 11.3 },- "39": { name: "Ohio", abbr: "OH", density: 288.8 },- "40": { name: "Oklahoma", abbr: "OK", density: 57.7 },- "41": { name: "Oregon", abbr: "OR", density: 43.9 },- "42": { name: "Pennsylvania", abbr: "PA", density: 286.1 },- "44": { name: "Rhode Island", abbr: "RI", density: 1061.4 },- "45": { name: "South Carolina", abbr: "SC", density: 170.2 },- "46": { name: "South Dakota", abbr: "SD", density: 12.2 },- "47": { name: "Tennessee", abbr: "TN", density: 167.0 },- "48": { name: "Texas", abbr: "TX", density: 112.8 },- "49": { name: "Utah", abbr: "UT", density: 40.3 },- "50": { name: "Vermont", abbr: "VT", density: 68.0 },- "51": { name: "Virginia", abbr: "VA", density: 218.6 },- "53": { name: "Washington", abbr: "WA", density: 115.9 },- "54": { name: "West Virginia", abbr: "WV", density: 74.6 },- "55": { name: "Wisconsin", abbr: "WI", density: 108.8 },- "56": { name: "Wyoming", abbr: "WY", density: 5.8 },+ 10: { name: "Delaware", abbr: "DE", density: 508.0 },+ 12: { name: "Florida", abbr: "FL", density: 410.5 },+ 13: { name: "Georgia", abbr: "GA", density: 185.6 },+ 15: { name: "Hawaii", abbr: "HI", density: 226.6 },+ 16: { name: "Idaho", abbr: "ID", density: 22.8 },+ 17: { name: "Illinois", abbr: "IL", density: 228.2 },+ 18: { name: "Indiana", abbr: "IN", density: 186.7 },+ 19: { name: "Iowa", abbr: "IA", density: 57.1 },+ 20: { name: "Kansas", abbr: "KS", density: 35.9 },+ 21: { name: "Kentucky", abbr: "KY", density: 113.2 },+ 22: { name: "Louisiana", abbr: "LA", density: 107.7 },+ 23: { name: "Maine", abbr: "ME", density: 43.8 },+ 24: { name: "Maryland", abbr: "MD", density: 636.1 },+ 25: { name: "Massachusetts", abbr: "MA", density: 901.2 },+ 26: { name: "Michigan", abbr: "MI", density: 176.4 },+ 27: { name: "Minnesota", abbr: "MN", density: 71.7 },+ 28: { name: "Mississippi", abbr: "MS", density: 63.5 },+ 29: { name: "Missouri", abbr: "MO", density: 89.5 },+ 30: { name: "Montana", abbr: "MT", density: 7.6 },+ 31: { name: "Nebraska", abbr: "NE", density: 25.3 },+ 32: { name: "Nevada", abbr: "NV", density: 28.3 },+ 33: { name: "New Hampshire", abbr: "NH", density: 153.2 },+ 34: { name: "New Jersey", abbr: "NJ", density: 1263.0 },+ 35: { name: "New Mexico", abbr: "NM", density: 17.4 },+ 36: { name: "New York", abbr: "NY", density: 415.3 },+ 37: { name: "North Carolina", abbr: "NC", density: 214.7 },+ 38: { name: "North Dakota", abbr: "ND", density: 11.3 },+ 39: { name: "Ohio", abbr: "OH", density: 288.8 },+ 40: { name: "Oklahoma", abbr: "OK", density: 57.7 },+ 41: { name: "Oregon", abbr: "OR", density: 43.9 },+ 42: { name: "Pennsylvania", abbr: "PA", density: 286.1 },+ 44: { name: "Rhode Island", abbr: "RI", density: 1061.4 },+ 45: { name: "South Carolina", abbr: "SC", density: 170.2 },+ 46: { name: "South Dakota", abbr: "SD", density: 12.2 },+ 47: { name: "Tennessee", abbr: "TN", density: 167.0 },+ 48: { name: "Texas", abbr: "TX", density: 112.8 },+ 49: { name: "Utah", abbr: "UT", density: 40.3 },+ 50: { name: "Vermont", abbr: "VT", density: 68.0 },+ 51: { name: "Virginia", abbr: "VA", density: 218.6 },+ 53: { name: "Washington", abbr: "WA", density: 115.9 },+ 54: { name: "West Virginia", abbr: "WV", density: 74.6 },+ 55: { name: "Wisconsin", abbr: "WI", density: 108.8 },+ 56: { name: "Wyoming", abbr: "WY", density: 5.8 },};const maxDensity = 500;@@ -237,9 +236,7 @@return "rgb(" + r + "," + g + "," + bl + ")";}- const svg = document.querySelector(- '#us-map .map-svg'- );+ const svg = document.querySelector("#us-map .map-svg");const statesGroup = svg.querySelector(".states-group");const labelsGroup = svg.querySelector(".labels-group");const tl = gsap.timeline({ paused: true });@@ -256,10 +253,8 @@const sortedStates = states.filter((f) => stateData[String(f.id).padStart(2, "0")]).sort((a, b) => {- const aData =- stateData[String(a.id).padStart(2, "0")];- const bData =- stateData[String(b.id).padStart(2, "0")];+ const aData = stateData[String(a.id).padStart(2, "0")];+ const bData = stateData[String(b.id).padStart(2, "0")];return aData.density - bData.density;});@@ -271,10 +266,7 @@const d = path(feature);if (!d) return;- const el = document.createElementNS(- "http://www.w3.org/2000/svg",- "path"- );+ const el = document.createElementNS("http://www.w3.org/2000/svg", "path");el.setAttribute("d", d);el.setAttribute("class", "state-path");el.setAttribute("data-state", info.abbr);@@ -284,10 +276,7 @@const centroid = path.centroid(feature);if (centroid[0] && centroid[1]) {- const label = document.createElementNS(- "http://www.w3.org/2000/svg",- "text"- );+ const label = document.createElementNS("http://www.w3.org/2000/svg", "text");label.setAttribute("x", centroid[0]);label.setAttribute("y", centroid[1]);label.setAttribute("class", "state-label");@@ -304,23 +293,23 @@const stateLabels = labelsGroup.querySelectorAll(".state-label");tl.to(- '#us-map .headline',+ "#us-map .headline",{clipPath: "inset(0 0% 0 0)",duration: 1.0,ease: "power2.inOut",},- 0+ 0,);tl.to(- '#us-map .subtitle',+ "#us-map .subtitle",{opacity: 1,duration: 0.6,ease: "power2.out",},- 0.4+ 0.4,);tl.to(@@ -335,7 +324,7 @@},ease: "back.out(1.4)",},- 1.0+ 1.0,);tl.to(@@ -349,35 +338,33 @@},ease: "power2.out",},- 3.5+ 3.5,);tl.to(- '#us-map .legend',+ "#us-map .legend",{opacity: 1,y: 0,duration: 0.6,ease: "power2.out",},- 5.0+ 5.0,);tl.to(- '#us-map .source',+ "#us-map .source",{opacity: 1,duration: 0.5,ease: "power2.out",},- 5.5+ 5.5,);const highlightStates = ["CA", "NY", "TX", "FL", "NJ"];highlightStates.forEach((abbr, i) => {- const el = statesGroup.querySelector(- "[data-state=\"" + abbr + "\"]"- );+ const el = statesGroup.querySelector('[data-state="' + abbr + '"]');if (!el) return;tl.to(@@ -389,7 +376,7 @@duration: 0.5,ease: "power2.out",},- 6.5 + i * 0.8+ 6.5 + i * 0.8,);tl.to(@@ -401,7 +388,7 @@duration: 0.5,ease: "power2.in",},- 7.0 + i * 0.8+ 7.0 + i * 0.8,);});diff --git a/registry/blocks/world-map/world-map.html b/registry/blocks/world-map/world-map.htmlindex 1b8703fa60..4e451c217b 100644--- a/registry/blocks/world-map/world-map.html+++ b/registry/blocks/world-map/world-map.html@@ -170,7 +170,9 @@<div class="legend-group"><divclass="legend-bar"- style="background: linear-gradient(90deg, #064e3b 0%, #0d9488 33%, #22d3ee 66%, #f0fdfa 100%)"+ style="+ background: linear-gradient(90deg, #064e3b 0%, #0d9488 33%, #22d3ee 66%, #f0fdfa 100%);+ "></div><div class="legend-labels"><span>Low</span>@@ -188,36 +190,36 @@/* ── GDP per capita data (2024 IMF estimates, USD) ── *//* Keys are ISO 3166-1 numeric codes as strings (3-digit, zero-padded) */var gdpData = {- "840": { name: "United States", gdp: 85373 },- "156": { name: "China", gdp: 13136 },- "356": { name: "India", gdp: 2731 },- "276": { name: "Germany", gdp: 54291 },- "826": { name: "United Kingdom", gdp: 48913 },- "250": { name: "France", gdp: 44408 },- "392": { name: "Japan", gdp: 33950 },+ 840: { name: "United States", gdp: 85373 },+ 156: { name: "China", gdp: 13136 },+ 356: { name: "India", gdp: 2731 },+ 276: { name: "Germany", gdp: 54291 },+ 826: { name: "United Kingdom", gdp: 48913 },+ 250: { name: "France", gdp: 44408 },+ 392: { name: "Japan", gdp: 33950 },"076": { name: "Brazil", gdp: 10412 },"036": { name: "Australia", gdp: 65366 },- "124": { name: "Canada", gdp: 54866 },- "643": { name: "Russia", gdp: 14403 },- "410": { name: "South Korea", gdp: 33147 },- "484": { name: "Mexico", gdp: 13434 },- "360": { name: "Indonesia", gdp: 5108 },- "566": { name: "Nigeria", gdp: 1621 },- "710": { name: "South Africa", gdp: 6190 },- "818": { name: "Egypt", gdp: 4295 },- "792": { name: "Turkey", gdp: 13110 },- "682": { name: "Saudi Arabia", gdp: 32270 },- "764": { name: "Thailand", gdp: 7647 },- "704": { name: "Vietnam", gdp: 4623 },- "616": { name: "Poland", gdp: 22393 },- "752": { name: "Sweden", gdp: 59324 },- "578": { name: "Norway", gdp: 94660 },- "756": { name: "Switzerland", gdp: 105669 },+ 124: { name: "Canada", gdp: 54866 },+ 643: { name: "Russia", gdp: 14403 },+ 410: { name: "South Korea", gdp: 33147 },+ 484: { name: "Mexico", gdp: 13434 },+ 360: { name: "Indonesia", gdp: 5108 },+ 566: { name: "Nigeria", gdp: 1621 },+ 710: { name: "South Africa", gdp: 6190 },+ 818: { name: "Egypt", gdp: 4295 },+ 792: { name: "Turkey", gdp: 13110 },+ 682: { name: "Saudi Arabia", gdp: 32270 },+ 764: { name: "Thailand", gdp: 7647 },+ 704: { name: "Vietnam", gdp: 4623 },+ 616: { name: "Poland", gdp: 22393 },+ 752: { name: "Sweden", gdp: 59324 },+ 578: { name: "Norway", gdp: 94660 },+ 756: { name: "Switzerland", gdp: 105669 },"032": { name: "Argentina", gdp: 13709 },- "170": { name: "Colombia", gdp: 7230 },- "404": { name: "Kenya", gdp: 2198 },- "586": { name: "Pakistan", gdp: 1658 },- "050": { name: "Bangladesh", gdp: 2688 }+ 170: { name: "Colombia", gdp: 7230 },+ 404: { name: "Kenya", gdp: 2198 },+ 586: { name: "Pakistan", gdp: 1658 },+ "050": { name: "Bangladesh", gdp: 2688 },};/* Top 5 GDP countries for highlight pulse */@@ -237,7 +239,7 @@{ r: 6, g: 78, b: 59 },{ r: 13, g: 148, b: 136 },{ r: 34, g: 211, b: 238 },- { r: 240, g: 253, b: 250 }+ { r: 240, g: 253, b: 250 },];function gdpToColor(value) {@@ -264,78 +266,69 @@.attr("viewBox", "0 0 1380 700").attr("preserveAspectRatio", "xMidYMid meet");- var projection = d3- .geoNaturalEarth1()- .fitSize([1380, 700], { type: "Sphere" });+ var projection = d3.geoNaturalEarth1().fitSize([1380, 700], { type: "Sphere" });var pathGenerator = d3.geoPath().projection(projection);/* Graticule */var graticule = d3.geoGraticule10();- svg- .append("path")- .datum(graticule)- .attr("class", "graticule")- .attr("d", pathGenerator);+ svg.append("path").datum(graticule).attr("class", "graticule").attr("d", pathGenerator);/* Tooltip element */var tooltipEl = document.querySelector("#world-map .tooltip");/* Fetch topology and render countries */- d3.json(- "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json"- ).then(function (world) {- var countries = topojson.feature(- world,- world.objects.countries- ).features;-- svg- .selectAll(".country-path")- .data(countries)- .enter()- .append("path")- .attr("class", "country-path")- .attr("d", pathGenerator)- .attr("data-country", function (d) {- return String(d.id).padStart(3, "0");- })- .attr("fill", function (d) {- var code = String(d.id).padStart(3, "0");- if (gdpData[code]) {- return gdpToColor(gdpData[code].gdp);- }- return defaultFill;- })- .on("mouseenter", function (event, d) {- var code = String(d.id).padStart(3, "0");- if (gdpData[code]) {- var entry = gdpData[code];- tooltipEl.innerHTML =- entry.name +- '<span class="tt-value">$' +- entry.gdp.toLocaleString() +- "</span>";- tooltipEl.style.opacity = "1";- tooltipEl.style.transform = "translateY(0)";- }- })- .on("mousemove", function (event) {- var container = document.querySelector("#world-map");- var rect = container.getBoundingClientRect();- var x = event.clientX - rect.left + 16;- var y = event.clientY - rect.top - 40;- tooltipEl.style.left = x + "px";- tooltipEl.style.top = y + "px";- })- .on("mouseleave", function () {- tooltipEl.style.opacity = "0";- tooltipEl.style.transform = "translateY(4px)";- });-- /* ── GSAP Timeline ── */- buildTimeline();- });+ d3.json("https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json").then(+ function (world) {+ var countries = topojson.feature(world, world.objects.countries).features;++ svg+ .selectAll(".country-path")+ .data(countries)+ .enter()+ .append("path")+ .attr("class", "country-path")+ .attr("d", pathGenerator)+ .attr("data-country", function (d) {+ return String(d.id).padStart(3, "0");+ })+ .attr("fill", function (d) {+ var code = String(d.id).padStart(3, "0");+ if (gdpData[code]) {+ return gdpToColor(gdpData[code].gdp);+ }+ return defaultFill;+ })+ .on("mouseenter", function (event, d) {+ var code = String(d.id).padStart(3, "0");+ if (gdpData[code]) {+ var entry = gdpData[code];+ tooltipEl.innerHTML =+ entry.name ++ '<span class="tt-value">$' ++ entry.gdp.toLocaleString() ++ "</span>";+ tooltipEl.style.opacity = "1";+ tooltipEl.style.transform = "translateY(0)";+ }+ })+ .on("mousemove", function (event) {+ var container = document.querySelector("#world-map");+ var rect = container.getBoundingClientRect();+ var x = event.clientX - rect.left + 16;+ var y = event.clientY - rect.top - 40;+ tooltipEl.style.left = x + "px";+ tooltipEl.style.top = y + "px";+ })+ .on("mouseleave", function () {+ tooltipEl.style.opacity = "0";+ tooltipEl.style.transform = "translateY(4px)";+ });++ /* ── GSAP Timeline ── */+ buildTimeline();+ },+ );function buildTimeline() {var tl = gsap.timeline({ paused: true });@@ -346,9 +339,9 @@{clipPath: "inset(0 0% 0 0)",duration: 1,- ease: "power3.inOut"+ ease: "power3.inOut",},- 0+ 0,);/* 0.4s: Subtitle fade in (0.6s) */@@ -357,9 +350,9 @@{opacity: 1,duration: 0.6,- ease: "power2.out"+ ease: "power2.out",},- 0.4+ 0.4,);/* 1.0s: Countries stagger reveal */@@ -370,11 +363,11 @@duration: 0.3,stagger: {each: 0.02,- from: "center"+ from: "center",},- ease: "power1.out"+ ease: "power1.out",},- 1.0+ 1.0,);/* 4.0s: Legend fade in */@@ -383,9 +376,9 @@{opacity: 1,duration: 0.6,- ease: "power2.out"+ ease: "power2.out",},- 4.0+ 4.0,);/* 4.5s: Source fade in */@@ -394,15 +387,14 @@{opacity: 1,duration: 0.5,- ease: "power2.out"+ ease: "power2.out",},- 4.5+ 4.5,);/* 5.0s: Highlight pulse on top 5 GDP countries */for (var i = 0; i < top5Codes.length; i++) {- var selector =- '#world-map [data-country="' + top5Codes[i] + '"]';+ var selector = '#world-map [data-country="' + top5Codes[i] + '"]';/* Pulse up: brightness + white stroke */tl.to(@@ -412,9 +404,9 @@stroke: "#ffffff",strokeWidth: 1.8,duration: 0.4,- ease: "power2.out"+ ease: "power2.out",},- 5.0 + i * 0.15+ 5.0 + i * 0.15,);/* Pulse back to normal */@@ -425,9 +417,9 @@stroke: "#1e293b",strokeWidth: 0.6,duration: 0.6,- ease: "power2.inOut"+ ease: "power2.inOut",},- 5.0 + i * 0.15 + 0.4+ 5.0 + i * 0.15 + 0.4,);}