@meduza/ui-kit-2 0.1.98 → 0.2.0

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.
@@ -2517,6 +2517,99 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
2517
2517
  })));
2518
2518
  };
2519
2519
 
2520
+ var styles$C = {"root":"ShopRelatedBlock-module_root__x4vdk","wrapper":"ShopRelatedBlock-module_wrapper__3jQp9","overlay":"ShopRelatedBlock-module_overlay__15S5a","overlayHeader":"ShopRelatedBlock-module_overlayHeader__2IXK-","body":"ShopRelatedBlock-module_body__3ipYj","hasGradient":"ShopRelatedBlock-module_hasGradient__1pghj","picture":"ShopRelatedBlock-module_picture__1bu9H","tag":"ShopRelatedBlock-module_tag__2vTKm","center":"ShopRelatedBlock-module_center__2H85-","title":"ShopRelatedBlock-module_title__1ZIW0","price":"ShopRelatedBlock-module_price__2cVXM","dark":"ShopRelatedBlock-module_dark__3Gfbc","light":"ShopRelatedBlock-module_light__1y8Qy","mobile":"ShopRelatedBlock-module_mobile__AleU0","desktop":"ShopRelatedBlock-module_desktop__2--zA"};
2521
+
2522
+ /* eslint-disable react/jsx-no-target-blank */
2523
+ var ShopRelatedBlock = function ShopRelatedBlock(_ref) {
2524
+ var _ref$block = _ref.block,
2525
+ onlyOn = _ref$block.only_on,
2526
+ _ref$block$data = _ref$block.data,
2527
+ url = _ref$block$data.url,
2528
+ _ref$block$data$cover = _ref$block$data.cover,
2529
+ urls = _ref$block$data$cover.urls,
2530
+ gradients = _ref$block$data$cover.gradients,
2531
+ tag = _ref$block$data$cover.tag,
2532
+ layout = _ref$block$data$cover.layout,
2533
+ ratio = _ref$block$data$cover.ratio,
2534
+ firstTitle = _ref$block$data$cover.first_title,
2535
+ secondTitle = _ref$block$data$cover.second_title,
2536
+ styleContext = _ref.styleContext;
2537
+ var style = {};
2538
+ var styleHeader = {};
2539
+
2540
+ var _useInView = reactIntersectionObserver.useInView({
2541
+ threshold: 0,
2542
+ triggerOnce: true
2543
+ }),
2544
+ ref = _useInView[0],
2545
+ inView = _useInView[1];
2546
+
2547
+ React.useEffect(function () {
2548
+ if (inView) {
2549
+ if (onlyOn === 'mobile' && window.innerWidth <= 511 || onlyOn === 'desktop' && window.innerWidth >= 512 || !onlyOn) {
2550
+ postMessage('productRelated', url, 'view');
2551
+ }
2552
+ }
2553
+ }, [inView]);
2554
+
2555
+ var handleClick = function handleClick() {
2556
+ postMessage('productRelated', url, 'click');
2557
+ };
2558
+
2559
+ var classNames = [[styles$C.root, true], [styles$C.hasGradient, !!gradients], [styles$C[onlyOn], !!onlyOn && !!styles$C[onlyOn]]];
2560
+
2561
+ if (styleContext) {
2562
+ classNames = makeStyleContext(classNames, styleContext, styles$C);
2563
+ }
2564
+
2565
+ if (gradients) {
2566
+ styleHeader.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockTop');
2567
+ var theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light'];
2568
+ classNames = makeStyleContext(classNames, theme, styles$C);
2569
+
2570
+ if (onlyOn === 'desktop') {
2571
+ style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
2572
+ }
2573
+ }
2574
+
2575
+ return React__default.createElement("a", {
2576
+ "data-testid": "related-rich-block",
2577
+ className: makeClassName(classNames),
2578
+ href: url,
2579
+ target: "_blank",
2580
+ onClick: function onClick() {
2581
+ return handleClick();
2582
+ },
2583
+ ref: ref
2584
+ }, layout === 'rich' && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
2585
+ className: styles$C.overlay,
2586
+ style: style
2587
+ }), React__default.createElement("div", {
2588
+ className: styles$C.overlayHeader,
2589
+ style: styleHeader
2590
+ })), React__default.createElement("div", {
2591
+ className: styles$C.tag
2592
+ }, React__default.createElement(Tag, {
2593
+ size: "small",
2594
+ theme: "inherit",
2595
+ styleContext: "richRelated"
2596
+ }, tag)), React__default.createElement("div", {
2597
+ className: styles$C.cover
2598
+ }, React__default.createElement("div", {
2599
+ className: styles$C.picture
2600
+ }, React__default.createElement(Image, {
2601
+ optimized: urls,
2602
+ ratio: ratio,
2603
+ display: "narrow"
2604
+ }))), React__default.createElement("div", {
2605
+ className: styles$C.body
2606
+ }, React__default.createElement("h2", {
2607
+ className: styles$C.title
2608
+ }, firstTitle, React__default.createElement("span", {
2609
+ className: styles$C.price
2610
+ }, secondTitle))));
2611
+ };
2612
+
2520
2613
  var RawHtmlBlock = function RawHtmlBlock(_ref) {
2521
2614
  var block = _ref.block,
2522
2615
  styleContext = _ref.styleContext,
@@ -2573,6 +2666,14 @@ var RawHtmlBlock = function RawHtmlBlock(_ref) {
2573
2666
  });
