@meduza/ui-kit-2 1.3.1 → 1.4.1

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,59 +1,31 @@
1
- /* eslint-disable react/jsx-no-target-blank */
2
- import React, { useEffect } from 'react'
1
+ import React from 'react'
3
2
  import { Link } from 'react-router-dom'
4
3
 
5
- import { useInView } from 'react-intersection-observer'
6
4
  import { RelatedRichBlockProps } from './RelatedRichBlock.types'
7
5
 
8
- import postMessage from '../utils/postMessage'
9
6
  import { makeClassName, ClassNames } from '../utils/makeClassName'
10
7
  import makeStyleContext from '../utils/makeStyleContext'
11
- import generateGradient from '../utils/generateGradient'
12
8
  import { toCapitalize } from '../utils/converCase'
13
9
 
14
10
  import { Tag } from '../Tag'
15
- import { RenderBlocks } from '../RenderBlocks'
16
11
  import { Image } from '../Image'
17
12
 
18
13
  import styles from './RelatedRichBlock.module.css'
14
+ import { RenderBlocks } from '../RenderBlocks'
19
15
 
20
16
  export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
21
17
  block: {
22
18
  only_on: onlyOn,
23
19
  data: {
24
- blocks,
25
20
  url,
21
+ blocks,
26
22
  cover: { urls, gradients, tag, layout, ratio }
27
23
  }
28
24
  },
29
25
  styleContext
30
26
  }) => {
31
- const style: React.CSSProperties = {}
32
- const styleHeader: React.CSSProperties = {}
33
-
34
27
  const cardType = `is${toCapitalize(layout)}`
35
28
 
36
- const [ref, inView] = useInView({
37
- threshold: 0,
38
- triggerOnce: true
39
- })
40
-
41
- useEffect(() => {
42
- if (inView) {
43
- if (
44
- (onlyOn === 'mobile' && window.innerWidth <= 511) ||
45
- (onlyOn === 'desktop' && window.innerWidth >= 512) ||
46
- !onlyOn
47
- ) {
48
- postMessage('richRelated', url, 'view')
49
- }
50
- }
51
- }, [inView])
52
-
53
- const handleClick = () => {
54
- postMessage('richRelated', url, 'click')
55
- }
56
-
57
29
  let classNames: ClassNames = [
58
30
  [styles.root, true],
59
31
  [styles[cardType], !!layout && !!styles[cardType]],
@@ -69,52 +41,27 @@ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
69
41
  context = [...styleContext, 'isInMediaBlock']
70
42
  }
71
43
 
72
- if (gradients) {
73
- styleHeader.backgroundImage = generateGradient(
74
- gradients.bg_rgb,
75
- 'mediaBlockTop'
76
- )
77
-
78
- const theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light']
79
- classNames = makeStyleContext(classNames, theme, styles)
80
-
81
- if (onlyOn === 'desktop') {
82
- style.backgroundImage = generateGradient(
83
- gradients.bg_rgb,
84
- 'mediaBlockBottom'
85
- )
86
- }
87
- }
88
-
89
44
  return (
90
45
  <Link
91
46
  data-testid="related-rich-block"
92
47
  className={makeClassName(classNames)}
93
48
  to={`/${url}`}
94
- onClick={(): void => handleClick()}
95
- ref={ref}
96
49
  >
97
- {layout === 'rich' && (
98
- <>
99
- <div className={styles.overlay} style={style} />
100
- <div className={styles.overlayHeader} style={styleHeader} />
101
- </>
102
- )}
103
-
104
50
  <div className={styles.tag}>
105
51
  <Tag size="small" theme="inherit" styleContext="richRelated">
106
52
  {tag}
107
53
  </Tag>
108
54
  </div>
109
- <div className={styles.cover}>
110
- <div className={styles.picture}>
55
+
56
+ <div className={styles.content}>
57
+ <div className={styles.cover}>
111
58
  <Image optimized={urls} ratio={ratio} display="narrow" />
112
59
  </div>
113
- </div>
114
- <div className={styles.body}>
115
- {blocks.map((item) => (
116
- <RenderBlocks key={item.id} block={item} styleContext={context} />
117
- ))}
60
+ <div className={styles.body}>
61
+ {blocks.map((item) => (
62
+ <RenderBlocks key={item.id} block={item} styleContext={context} />
63
+ ))}
64
+ </div>
118
65
  </div>
119
66
  </Link>
120
67
  )
@@ -100,26 +100,22 @@
100
100
  text-align: left;
101
101
 
102
102
  @media $landscapeTablet {
103
- margin-bottom: 18px;
103
+ margin-bottom: 16px;
104
104
  }
105
105
  }
106
106
 
107
107
  .isInMediaBlock:not(.featured) {
108
- font-size: 19px;
109
- line-height: 23px;
110
-
111
- @media $landscapeTablet {
112
- font-size: 1.3rem;
113
- line-height: 1.6rem;
114
- }
108
+ font-size: 20px;
109
+ line-height: 130%;
115
110
  }
116
111
 
117
112
  .isInMediaBlock:not(.featured) span {
118
- font-size: 20px;
113
+ display: block;
119
114
 
120
- @media $landscapeTablet {
121
- font-size: 1.35rem;
122
- }
115
+ margin-top: 4px;
116
+
117
+ font-size: 18px;
118
+ line-height: 132%;
123
119
  }
124
120
 
125
121
  .isInBookRelated {
@@ -91,7 +91,6 @@
91
91
  line-height: 17px;
92
92
 
93
93
  @media $landscapeTablet {
94
- font-size: 14px;
95
94
  line-height: 20px;
96
95
  }
97
96
  }
package/src/index.tsx CHANGED
@@ -27,6 +27,7 @@ export * from './ImportantLead'
27
27
  export * from './ListBlock'
28
28
  export * from './ListViewSwitcher'
29
29
  export * from './RelatedBlock'
30
+ export * from './RelatedCarousel'
30
31
  export * from './RichTitle'
31
32
  export * from './SimpleBlock'
32
33
  export * from './SimpleTitle'