From dedc0e7873062690b9bdb06207f09d2d6d2fc43c Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Fri, 19 Sep 2025 15:45:46 -0500 Subject: [PATCH] fix: match React component font sizing for SVG numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated SVG text generation to use the exact same font size calculation as the React component: Math.max(8, 14 * scaleFactor). This ensures perfect visual consistency between live React components and generated SVG examples. Font styling now matches exactly: - fontSize: Math.max(8, 14 * scaleFactor) - fontFamily: 'monospace' - fontWeight: 'bold' 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- packages/abacus-react/examples/README.md | 2 +- packages/abacus-react/examples/basic-usage.svg | 2 +- packages/abacus-react/examples/custom-styling.svg | 2 +- packages/abacus-react/examples/interactive.svg | 2 +- packages/abacus-react/examples/tutorial-mode.svg | 2 +- packages/abacus-react/generate-examples.js | 6 +++++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/abacus-react/examples/README.md b/packages/abacus-react/examples/README.md index 7875c637..d0615e4a 100644 --- a/packages/abacus-react/examples/README.md +++ b/packages/abacus-react/examples/README.md @@ -26,4 +26,4 @@ Or referenced in HTML: --- _Generated automatically by generate-examples.js using react-dom/server_ -_Last updated: 2025-09-19T20:44:02.744Z_ +_Last updated: 2025-09-19T20:45:33.669Z_ diff --git a/packages/abacus-react/examples/basic-usage.svg b/packages/abacus-react/examples/basic-usage.svg index 73710806..29b4221c 100644 --- a/packages/abacus-react/examples/basic-usage.svg +++ b/packages/abacus-react/examples/basic-usage.svg @@ -31,4 +31,4 @@ .abacus-svg.hide-inactive-mode:not(.interactive) .abacus-bead.hidden-inactive { opacity: 0 !important; } - 123 \ No newline at end of file + 123 \ No newline at end of file diff --git a/packages/abacus-react/examples/custom-styling.svg b/packages/abacus-react/examples/custom-styling.svg index 9740cc42..33888e6f 100644 --- a/packages/abacus-react/examples/custom-styling.svg +++ b/packages/abacus-react/examples/custom-styling.svg @@ -49,4 +49,4 @@ .abacus-svg.hide-inactive-mode:not(.interactive) .abacus-bead.hidden-inactive { opacity: 0 !important; } - 789 \ No newline at end of file + 789 \ No newline at end of file diff --git a/packages/abacus-react/examples/interactive.svg b/packages/abacus-react/examples/interactive.svg index 40721972..4f7184a2 100644 --- a/packages/abacus-react/examples/interactive.svg +++ b/packages/abacus-react/examples/interactive.svg @@ -31,4 +31,4 @@ .abacus-svg.hide-inactive-mode:not(.interactive) .abacus-bead.hidden-inactive { opacity: 0 !important; } - 456 \ No newline at end of file + 456 \ No newline at end of file diff --git a/packages/abacus-react/examples/tutorial-mode.svg b/packages/abacus-react/examples/tutorial-mode.svg index 247d1d89..8de8757d 100644 --- a/packages/abacus-react/examples/tutorial-mode.svg +++ b/packages/abacus-react/examples/tutorial-mode.svg @@ -31,4 +31,4 @@ .abacus-svg.hide-inactive-mode:not(.interactive) .abacus-bead.hidden-inactive { opacity: 0 !important; } - 42 \ No newline at end of file + 42 \ No newline at end of file diff --git a/packages/abacus-react/generate-examples.js b/packages/abacus-react/generate-examples.js index d1ded5da..a045729e 100644 --- a/packages/abacus-react/generate-examples.js +++ b/packages/abacus-react/generate-examples.js @@ -276,7 +276,11 @@ async function generateSVGExamples() { const x = parseFloat(xMatch[1]) + parseFloat(widthMatch[1]) / 2; // Center horizontally const y = parseFloat(yMatch[1]) + parseFloat(heightMatch[1]) / 2 + 4; // Center vertically with slight offset - return `${textContent.trim()}`; + // Calculate font size to match React component: Math.max(8, 14 * scaleFactor) + const scaleFactor = example.props.scaleFactor || 1.0; + const fontSize = Math.max(8, 14 * scaleFactor); + + return `${textContent.trim()}`; } return match; // Return original if we can't parse }