@meduza/ui-kit-2 0.1.38 → 0.1.39

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.38",
2
+ "version": "0.1.39",
3
3
  "license": "MIT",
4
4
  "description": "UIKit for Meduza",
5
5
  "repository": "https://github.com/meduza-corp/ui-kit-2.git",
@@ -201,8 +201,8 @@
201
201
  }
202
202
  }
203
203
 
204
- .isInCard:not(.cc):last-child,
205
- .isInSlide:not(.cc):last-child {
204
+ .isInCard:not(.cc):last-child .figure,
205
+ .isInSlide:not(.cc):last-child .figure {
206
206
  overflow: hidden;
207
207
 
208
208
  margin-bottom: -16px;
@@ -214,6 +214,15 @@
214
214
  }
215
215
  }
216
216
 
217
+ .isInCard.isInSensitiveBlock:not(.cc) .figure,
218
+ .isInSlide.isInSensitiveBlock:not(.cc) .figure {
219
+ overflow: visible;
220
+
221
+ margin-bottom: 0;
222
+
223
+ border-radius: 0;
224
+ }
225
+
217
226
  .isInAnswer {
218
227
  margin-top: 12px;
219
228
  margin-bottom: 12px;
@@ -246,7 +255,6 @@
246
255
  position: static;
247
256
  }
248
257
 
249
-
250
258
  /* DEVICES */
251
259
  .mobile {
252
260
  @media $mobile {
@@ -268,7 +276,6 @@
268
276
  }
269
277
  }
270
278
 
271
-
272
279
  /* XS */
