Compare commits

...
2 Commits
Author SHA1 Message Date
MehboobKandClaude Sonnet 5 5232e6bd64 Add download button to the ROI slide card
CI / build (push) Canceled after 0s
Lazy-loads html2canvas (separate chunk, only fetched on click) to export
the card as a PNG. The button floats on the card's top-right corner,
outside the captured element, so it never ends up in the exported image.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 17:32:18 +05:00
MehboobKandClaude Sonnet 5 6d1ad44e6d Restore hero image for the South-east Asia blog post
The wp-content URL 404s on the current server, but the Wayback Machine
had a genuine image/png capture from 2026-09-02 (a later crawl only
caught the SPA fallback page, which is why the dead link looked "alive").
Recovered it, re-encoded as JPEG to match the other migrated posts, and
wired it back into the post's hero field.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 17:25:43 +05:00
6 changed files with 143 additions and 3 deletions
+50
View File
@@ -9,6 +9,7 @@
"version": "1.0.0",
"dependencies": {
"framer-motion": "^11.18.2",
"html2canvas": "^1.4.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
@@ -1251,6 +1252,15 @@
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
}
},
"node_modules/base64-arraybuffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/baseline-browser-mapping": {
"version": "2.10.40",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.40.tgz",
@@ -1326,6 +1336,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/css-line-break": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
"license": "MIT",
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -1565,6 +1584,19 @@
"node": ">=6.9.0"
}
},
"node_modules/html2canvas": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
"license": "MIT",
"dependencies": {
"css-line-break": "^2.1.0",
"text-segmentation": "^1.0.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/htmlparser2": {
"version": "12.0.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-12.0.0.tgz",
@@ -1907,6 +1939,15 @@
"node": ">=0.10.0"
}
},
"node_modules/text-segmentation": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
"license": "MIT",
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
@@ -1958,6 +1999,15 @@
"browserslist": ">= 4.21.0"
}
},
"node_modules/utrie": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
"license": "MIT",
"dependencies": {
"base64-arraybuffer": "^1.0.2"
}
},
"node_modules/vite": {
"version": "5.4.21",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
+1
View File
@@ -15,6 +15,7 @@
},
"dependencies": {
"framer-motion": "^11.18.2",
"html2canvas": "^1.4.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

File diff suppressed because one or more lines are too long
+42 -1
View File
@@ -1,3 +1,4 @@
import { useRef, useState } from 'react'
import './roiSlide.css'
import hexMotif from './hexMotif.svg?raw'
@@ -36,9 +37,48 @@ export default function RoiSlide({ values, results }: { values: DeckValues; resu
const mids = CATS.map((c) => Math.max(0, (results[c.key].lo + results[c.key].hi) / 2))
const totalMid = mids.reduce((a, b) => a + b, 0)
const cardRef = useRef<HTMLDivElement>(null)
const [downloading, setDownloading] = useState(false)
const download = async () => {
if (!cardRef.current || downloading) return
setDownloading(true)
try {
const { default: html2canvas } = await import('html2canvas')
const canvas = await html2canvas(cardRef.current, { backgroundColor: null, scale: 2 })
const a = document.createElement('a')
a.download = `blackdice-roi-savings-${new Date().toISOString().slice(0, 10)}.png`
a.href = canvas.toDataURL('image/png')
a.click()
} catch {
/* best effort — leave the slide visible either way */
} finally {
setDownloading(false)
}
}
return (
<div className="roi-slide">
<div className="roi-slide-card">
<div className="roi-slide-card-wrap">
<button
type="button"
className="roi-slide-download"
onClick={download}
disabled={downloading}
aria-label="Download slide as image"
title="Download as image"
>
{downloading ? (
<svg viewBox="0 0 24 24">
<path d="M12 2a10 10 0 0 1 10 10" />
</svg>
) : (
<svg viewBox="0 0 24 24">
<path d="M12 3v12m0 0l-4-4m4 4l4-4M4 17v2a2 2 0 002 2h12a2 2 0 002-2v-2" />
</svg>
)}
</button>
<div className="roi-slide-card" ref={cardRef}>
<div className="roi-slide-hex" dangerouslySetInnerHTML={{ __html: hexMotif }} />
<div className="roi-slide-top">
<img src="/logo.svg" alt="BlackDice" className="roi-slide-logo" />
@@ -80,5 +120,6 @@ export default function RoiSlide({ values, results }: { values: DeckValues; resu
</div>
</div>
</div>
</div>
)
}
+49 -1
View File
@@ -13,9 +13,57 @@
justify-content: center;
}
.roi-slide-card {
.roi-slide-card-wrap {
position: relative;
width: 100%;
max-width: 860px;
}
.roi-slide-download {
position: absolute;
top: -14px;
right: -14px;
z-index: 2;
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
border-radius: 50%;
border: 1px solid rgba(255, 255, 255, 0.25);
background: var(--rs-teal2);
box-shadow: 0 4px 14px rgba(1, 59, 73, 0.4);
color: #fff;
cursor: pointer;
transition: background 0.15s, opacity 0.15s;
}
.roi-slide-download:hover:not(:disabled) {
background: var(--rs-teal3);
}
.roi-slide-download:disabled {
opacity: 0.5;
cursor: wait;
}
.roi-slide-download svg {
width: 16px;
height: 16px;
stroke: currentColor;
fill: none;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.roi-slide-download:disabled svg {
animation: roi-slide-spin 0.8s linear infinite;
}
@keyframes roi-slide-spin {
to {
transform: rotate(360deg);
}
}
.roi-slide-card {
width: 100%;
aspect-ratio: 16 / 9;
background: linear-gradient(135deg, var(--rs-teal) 0%, var(--rs-teal2) 60%, var(--rs-teal3) 100%);
border-radius: 16px;