@meduza/ui-kit-2 0.1.10 → 0.1.11

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.
@@ -1,8 +1,12 @@
1
+ /// <reference types="react" />
1
2
  import { OptimizedImageItem } from '../Image/Image.types';
2
3
  export interface PopoverData {
3
4
  title?: string;
4
5
  body?: string;
5
6
  id?: string;
7
+ align?: 'isTop' | 'isBottom';
8
+ side?: 'isLeft' | 'isRight';
9
+ style?: React.CSSProperties;
6
10
  show: boolean;
7
11
  }
8
12
  export interface SingleDot {
@@ -19,7 +19,10 @@ export interface ImageProps {
19
19
  height?: number;
20
20
  source?: string[];
21
21
  lazy?: boolean;
22
- fullscreen?: boolean;
22
+ fullscreen?: {
23
+ mobile: boolean;
24
+ desktop: boolean;
25
+ };
23
26
  ratio?: number;
24
27
  }
25
28
  export interface PictureProps {
@@ -440,10 +440,17 @@ var Image = function Image(_ref) {
440
440
  lightBox = _useContext.lightBox;
441
441
 
442
442
  var handleClick = function handleClick() {
443
+ if (!fullscreen || !lightBox || optimized && !optimized.original) {
444
+ return;
445
+ }
446
+
443
447
  var _viewportSize = viewportSize(),
444
448
  viewportWidth = _viewportSize.width;
445
449
 
446
- if (optimized && !optimized.original || !lightBox || viewportWidth >= MediaQuerySizes.LANDSCAPE_TABLET && !fullscreen) {
450
+ var disableFullscreenDesktop = viewportWidth >= MediaQuerySizes.LANDSCAPE_TABLET && !fullscreen.desktop;
451
+ var disableFullscreenMobile = viewportWidth < MediaQuerySizes.LANDSCAPE_TABLET && !fullscreen.mobile;
452
+
453
+ if (disableFullscreenDesktop || disableFullscreenMobile) {
447
454
  return;
448
455
  }
449
456
 
@@ -461,7 +468,7 @@ var Image = function Image(_ref) {
461
468
 
462
469
  var fallbackSource = source && source[0] || optimized.w325 && optimized.w325['1x'] || optimized.original;
463
470
  return React__default.createElement("div", {
464
- className: makeClassName([[styles$4.root, true], [styles$4.fullscreen, fullscreen]]),
471
+ className: makeClassName([[styles$4.root, true], [styles$4.fullscreen, fullscreen && fullscreen.desktop]]),
465
472
  style: blockStyles,
466
473
  "data-testid": "image"
467
474
  }, React__default.createElement("div", {
@@ -604,7 +611,7 @@ var Footnote = function Footnote(_ref) {
604
611
  }, children));
605
612
  };
606
613
 
607
- var styles$7 = {"root":"DotsOnImage-module_root__2XP3Q","dot":"DotsOnImage-module_dot__H1wua","popover":"DotsOnImage-module_popover__35Cpj","popoverTitle":"DotsOnImage-module_popoverTitle__343d8","popoverBody":"DotsOnImage-module_popoverBody__2MSn7","popoverText":"DotsOnImage-module_popoverText__3v02w","dismiss":"DotsOnImage-module_dismiss__1EWXd"};
614
+ var styles$7 = {"root":"DotsOnImage-module_root__2XP3Q","dot":"DotsOnImage-module_dot__H1wua","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","popoverTitle":"DotsOnImage-module_popoverTitle__343d8","popoverBody":"DotsOnImage-module_popoverBody__2MSn7","popoverText":"DotsOnImage-module_popoverText__3v02w","dismiss":"DotsOnImage-module_dismiss__1EWXd"};
608
615
 
609
616
  var DotsOnImage = function DotsOnImage(_ref) {
610
617
  var _ref$block = _ref.block,
@@ -626,11 +633,20 @@ var DotsOnImage = function DotsOnImage(_ref) {
626
633
 
627
634
  var handleDotClick = function handleDotClick(dot) {
628
635
  var shouldShow = dot.id !== popover.id;
636
+ var side = dot.position.x > 50 ? 'isLeft' : 'isRight';
637
+ var align = dot.position.y > 50 ? 'isBottom' : 'isTop';
638
+ var style = {
639
+ top: dot.position.y + "%",
640
+ left: dot.position.x + "%"
641
+ };
629
642
  setPopover({
630
643
  title: dot.title,
631
644
  body: dot.body,
632
645
  show: shouldShow,
633
- id: shouldShow ? dot.id : null
646
+ id: shouldShow ? dot.id : null,
647
+ style: style,
648
+ side: side,
649
+ align: align
634
650
  });
635
651
  };
636
652
 
@@ -653,7 +669,6 @@ var DotsOnImage = function DotsOnImage(_ref) {
653
669
  return handleDotClick(dot);
654
670
  }
655
671
  }, dot.icon.type === 'svg' && React__default.createElement("div", {
656
- className: styles$7.icon,
657
672
  dangerouslySetInnerHTML: {
658
673
  __html: dot.icon.svg_string
659
674
  }
@@ -665,9 +680,14 @@ var DotsOnImage = function DotsOnImage(_ref) {
665
680
  width: width,
666
681
  height: height,
667
682
  alt: credit,
668
- display: display
683
+ display: display,
684
+ fullscreen: {
685
+ mobile: false,
686
+ desktop: false
687
+ }
669
688
  })), popover.show && React__default.createElement(React__default.Fragment, null, viewportSize().width >= MediaQuerySizes.LANDSCAPE_TABLET ? React__default.createElement("div", {
670
- className: styles$7.popover
689
+ className: makeClassName([[styles$7.popover, true], [styles$7[popover.side], !!popover.side], [styles$7[popover.align], !!popover.align]]),
690
+ style: popover.style
671
691
  }, React__default.createElement(Footnote, {
672
692
  onClose: function onClose() {
673
693
  setPopover({
@@ -1163,7 +1183,10 @@ var EmbedBlock = function EmbedBlock(_ref) {
1163
1183
  return React__default.createElement("div", {
1164
1184
  className: styles$i.figure
1165
1185
  }, (small || optimized) && React__default.createElement(Image, {
1166
- fullscreen: block.data.fullscreen,
1186
+ fullscreen: {
1187
+ desktop: block.data.fullscreen,
1188
+ mobile: true
1189
+ },
1167
1190
  source: !optimized && [small, large],
1168
1191
  optimized: block.data.optimized,
1169
1192
  width: block.data.width,