@cntrl-site/components 0.1.0-3 → 0.1.0-5

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.
@@ -29,7 +29,6 @@ type Alignment = 'top-left' | 'top-center' | 'top-right' | 'middle-left' | 'midd
29
29
  type Caption = {
30
30
  isActive: boolean;
31
31
  alignment: Alignment;
32
- color: string;
33
32
  offset: Offset;
34
33
  hover: string;
35
34
  };
package/dist/index.js CHANGED
@@ -1483,14 +1483,29 @@ const styles = {
1483
1483
  };
1484
1484
  function LightboxGallery({ settings, content, styles: styles2, portalId }) {
1485
1485
  const [open, setOpen] = React.useState(false);
1486
+ const [wrapperRef, setWrapperRef] = React.useState(null);
1487
+ const [coverDimensions, setCoverDimensions] = React.useState(void 0);
1486
1488
  const { url: coverUrl } = settings.cover;
1487
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1489
+ React.useEffect(() => {
1490
+ if (!wrapperRef) return;
1491
+ const observer = new ResizeObserver((entries) => {
1492
+ if (!wrapperRef) return;
1493
+ const [wrapper2] = entries;
1494
+ setCoverDimensions({
1495
+ width: Math.round(wrapper2.contentRect.width),
1496
+ height: Math.round(wrapper2.contentRect.height)
1497
+ });
1498
+ });
1499
+ observer.observe(wrapperRef);
1500
+ return () => observer.unobserve(wrapperRef);
1501
+ }, [wrapperRef]);
1502
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: setWrapperRef, children: [
1488
1503
  /* @__PURE__ */ jsxRuntime.jsx(
1489
1504
  "img",
1490
1505
  {
1491
1506
  src: coverUrl,
1492
1507
  alt: "Cover",
1493
- style: { width: "100%", height: "100%", cursor: "pointer" },
1508
+ style: { width: (coverDimensions == null ? void 0 : coverDimensions.width) ? coverDimensions.width : "100%", height: (coverDimensions == null ? void 0 : coverDimensions.height) ? coverDimensions.height : "100%", cursor: "pointer" },
1494
1509
  onClick: () => setOpen(true)
1495
1510
  }
1496
1511
  ),
@@ -1696,7 +1711,7 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1696
1711
  )
1697
1712
  ] }),
1698
1713
  settings.area.closeIconUrl && /* @__PURE__ */ jsxRuntime.jsx("button", { className: styles.closeButton, style: { top: settings.area.closeIconOffset.y, left: settings.area.closeIconOffset.x }, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { url: settings.area.closeIconUrl, fill: settings.area.color }) }),
