@meduza/ui-kit-2 0.1.15 → 0.1.17

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.
@@ -611,7 +611,7 @@ var Footnote = function Footnote(_ref) {
611
611
  }, children));
612
612
  };
613
613
 
614
- var styles$7 = {"root":"DotsOnImage-module_root__2XP3Q","isVisible":"DotsOnImage-module_isVisible__Wqqqt","dot":"DotsOnImage-module_dot__H1wua","show":"DotsOnImage-module_show__2TMBv","isActive":"DotsOnImage-module_isActive__3hh31","popover":"DotsOnImage-module_popover__35Cpj","isRight":"DotsOnImage-module_isRight__2RsJe","isTop":"DotsOnImage-module_isTop__3zmSK","isLeft":"DotsOnImage-module_isLeft__3quc9","isBottom":"DotsOnImage-module_isBottom__3Nk1T"};
614
+ var styles$7 = {"root":"DotsOnImage-module_root__2XP3Q","isVisible":"DotsOnImage-module_isVisible__Wqqqt","marker":"DotsOnImage-module_marker__lH5cP","show":"DotsOnImage-module_show__2TMBv","dot":"DotsOnImage-module_dot__H1wua","isActive":"DotsOnImage-module_isActive__3hh31","popover":"DotsOnImage-module_popover__35Cpj","isRight":"DotsOnImage-module_isRight__2RsJe","isTop":"DotsOnImage-module_isTop__3zmSK","isLeft":"DotsOnImage-module_isLeft__3quc9","isBottom":"DotsOnImage-module_isBottom__3Nk1T"};
615
615
 
616
616
  var DotsOnImage = function DotsOnImage(_ref) {
617
617
  var _ref$block = _ref.block,
@@ -622,6 +622,10 @@ var DotsOnImage = function DotsOnImage(_ref) {
622
622
  display = _ref$block.display,
623
623
  dots = _ref$block.dots;
624
624
 
625
+ var _useState = React.useState(1),
626
+ ratio = _useState[0],
627
+ setRatio = _useState[1];
628
+
625
629
  var _useInView = reactIntersectionObserver.useInView({
626
630
  threshold: 0.5
627
631
  }),
@@ -631,19 +635,20 @@ var DotsOnImage = function DotsOnImage(_ref) {
631
635
 
632
636
  var container = React.useRef(null);
633
637
 
634
- var _useState = React.useState({
638
+ var _useState2 = React.useState({
635
639
  title: null,
636
640
  body: null,
637
641
  show: false,
638
642
  id: null
639
643
  }),
640
- popover = _useState[0],
641
- setPopover = _useState[1];
644
+ popover = _useState2[0],
645
+ setPopover = _useState2[1];
642
646
 
643
- var _useState2 = React.useState(false),
644
- visible = _useState2[0],
645
- setVisible = _useState2[1];
647
+ var _useState3 = React.useState(false),
648
+ visible = _useState3[0],
649
+ setVisible = _useState3[1];
646
650
 
651
+ var defaultWidth = 375;
647
652
  React.useEffect(function () {
648
653
  if (entry && entry.boundingClientRect && entry.boundingClientRect.y < 0) {
649
654
  setVisible(true);
@@ -665,6 +670,25 @@ var DotsOnImage = function DotsOnImage(_ref) {
665
670
  return document.removeEventListener('click', handleClickOutside);
666
671
  };
667
672
  }, [popover]);
673
+ React.useEffect(function () {
674
+ setDotSize();
675
+ window.addEventListener('resize', setDotSize);
676
+ return function () {
677
+ return document.removeEventListener('resize', setDotSize);
678
+ };
679
+ }, [visible]);
680
+
681
+ var setDotSize = function setDotSize() {
682
+ var width = window.innerWidth;
683
+
684
+ if (width < defaultWidth) {
685
+ var _ratio = width / defaultWidth;
686
+
687
+ setRatio(_ratio);
688
+ } else {
689
+ setRatio(1);
690
+ }
691
+ };
668
692
 
669
693
  var handleClickOutside = function handleClickOutside(event) {
670
694
  var path = event.composedPath();
@@ -712,13 +736,18 @@ var DotsOnImage = function DotsOnImage(_ref) {
712
736
  }), React__default.createElement("div", {
713
737
  ref: container
714
738
  }, dots.map(function (dot) {
715
- return React__default.createElement("button", {
716
- className: makeClassName([[styles$7.dot, true], [styles$7.isActive, dot.id === popover.id]]),
717
- type: "button",
739
+ return React__default.createElement("div", {
740
+ className: styles$7.dot,
718
741
  key: dot.id,
719
742
  style: {
720
743
  top: dot.position.y + "%",
721
744
  left: dot.position.x + "%",
745
+ transform: "scale(" + ratio + ") translate(-" + 50 / ratio + "%, -" + 50 / ratio + "%)"
746
+ }
747
+ }, React__default.createElement("button", {
748
+ className: makeClassName([[styles$7.marker, true], [styles$7.isActive, dot.id === popover.id]]),
749
+ type: "button",
750
+ style: {
722
751
  backgroundColor: dot.icon.color
723
752
  },
724
753
  onClick: function onClick() {
@@ -728,7 +757,7 @@ var DotsOnImage = function DotsOnImage(_ref) {
728
757
  dangerouslySetInnerHTML: {
729
758
  __html: dot.icon.svg_string
730
759
  }
731
- }), dot.icon.type === 'number' && dot.icon.number);
760
+ }), dot.icon.type === 'number' && dot.icon.number));
732
761
  }), popover.show && React__default.createElement(React__default.Fragment, null, viewportSize().width >= MediaQuerySizes.LANDSCAPE_TABLET ? React__default.createElement("div", {
733
762
  className: makeClassName([[styles$7.popover, true], [styles$7[popover.side], !!popover.side], [styles$7[popover.align], !!popover.align]]),
734
763
  style: popover.style