273
280
  .xs {
274
281
  @media $contentWidth {
@@ -6,13 +6,15 @@
6
6
 
7
7
  display: block;
8
8
  overflow: hidden;
9
+ transition: background-color 250ms ease;
10
+
11
+ background-color: #f2f2f2;
9
12
 
10
13
  @media $mobile {
11
14
  border-radius: inherit;
12
15
  }
13
16
  }
14
17
 
15
- .placeholder,
16
18
  .root img {
17
19
  position: absolute;
18
20
  top: 0;
@@ -22,6 +24,10 @@
22
24
  height: 100%;
23
25
  }
24
26
 
27
+ .isLoaded {
28
+ background-color: transparent
29
+ }
30
+
25
31
  .wrapper {
26
32
  display: block;
27
33
 
@@ -31,16 +37,6 @@
31
37
  background-size: 100% auto;
32
38
  }
33
39
 
34
- .placeholder {
35
- transition: background-color 250ms ease;
36
-
37
- background-color: #f2f2f2;
38
- }
39
-
40
- .loaded {
41
- background: transparent;
42
- }
43
-
44
40
  .fullscreen picture {
45
41
  cursor: pointer;
46
42
  }
@@ -35,4 +35,5 @@ export interface PictureProps {
35
35
  alt?: string
36
36
  fallbackSource: string
37
37
  display: string
38
+ onLoad: (boolean) => void
38
39
  }
@@ -8,7 +8,8 @@ export const RenderPicture: React.FC<PictureProps> = ({
8
8
  fallbackSource,
9
9
  optimized,
10
10
  alt,
11
- display
11
+ display,
12
+ onLoad
12
13
  }) => {
13
14
  const [fallback, setFallback] = useState(false)
14
15
 
@@ -61,6 +62,7 @@ export const RenderPicture: React.FC<PictureProps> = ({
61
62
  : 'data:image/gif;base64,R0lGODlhAQABAPAAAPLy8gAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='
62
63
  }
63
64
  alt={alt}
65
+ onLoad={() => onLoad(true)}
64
66
  />
65
67
  </picture>
66
68
  )
@@ -1,4 +1,4 @@
1
- import React, { useContext } from 'react'
1
+ import React, { useContext, useState } from 'react'
2
2
  import { ImageProps } from './Image.types'
3
3
  import { makeClassName } from '../utils/makeClassName'
4
4
  import BlockContext from '../utils/BlockContext'
@@ -22,6 +22,7 @@ export const Image: React.FC<ImageProps> = ({
22
22
  ratio
23
23
  }) => {
24
24
  const { lightBox } = useContext(BlockContext)
25
+ const [isLoaded, setIsLoaded] = useState(false)
25
26
 
26
27
  const handleClick = (): void => {
27
28
  if (!fullscreen || !lightBox || (optimized && !optimized.original)) {
@@ -44,14 +45,14 @@ export const Image: React.FC<ImageProps> = ({
44
45
  lightBox.show(optimized, width, height, alt)
45
46
  }
46
47
 
47
- const pictureStyles = {
48
- paddingBottom: `${100 / (ratio || width / height)}%`
49
- }
50
-
51
48
  const blockStyles = {
52
49
  maxWidth: width <= 649 ? width : '100%'
53
50
  }
54
51
 
52
+ const pictureStyles = {
53
+ paddingBottom: `${100 / (ratio || width / height)}%`
54
+ }
55
+
55
56
  /* fallback w325 url until w6 was released */
56
57
  const fallbackSource =
57
58
  (source && source[0]) ||
@@ -62,6 +63,7 @@ export const Image: React.FC<ImageProps> = ({
62
63
  <div
63
64
  className={makeClassName([
64
65
  [styles.root, true],
66
+ [styles.isLoaded, !isLoaded],
65
67
  [styles.fullscreen, fullscreen && fullscreen.desktop]
66
68
  ])}
67
69
  style={blockStyles}
@@ -84,6 +86,7 @@ export const Image: React.FC<ImageProps> = ({
84
86
  optimized={optimized}
85
87
  alt={alt}
86
88
  display={display}
89
+ onLoad={setIsLoaded}
87
90
  />
88
91
  </Lazy>
89
92
  <noscript>
@@ -97,6 +100,7 @@ export const Image: React.FC<ImageProps> = ({
97
100
  optimized={optimized}
98
101
  alt={alt}
99
102
  display={display}
103
+ onLoad={setIsLoaded}
100
104
  />
101
105
  )}
102
106
  </div>
@@ -3,7 +3,3 @@
3
3
  .root {
4
4
  display: block;
5
5
  }
6
-
7
- .visible {
8
- color: red;
9
- }
@@ -13,6 +13,5 @@ export interface RelatedBlockProps {
13
13
  }
14
14
  only_on?: string
15
15
  }
16
- trackClick?: boolean
17
16
  styleContext?: string[] | string
18
17
  }
@@ -1,7 +1,6 @@
1
1
  import React from 'react'
2
2
  import { RelatedBlockProps } from './RelatedBlock.types'
3
3
  import { makeClassName, ClassNames } from '../utils/makeClassName'
4
- import postMessage from '../utils/postMessage'
5
4
 
6
5
  import makeStyleContext from '../utils/makeStyleContext'
7
6
 
@@ -12,7 +11,6 @@ export const RelatedBlock: React.FC<RelatedBlockProps> = ({
12
11
  data: { title, related },
13
12
  only_on: onlyOn
14
13
  },
15
- trackClick,
16
14
  styleContext
17
15
  }) => {
18
16
  let classNames: ClassNames = [
@@ -24,12 +22,6 @@ export const RelatedBlock: React.FC<RelatedBlockProps> = ({
24
22
  classNames = makeStyleContext(classNames, styleContext, styles)
25
23
  }
26
24
 
27
- const handleClick = (url) => {
28
- if (trackClick) {
29
- postMessage('simpleRelated', url, 'click')
30
- }
31
- }
32
-
33
25
  return (
34
26
  <div data-testid="related-block" className={makeClassName(classNames)}>
35
27
  <h3 className={styles.header}>{title}</h3>
@@ -40,7 +32,6 @@ export const RelatedBlock: React.FC<RelatedBlockProps> = ({
40
32
  href={item.full_url || `/${item.url}`}
41
33
  target="_blank"
42
34
  rel="noopener noreferrer"
43
- onClick={(): void => handleClick(item.full_url || item.url)}
44
35
  >
45
36
  <span className={styles.first}>{item.title}</span>
46
37
  {item.second_title && ' '}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/jsx-no-target-blank */
2
- import React, { useState, useEffect } from 'react'
2
+ import React, { useEffect } from 'react'
3
3
  import { useInView } from 'react-intersection-observer'
4
4
  import { RelatedRichBlockProps } from './RelatedRichBlock.types'
5
5
 
@@ -15,14 +15,11 @@ import { Image } from '../Image'
15
15
 
16
16
  import styles from './RelatedRichBlock.module.css'
17
17
 
18
- import { RelatedBlock } from '../RelatedBlock'
19
-
20
18
  export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
21
19
  block: {
22
20
  only_on: onlyOn,
23
21
  data: {
24
22
  blocks,
25
- fallback,
26
23
  url,
27
24
  cover: { urls, gradients, tag, layout, ratio }
28
25
  }
@@ -32,14 +29,8 @@ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
32
29
  const style: React.CSSProperties = {}
33
30
  const styleHeader: React.CSSProperties = {}
34
31
 
35
- const [type, setType] = useState('unset')
36
-
37
32
  const cardType = `is${toCapitalize(layout)}`
38
33
 
39
- useEffect(() => {
40
- setType(Math.random() >= 0.5 ? 'simpleRelated' : 'richRelated')
41
- }, [])
42
-
43
34
  const [ref, inView] = useInView({
44
35
  threshold: 0,
45
36
  triggerOnce: true
@@ -52,13 +43,13 @@ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
52
43
  (onlyOn === 'desktop' && window.innerWidth >= 512) ||
53
44
  !onlyOn
54
45
  ) {
55
- postMessage(type, url, 'view')
46
+ postMessage('richRelated', url, 'view')
56
47
  }
57
48
  }
58
49
  }, [inView])
59
50
 
60
51
  const handleClick = () => {
61
- postMessage(type, url, 'click')
52
+ postMessage('richRelated', url, 'click')
62
53
  }
63
54
 
64
55
  let classNames: ClassNames = [
@@ -93,22 +84,6 @@ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
93
84
  }
94
85
  }
95
86
 
96
- if (type === 'unset') {
97
- return <div className={styles.wrapper} />
98
- }
99
-
100
- if (type === 'simpleRelated') {
101
- return (
102
- <div ref={ref} className={styles.wrapper}>
103
- <RelatedBlock
104
- block={fallback}
105
- trackClick={true}
106
- styleContext={styleContext}
107
- />
108
- </div>
109
- )
110
- }
111
-
112
87
  return (
113
88
  <a
114
89
  data-testid="related-rich-block"
@@ -29,8 +29,10 @@
29
29
 
30
30
  .container {
31
31
  position: relative;
32
- transition: min-height 350ms ease;
32
+
33
33
  min-height: 170px;
34
+
35
+ transition: min-height 350ms ease;
34
36
  }
35
37
 
36
38
  .overlay {
@@ -75,12 +77,19 @@
75
77
  width: 100%;
76
78
  max-width: 368px;
77
79
  margin-top: 0;
78
- margin-bottom: 24px;
80
+ margin-bottom: 12px;
79
81
 
80
82
  text-align: center;
81
83
 
82
- font-size: 16px;
83
- line-height: 22px;
84
+ font-size: 14px;
85
+ line-height: 18px;
86
+
87
+ @media $mobile {
88
+ margin-bottom: 24px;
89
+
90
+ font-size: 16px;
91
+ line-height: 22px;
92
+ }
84
93
  }
85
94
 
86
95
  .button {
@@ -107,13 +116,23 @@
107
116
  }
108
117
  }
109
118
 
110
- .full .container {
111
- margin-right: -20px;
112
- margin-left: -20px;
119
+ .full .overlay {
120
+ right: -20px;
121
+ left: -20px;
113
122
 
114
123
  @media $mobile {
115
- margin-right: 0;
116
- margin-left: 0;
124
+ right: 0;
125
+ left: 0;
126
+ }
127
+ }
128
+
129
+ .full .media {
130
+ padding-right: 20px;
131
+ padding-left: 20px;
132
+
133
+ @media $mobile {
134
+ padding-right: 0;
135
+ padding-left: 0;
117
136
  }
118
137
  }
119
138
 
@@ -121,13 +140,19 @@
121
140
  max-width: 100%;
122
141
  }
123
142
 
124
- .super_full .container {
143
+ .super_full .overlay {
125
144
  @media $mobile {
126
- margin-right: -15px;
127
- margin-left: -15px;
145
+ right: -15px;
146
+ left: -15px;
128
147
  }
129
148
  }
130
149
 
150
+ .super_full .media {
151
+ @media $mobile {
152
+ padding-right: 15px;
153
+ padding-left: 15px;
154
+ }
155
+ }
131
156
 
132
157
  /* STATE */
133
158
  .visible .overlay {
@@ -141,3 +166,12 @@
141
166
  .visible .container {
142
167
  min-height: 0;
143
168
  }
169
+
170
+ /* CONTEXT */
171
+ .isInCard .overlay,
172
+ .isInSlide .overlay {
173
+ @media $landscapeTabletMax {
174
+ right: -11px;
175
+ left: -11px;
176
+ }
177
+ }
@@ -11,5 +11,5 @@ export interface SensitiveBlockProps {
11
11
  caption?: string
12
12
  cc: string
13
13
  }
14
- styleContext?: string[] | string
14
+ styleContext?: string[]
15
15
  }
@@ -1,6 +1,7 @@
1
1
  import React, { useState } from 'react'
2
2
  import { SensitiveBlockProps } from './SensitiveBlock.types'
3
- import makeClassName from '../utils/makeClassName'
3
+ import { makeClassName, ClassNames } from '../utils/makeClassName'
4
+ import makeStyleContext from '../utils/makeStyleContext'
4
5
 
5
6
  import { EmbedBlockContainer } from '../EmbedBlock'
6
7
  import { MediaCaption } from '../MediaCaption'
@@ -24,15 +25,21 @@ export const SensitiveBlock: React.FC<SensitiveBlockProps> = ({
24
25
  isVisible(true)
25
26
  }
26
27
 
28
+ let classNames: ClassNames = [
29
+ [styles.root, true],
30
+ [styles.visible, visible],
31
+ [styles[display], display && styles[display]]
32
+ ]
33
+
34
+ let context = ['isInSensitiveBlock']
35
+
36
+ if (styleContext) {
37
+ classNames = makeStyleContext(classNames, styleContext, styles)
38
+ context = [...styleContext, 'isInSensitiveBlock']
39
+ }
40
+
27
41
  return (
28
- <div
29
- data-testid="sensitive-block"
30
- className={makeClassName([
31
- [styles.root, true],
32
- [styles.visible, visible],
33
- [styles[display], display && styles[display]]
34
- ])}
35
- >
42
+ <div data-testid="sensitive-block" className={makeClassName(classNames)}>
36
43
  <div className={styles.container}>
37
44
  <div
38
45
  className={styles.overlay}
@@ -49,10 +56,7 @@ export const SensitiveBlock: React.FC<SensitiveBlockProps> = ({
49
56
  </div>
50
57
  </div>
51
58
  <div className={styles.media}>
52
- <EmbedBlockContainer
53
- block={block.item}
54
- styleContext={['isInSensitiveBlock']}
55
- />
59
+ <EmbedBlockContainer block={block.item} styleContext={context} />
56
60
  </div>
57
61
  </div>
58
62