1699
- settings.caption.isActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.caption, style: { top: settings.caption.offset.y, left: settings.caption.offset.x, color: settings.caption.color }, children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption }) }),
1714
+ settings.caption.isActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.caption, style: { top: settings.caption.offset.y, left: settings.caption.offset.x }, children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption }) }),
1700
1715
  settings.thumbnail.isActive && /* @__PURE__ */ jsxRuntime.jsx(
1701
1716
  "div",
1702
1717
  {
@@ -1767,7 +1782,7 @@ const LightboxComponent = {
1767
1782
  properties: {
1768
1783
  cover: {
1769
1784
  title: "COVER",
1770
- icon: "image",
1785
+ icon: "cover",
1771
1786
  tooltip: "Cover Image",
1772
1787
  type: "object",
1773
1788
  properties: {
@@ -1874,7 +1889,7 @@ const LightboxComponent = {
1874
1889
  },
1875
1890
  thumbnail: {
1876
1891
  title: "THUMB",
1877
- icon: "pagination",
1892
+ icon: "thumbnail",
1878
1893
  tooltip: "Thumbnail",
1879
1894
  type: "object",
1880
1895
  properties: {
@@ -1902,7 +1917,7 @@ const LightboxComponent = {
1902
1917
  type: "string",
1903
1918
  title: "Align",
1904
1919
  display: {
1905
- type: "ratio-group"
1920
+ type: "align-grid"
1906
1921
  },
1907
1922
  enum: ["top", "center", "bottom"]
1908
1923
  },
@@ -2105,7 +2120,7 @@ const LightboxComponent = {
2105
2120
  },
2106
2121
  area: {
2107
2122
  title: "AREA",
2108
- icon: "background",
2123
+ icon: "area",
2109
2124
  tooltip: "Area",
2110
2125
  type: "object",
2111
2126
  properties: {
@@ -2181,14 +2196,6 @@ const LightboxComponent = {
2181
2196
  }
2182
2197
  }
2183
2198
  },
2184
- color: {
2185
- title: "Color",
2186
- type: "string",
2187
- display: {
2188
- type: "settings-color-picker",
2189
- format: "single"
2190
- }
2191
- },
2192
2199
  hover: {
2193
2200
  title: "Hover",
2194
2201
  type: "string",
@@ -2259,7 +2266,6 @@ const LightboxComponent = {
2259
2266
  caption: {
2260
2267
  alignment: "middle-center",
2261
2268
  offset: { x: 0, y: 0 },
2262
- color: "#000000",
2263
2269
  hover: "#cccccc"
2264
2270
  }
2265
2271
  },
package/dist/index.mjs CHANGED
@@ -1480,15 +1480,30 @@ const styles = {
1480
1480
  slideInBottom
1481
1481
  };
1482
1482
  function LightboxGallery({ settings, content, styles: styles2, portalId }) {
1483
- const [open, setOpen] = React.useState(false);
1483
+ const [open, setOpen] = useState(false);
1484
+ const [wrapperRef, setWrapperRef] = useState(null);
1485
+ const [coverDimensions, setCoverDimensions] = useState(void 0);
1484
1486
  const { url: coverUrl } = settings.cover;
1485
- return /* @__PURE__ */ jsxs("div", { children: [
1487
+ useEffect(() => {
1488
+ if (!wrapperRef) return;
1489
+ const observer = new ResizeObserver((entries) => {
1490
+ if (!wrapperRef) return;
1491
+ const [wrapper2] = entries;
1492
+ setCoverDimensions({
1493
+ width: Math.round(wrapper2.contentRect.width),
1494
+ height: Math.round(wrapper2.contentRect.height)
1495
+ });
1496
+ });
1497
+ observer.observe(wrapperRef);
1498
+ return () => observer.unobserve(wrapperRef);
1499
+ }, [wrapperRef]);
1500
+ return /* @__PURE__ */ jsxs("div", { ref: setWrapperRef, children: [
1486
1501
  /* @__PURE__ */ jsx(
1487
1502
  "img",
1488
1503
  {
1489
1504
  src: coverUrl,
1490
1505
  alt: "Cover",
1491
- style: { width: "100%", height: "100%", cursor: "pointer" },
1506
+ style: { width: (coverDimensions == null ? void 0 : coverDimensions.width) ? coverDimensions.width : "100%", height: (coverDimensions == null ? void 0 : coverDimensions.height) ? coverDimensions.height : "100%", cursor: "pointer" },
1492
1507
  onClick: () => setOpen(true)
1493
1508
  }
1494
1509
  ),
@@ -1694,7 +1709,7 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1694
1709
  )
1695
1710
  ] }),
1696
1711
  settings.area.closeIconUrl && /* @__PURE__ */ jsx("button", { className: styles.closeButton, style: { top: settings.area.closeIconOffset.y, left: settings.area.closeIconOffset.x }, onClick: onClose, children: /* @__PURE__ */ jsx(SvgImage, { url: settings.area.closeIconUrl, fill: settings.area.color }) }),
1697
- settings.caption.isActive && /* @__PURE__ */ jsx("div", { className: styles.caption, style: { top: settings.caption.offset.y, left: settings.caption.offset.x, color: settings.caption.color }, children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption }) }),
1712
+ settings.caption.isActive && /* @__PURE__ */ jsx("div", { className: styles.caption, style: { top: settings.caption.offset.y, left: settings.caption.offset.x }, children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption }) }),
1698
1713
  settings.thumbnail.isActive && /* @__PURE__ */ jsx(
1699
1714
  "div",
1700
1715
  {
@@ -1765,7 +1780,7 @@ const LightboxComponent = {
1765
1780
  properties: {
1766
1781
  cover: {
1767
1782
  title: "COVER",
1768
- icon: "image",
1783
+ icon: "cover",
1769
1784
  tooltip: "Cover Image",
1770
1785
  type: "object",
1771
1786
  properties: {
@@ -1872,7 +1887,7 @@ const LightboxComponent = {
1872
1887
  },
1873
1888
  thumbnail: {
1874
1889
  title: "THUMB",
1875
- icon: "pagination",
1890
+ icon: "thumbnail",
1876
1891
  tooltip: "Thumbnail",
1877
1892
  type: "object",
1878
1893
  properties: {
@@ -1900,7 +1915,7 @@ const LightboxComponent = {
1900
1915
  type: "string",
1901
1916
  title: "Align",
1902
1917
  display: {
1903
- type: "ratio-group"
1918
+ type: "align-grid"
1904
1919
  },
1905
1920
  enum: ["top", "center", "bottom"]
1906
1921
  },
@@ -2103,7 +2118,7 @@ const LightboxComponent = {
2103
2118
  },
2104
2119
  area: {
2105
2120
  title: "AREA",
2106
- icon: "background",
2121
+ icon: "area",
2107
2122
  tooltip: "Area",
2108
2123
  type: "object",
2109
2124
  properties: {
@@ -2179,14 +2194,6 @@ const LightboxComponent = {
2179
2194
  }
2180
2195
  }
2181
2196
  },
2182
- color: {
2183
- title: "Color",
2184
- type: "string",
2185
- display: {
2186
- type: "settings-color-picker",
2187
- format: "single"
2188
- }
2189
- },
2190
2197
  hover: {
2191
2198
  title: "Hover",
2192
2199
  type: "string",
@@ -2257,7 +2264,6 @@ const LightboxComponent = {
2257
2264
  caption: {
2258
2265
  alignment: "middle-center",
2259
2266
  offset: { x: 0, y: 0 },
2260
- color: "#000000",
2261
2267
  hover: "#cccccc"
2262
2268
  }
2263
2269
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "0.1.0-3",
3
+ "version": "0.1.0-5",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",