2574
2667
  }
2575
2668
 
2669
+ case 'related_shop':
2670
+ {
2671
+ return React__default.createElement(ShopRelatedBlock, {
2672
+ block: block,
2673
+ styleContext: styleContext
2674
+ });
2675
+ }
2676
+
2576
2677
  default:
2577
2678
  {
2578
2679
  return React__default.createElement(BlockProvider, {
@@ -2590,7 +2691,7 @@ var RawHtmlBlock = function RawHtmlBlock(_ref) {
2590
2691
  }
2591
2692
  };
2592
2693
 
2593
- var styles$C = {"root":"ToolbarButton-module_root__xN-fq","isDark":"ToolbarButton-module_isDark__2q5U7","dark":"ToolbarButton-module_dark__GrIOr","bookmark":"ToolbarButton-module_bookmark__3369b","isActive":"ToolbarButton-module_isActive__3NLAE","text":"ToolbarButton-module_text__32m6s"};
2694
+ var styles$D = {"root":"ToolbarButton-module_root__xN-fq","isDark":"ToolbarButton-module_isDark__2q5U7","dark":"ToolbarButton-module_dark__GrIOr","bookmark":"ToolbarButton-module_bookmark__3369b","isActive":"ToolbarButton-module_isActive__3NLAE","text":"ToolbarButton-module_text__32m6s"};
2594
2695
 
2595
2696
  var ToolbarButton = function ToolbarButton(_ref) {
2596
2697
  var children = _ref.children,
@@ -2598,7 +2699,7 @@ var ToolbarButton = function ToolbarButton(_ref) {
2598
2699
  theme = _ref.theme,
2599
2700
  isActive = _ref.isActive,
2600
2701
  _onClick = _ref.onClick;
2601
- var classNames = [[styles$C.root, true], [styles$C[type], !!styles$C[type]], [styles$C[theme], !!styles$C[theme] && !!theme], [styles$C.isActive, !!isActive]];
2702
+ var classNames = [[styles$D.root, true], [styles$D[type], !!styles$D[type]], [styles$D[theme], !!styles$D[theme] && !!theme], [styles$D.isActive, !!isActive]];
2602
2703
  return React__default.createElement("li", {
2603
2704
  className: toolbarStyles.item
2604
2705
  }, React__default.createElement("button", {
@@ -2613,103 +2714,10 @@ var ToolbarButton = function ToolbarButton(_ref) {
2613
2714
  icon: type,
2614
2715
  styleContext: "isInToolbar"
2615
2716
  }), children && React__default.createElement("span", {
2616
- className: styles$C.text
2717
+ className: styles$D.text
2617
2718
  }, children)));
2618
2719
  };
2619
2720
 
2620
- var styles$D = {"root":"ShopRelatedBlock-module_root__x4vdk","wrapper":"ShopRelatedBlock-module_wrapper__3jQp9","overlay":"ShopRelatedBlock-module_overlay__15S5a","overlayHeader":"ShopRelatedBlock-module_overlayHeader__2IXK-","body":"ShopRelatedBlock-module_body__3ipYj","hasGradient":"ShopRelatedBlock-module_hasGradient__1pghj","picture":"ShopRelatedBlock-module_picture__1bu9H","tag":"ShopRelatedBlock-module_tag__2vTKm","center":"ShopRelatedBlock-module_center__2H85-","title":"ShopRelatedBlock-module_title__1ZIW0","price":"ShopRelatedBlock-module_price__2cVXM","dark":"ShopRelatedBlock-module_dark__3Gfbc","light":"ShopRelatedBlock-module_light__1y8Qy","mobile":"ShopRelatedBlock-module_mobile__AleU0","desktop":"ShopRelatedBlock-module_desktop__2--zA"};
2621
-
2622
- /* eslint-disable react/jsx-no-target-blank */
2623
- var ShopRelatedBlock = function ShopRelatedBlock(_ref) {
2624
- var _ref$block = _ref.block,
2625
- onlyOn = _ref$block.only_on,
2626
- _ref$block$data = _ref$block.data,
2627
- url = _ref$block$data.url,
2628
- _ref$block$data$cover = _ref$block$data.cover,
2629
- urls = _ref$block$data$cover.urls,
2630
- gradients = _ref$block$data$cover.gradients,
2631
- tag = _ref$block$data$cover.tag,
2632
- layout = _ref$block$data$cover.layout,
2633
- ratio = _ref$block$data$cover.ratio,
2634
- firstTitle = _ref$block$data$cover.first_title,
2635
- secondTitle = _ref$block$data$cover.second_title,
2636
- styleContext = _ref.styleContext;
2637
- var style = {};
2638
- var styleHeader = {};
2639
-
2640
- var _useInView = reactIntersectionObserver.useInView({
2641
- threshold: 0,
2642
- triggerOnce: true
2643
- }),
2644
- ref = _useInView[0],
2645
- inView = _useInView[1];
2646
-
2647
- React.useEffect(function () {
2648
- if (inView) {
2649
- if (onlyOn === 'mobile' && window.innerWidth <= 511 || onlyOn === 'desktop' && window.innerWidth >= 512 || !onlyOn) {
2650
- postMessage('richRelated', url, 'view');
2651
- }
2652
- }
2653
- }, [inView]);
2654
-
2655
- var handleClick = function handleClick() {
2656
- postMessage('richRelated', url, 'click');
2657
- };
2658
-
2659
- var classNames = [[styles$D.root, true], [styles$D.hasGradient, !!gradients], [styles$D[onlyOn], !!onlyOn && !!styles$D[onlyOn]]];
2660
-
2661
- if (styleContext) {
2662
- classNames = makeStyleContext(classNames, styleContext, styles$D);
2663
- }
2664
-
2665
- if (gradients) {
2666
- styleHeader.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockTop');
2667
- var theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light'];
2668
- classNames = makeStyleContext(classNames, theme, styles$D);
2669
-
2670
- if (onlyOn === 'desktop') {
2671
- style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
2672
- }
2673
- }
2674
-
2675
- return React__default.createElement("a", {
2676
- "data-testid": "related-rich-block",
2677
- className: makeClassName(classNames),
2678
- href: url,
2679
- target: "_blank",
2680
- onClick: function onClick() {
2681
- return handleClick();
2682
- },
2683
- ref: ref
2684
- }, layout === 'rich' && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
2685
- className: styles$D.overlay,
2686
- style: style
2687
- }), React__default.createElement("div", {
2688
- className: styles$D.overlayHeader,
2689
- style: styleHeader
2690
- })), React__default.createElement("div", {
2691
- className: styles$D.tag
2692
- }, React__default.createElement(Tag, {
2693
- size: "small",
2694
- theme: "inherit",
2695
- styleContext: "richRelated"
2696
- }, tag)), React__default.createElement("div", {
2697
- className: styles$D.cover
2698
- }, React__default.createElement("div", {
2699
- className: styles$D.picture
2700
- }, React__default.createElement(Image, {
2701
- optimized: urls,
2702
- ratio: ratio,
2703
- display: "narrow"
2704
- }))), React__default.createElement("div", {
2705
- className: styles$D.body
2706
- }, React__default.createElement("h2", {
2707
- className: styles$D.title
2708
- }, firstTitle, React__default.createElement("span", {
2709
- className: styles$D.price
2710
- }, secondTitle))));
2711
- };
2712
-
2713
2721
  exports.BookmarkButton = BookmarkButton;
2714
2722
  exports.Button = Button;
2715
2723
  exports.CardTitle = CardTitle;