@bravostudioai/react 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/components.tsx +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bravostudioai/react",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -1553,6 +1553,36 @@ const SvgComponent: React.FC<ComponentProps> = ({ id, name, nodeData }) => {
1553
1553
  });
1554
1554
  const assetsById = useEncoreState((state) => state.assetsById);
1555
1555
 
1556
+ // Fix for headless rendering: Explicitly calculate width/height from positioning
1557
+ // img tags with both left+right or top+bottom might not render correctly in all browsers
1558
+ const pos = nodeData.style?.positioning;
1559
+ if (pos) {
1560
+ const hasLR = typeof pos.left === "number" && typeof pos.right === "number";
1561
+ const hasTB = typeof pos.top === "number" && typeof pos.bottom === "number";
1562
+
1563
+ // Explicitly set width if left+right are present
1564
+ if (hasLR) {
1565
+ const widthPct = 100 - pos.left - pos.right;
1566
+ style.width = `${widthPct}%`;
1567
+ // Ensure left/top are set (useEncoreStyle sets them, but we want to be sure)
1568
+ style.left = `${pos.left}%`;
1569
+ delete style.right;
1570
+ }
1571
+
1572
+ // Explicitly set height if top+bottom are present
1573
+ if (hasTB) {
1574
+ const heightPct = 100 - pos.top - pos.bottom;
1575
+ style.height = `${heightPct}%`;
1576
+ style.top = `${pos.top}%`;
1577
+ delete style.bottom;
1578
+ }
1579
+ }
1580
+
1581
+ // Ensure object fills the box
1582
+ if (!style.objectFit) {
1583
+ style.objectFit = "fill"; // Default to fill for SVGs/Groups to match Figma bounds
1584
+ }
1585
+
1556
1586
  return (
1557
1587
  <EncoreLinkActionWrapper id={id} nodeData={nodeData}>
1558
1588
  <img