From bee8955e31b90bd02b45976281e52ce8753049e7 Mon Sep 17 00:00:00 2001 From: yeasin50 <46500228+yeasin50@users.noreply.github.com> Date: Mon, 11 May 2026 18:05:44 +0600 Subject: [PATCH 1/2] fixed(watch) update the body BG to match svg BG --- d2cli/static/watch.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/d2cli/static/watch.js b/d2cli/static/watch.js index b3596eff2d..08b84509cf 100644 --- a/d2cli/static/watch.js +++ b/d2cli/static/watch.js @@ -26,6 +26,14 @@ function init(reconnectDelay) { // we can't just set `d2SVG.innerHTML = msg.svg` need to parse this as xml not html const parsedXML = new DOMParser().parseFromString(msg.svg, "text/xml"); d2SVG.replaceChildren(parsedXML.documentElement); + + // Update the body/container background that match the SVG background + const bgRect = d2SVG.querySelector("rect"); + if (bgRect && bgRect.hasAttribute("fill")) { + const bgColor = bgRect.getAttribute("fill"); + document.body.style.backgroundColor = bgColor; + } + changeFavicon("/static/favicon.ico"); const svgEl = d2SVG.querySelector(".d2-svg"); // just use inner SVG in watch mode From c008fac423dc05af68deec6a6e515a78f23f2afb Mon Sep 17 00:00:00 2001 From: yeasin50 <46500228+yeasin50@users.noreply.github.com> Date: Mon, 11 May 2026 18:05:44 +0600 Subject: [PATCH 2/2] fixed(watch) update the body BG to match svg BG --- ci/release/changelogs/next.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f4616390ed..21eef7af11 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -13,6 +13,8 @@ - `animate-interval` is no longer required, defaults to 1000ms for gifs [#2663](https://github.com/terrastruct/d2/pull/2663) - renders: - remote images are fetched more reliably [#2659](https://github.com/terrastruct/d2/pull/2659) +- d2cli: + - Update the body background that match the SVG background [#2745](https://github.com/terrastruct/d2/pull/2745) #### Bugfixes ⛑️