@meduza/ui-kit-2 0.1.19 → 0.1.21

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.
Files changed (87) hide show
  1. package/dist/Cover/Cover.types.d.ts +21 -1
  2. package/dist/DotsOnImage/DotsOnImage.types.d.ts +1 -1
  3. package/dist/Image/Image.types.d.ts +1 -6
  4. package/dist/ListBlock/ListBlock.stories.d.ts +2 -1
  5. package/dist/ListBlock/ListBlock.types.d.ts +7 -1
  6. package/dist/RelatedBlock/RelatedBlock.types.d.ts +14 -1
  7. package/dist/RelatedRichBlock/RelatedRichBlock.stories.d.ts +10 -0
  8. package/dist/RelatedRichBlock/RelatedRichBlock.types.d.ts +4 -0
  9. package/dist/RelatedRichBlock/index.d.ts +3 -0
  10. package/dist/RichTitle/RichTitle.types.d.ts +8 -1
  11. package/dist/SimpleTitle/SimpleTitle.types.d.ts +6 -1
  12. package/dist/SourceBlock/SourceBlock.types.d.ts +12 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/types.d.ts +6 -0
  15. package/dist/ui-kit-2.cjs.development.js +147 -47
  16. package/dist/ui-kit-2.cjs.development.js.map +1 -1
  17. package/dist/ui-kit-2.cjs.production.min.js +1 -1
  18. package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
  19. package/dist/ui-kit-2.esm.js +147 -48
  20. package/dist/ui-kit-2.esm.js.map +1 -1
  21. package/dist/ui-kit.css +1157 -961
  22. package/dist/utils/converCase.d.ts +2 -0
  23. package/dist/utils/generateGradient.d.ts +1 -1
  24. package/package.json +4 -1
  25. package/src/.DS_Store +0 -0
  26. package/src/BookmarkButton/BookmarkButton.test.tsx +17 -4
  27. package/src/CardTitle/CardTitle.test.tsx +4 -3
  28. package/src/ChapterBlock/ChapterBlock.test.tsx +4 -3
  29. package/src/Cover/Cover.test.tsx +3 -3
  30. package/src/Cover/Cover.types.ts +22 -1
  31. package/src/Cover/index.tsx +1 -1
  32. package/src/DocumentItemsCount/DocumentItemsCount.test.tsx +4 -3
  33. package/src/DotsOnImage/DotsOnImage.test.tsx +4 -2
  34. package/src/DotsOnImage/DotsOnImage.types.ts +1 -1
  35. package/src/EmbedBlock/EmbedBlock.test.tsx +16 -3
  36. package/src/EmbedBlock/index.tsx +1 -1
  37. package/src/GroupedBlock/GroupedBlock.test.tsx +5 -3
  38. package/src/HalfBlock/HalfBlock.test.tsx +4 -3
  39. package/src/Image/Image.test.tsx +3 -0
  40. package/src/Image/Image.types.ts +1 -6
  41. package/src/Image/RenderPicture.tsx +1 -1
  42. package/src/ImportantLead/ImportantLead.test.tsx +10 -8
  43. package/src/ImportantLead/mock.json +6 -0
  44. package/src/Lazy/Lazy.test.tsx +3 -0
  45. package/src/ListBlock/ListBlock.stories.tsx +2 -1
  46. package/src/ListBlock/ListBlock.test.tsx +8 -4
  47. package/src/ListBlock/ListBlock.types.ts +6 -1
  48. package/src/ListBlock/index.tsx +1 -1
  49. package/src/ListBlock/mock.json +1 -1
  50. package/src/MaterialNote/MaterialNote.test.tsx +4 -3
  51. package/src/Meta/Meta.module.css +1 -1
  52. package/src/QuoteBlock/QuoteBlock.test.tsx +4 -3
  53. package/src/RawHtmlBlock/RawHtmlBlock.test.tsx +18 -9
  54. package/src/RawHtmlBlock/mock.json +6 -0
  55. package/src/RelatedBlock/RelatedBlock.test.tsx +4 -3
  56. package/src/RelatedBlock/RelatedBlock.types.ts +14 -1
  57. package/src/RelatedRichBlock/RelatedRichBlock.module.css +165 -0
  58. package/src/RelatedRichBlock/RelatedRichBlock.stories.module.css +12 -0
  59. package/src/RelatedRichBlock/RelatedRichBlock.stories.tsx +55 -0
  60. package/src/RelatedRichBlock/RelatedRichBlock.test.tsx +20 -0
  61. package/src/RelatedRichBlock/RelatedRichBlock.types.ts +4 -0
  62. package/src/RelatedRichBlock/index.tsx +105 -0
  63. package/src/RelatedRichBlock/mock.json +354 -0
  64. package/src/RenderBlocks/RenderBlocks.stories.module.css +3 -0
  65. package/src/RenderBlocks/RenderBlocks.stories.tsx +4 -1
  66. package/src/RenderBlocks/RenderBlocks.test.tsx +15 -9
  67. package/src/RenderBlocks/index.tsx +5 -0
  68. package/src/RenderBlocks/mock.json +83 -0
  69. package/src/RichTitle/RichTitle.module.css +37 -7
  70. package/src/RichTitle/RichTitle.test.tsx +4 -3
  71. package/src/RichTitle/RichTitle.types.ts +8 -1
  72. package/src/SimpleBlock/SimpleBlock.test.tsx +16 -9
  73. package/src/SimpleBlock/mock.json +6 -0
  74. package/src/SimpleTitle/SimpleTitle.test.tsx +4 -3
  75. package/src/SimpleTitle/SimpleTitle.types.ts +6 -1
  76. package/src/SourceBlock/SourceBlock.test.tsx +4 -3
  77. package/src/SourceBlock/SourceBlock.types.ts +13 -1
  78. package/src/Spoiler/Spoiler.test.tsx +4 -3
  79. package/src/Table/Table.test.tsx +3 -3
  80. package/src/Timestamp/Timestamp.test.tsx +4 -3
  81. package/src/ToolbarButton/ToolbarButton.test.tsx +8 -3
  82. package/src/_storybook/PreviewWrapper/PreviewWrapper.module.css +3 -1
  83. package/src/index.tsx +1 -0
  84. package/src/types.ts +6 -0
  85. package/src/utils/{toCamel.ts → converCase.ts} +3 -0
  86. package/src/utils/generateGradient.ts +21 -15
  87. package/dist/utils/toCamel.d.ts +0 -1
@@ -0,0 +1,165 @@
1
+ @import '../vars.css';
2
+
3
+ .root {
4
+ position: relative;
5
+ z-index: 10;
6
+
7
+ display: block;
8
+ overflow: hidden;
9
+
10
+ min-height: 434px;
11
+
12
+ text-decoration: none;
13
+
14
+ border-radius: 8px;
15
+ outline-width: 0;
16
+ }
17
+
18
+ .root::before,
19
+ .root::after {
20
+ position: absolute;
21
+ z-index: 20;
22
+ top: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ left: 0;
26
+
27
+ content: '';
28
+
29
+ border-radius: 8px;
30
+ }
31
+
32
+ .root::before {
33
+ border: 1px solid rgba(0, 0, 0, 0.1);
34
+ }
35
+
36
+ .root::after {
37
+ box-shadow: inset 0 4px #b88b59, inset 0 5px rgba(0, 0, 0, 0.2);
38
+ }
39
+
40
+ .overlay,
41
+ .overlayHeader {
42
+ position: absolute;
43
+ z-index: 10;
44
+ right: 0;
45
+ left: 0;
46
+ }
47
+
48
+ .overlay {
49
+ bottom: 0;
50
+
51
+ height: 295px;
52
+ }
53
+
54
+ .overlayHeader {
55
+ top: 0;
56
+
57
+ height: 150px;
58
+
59
+
60
+ }
61
+
62
+ .isRich .overlayHeader {
63
+ background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 97%);
64
+ }
65
+
66
+ .body {
67
+ display: flex;
68
+ flex-flow: column nowrap;
69
+ justify-content: flex-end;
70
+
71
+ padding: 15px;
72
+
73
+ background-color: #f7f7f7;
74
+
75
+ @media $mobile {
76
+ position: absolute;
77
+ z-index: 10;
78
+ right: 0;
79
+ bottom: 0;
80
+ left: 0;
81
+
82
+ min-height: 295px;
83
+ padding: 20px;
84
+
85
+ background-color: transparent;
86
+ }
87
+ }
88
+
89
+ .isCard .body,
90
+ .isRich.hasGradient .body {
91
+ position: absolute;
92
+ z-index: 10;
93
+ right: 0;
94
+ bottom: 0;
95
+ left: 0;
96
+
97
+ min-height: 295px;
98
+
99
+ background-color: transparent;
100
+ }
101
+
102
+ .isCard {
103
+ color: #fff;
104
+ background-color: #191919;
105
+ }
106
+
107
+ .isCard .cover {
108
+ position: absolute;
109
+ top: 17.2811059908%;
110
+ left: 50%;
111
+
112
+ width: 170px;
113
+
114
+ transform: translate(-50%, 0);
115
+ }
116
+
117
+ .isRich {
118
+ color: #000;
119
+
120
+ @media $landscapeTablet {
121
+ color: #fff;
122
+ }
123
+ }
124
+
125
+ .tag {
126
+ position: absolute;
127
+ z-index: 10;
128
+ top: 15px;
129
+ left: 15px;
130
+
131
+ color: #fff;
132
+
133
+ @media $mobile {
134
+ top: 20px;
135
+ left: 20px;
136
+ }
137
+ }
138
+
139
+ /* Themes */
140
+
141
+ .isRich.dark,
142
+ .isRich.dark .tag {
143
+ color: #000;
144
+ }
145
+
146
+ .isRich.light {
147
+ color: #fff;
148
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
149
+ }
150
+
151
+ /* Display */
152
+
153
+ .mobile {
154
+ @media $mobile {
155
+ display: none;
156
+ }
157
+ }
158
+
159
+ .desktop {
160
+ display: none;
161
+
162
+ @media $mobile {
163
+ display: block;
164
+ }
165
+ }
@@ -0,0 +1,12 @@
1
+ @import '../vars.css';
2
+
3
+ .root {
4
+ display: block;
5
+
6
+ max-width: 650px;
7
+ margin: 0 auto;
8
+ }
9
+
10
+ .card + .card {
11
+ margin-top: 40px;
12
+ }
@@ -0,0 +1,55 @@
1
+ import React from 'react'
2
+ import { RelatedRichBlock } from './'
3
+ import { PreviewWrapper } from '../_storybook/PreviewWrapper'
4
+
5
+ import styles from './RelatedRichBlock.stories.module.css'
6
+ import mock from './mock.json'
7
+
8
+ export default {
9
+ title: 'Main / RelatedRichBlock',
10
+ component: RelatedRichBlock,
11
+ parameters: {
12
+ themeWrapperSideBySide: true
13
+ }
14
+ }
15
+
16
+ const Example: React.FC = () => {
17
+ return (
18
+ <>
19
+ <div className={styles.root}>
20
+ <div className={styles.card}>
21
+ <RelatedRichBlock block={mock.rich} styleContext={['no_mods']} />
22
+ </div>
23
+ <div className={styles.card}>
24
+ <RelatedRichBlock block={mock.rich_dark} styleContext={['no_mods']} />
25
+ </div>
26
+ <div className={styles.card}>
27
+ <RelatedRichBlock
28
+ block={mock.rich_and_featured_mobile}
29
+ styleContext={['no_mods']}
30
+ />
31
+ </div>
32
+ <div className={styles.card}>
33
+ <RelatedRichBlock
34
+ block={mock.rich_and_featured_desktop}
35
+ styleContext={['no_mods']}
36
+ />
37
+ </div>
38
+ <div className={styles.card}>
39
+ <RelatedRichBlock block={mock.card} styleContext={['no_mods']} />
40
+ </div>
41
+ </div>
42
+ </>
43
+ )
44
+ }
45
+
46
+ export const Default: React.FC = () => (
47
+ <>
48
+ <PreviewWrapper theme="light">
49
+ <Example />
50
+ </PreviewWrapper>
51
+ {/* <PreviewWrapper theme="dark">
52
+ <Example />
53
+ </PreviewWrapper> */}
54
+ </>
55
+ )
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+ import { render } from '@testing-library/react'
3
+ import { RelatedRichBlock } from './'
4
+ import { RelatedRichBlockProps } from './RelatedRichBlock.types'
5
+
6
+ import styles from './RelatedRichBlock.module.css'
7
+
8
+ describe('Related Rich Block', () => {
9
+ let props: RelatedRichBlockProps
10
+
11
+ const renderComponent = () => render(<RelatedRichBlock {...props} />)
12
+
13
+ it('should have root style', () => {
14
+ const { getByTestId } = renderComponent()
15
+
16
+ const RelatedRichBlock = getByTestId('realated-rich-block')
17
+
18
+ expect(RelatedRichBlock).toHaveClass(styles.root)
19
+ })
20
+ })
@@ -0,0 +1,4 @@
1
+ export interface RelatedRichBlockProps {
2
+ block?: any
3
+ styleContext?: any
4
+ }
@@ -0,0 +1,105 @@
1
+ /* eslint-disable react/jsx-no-target-blank */
2
+ import React, { useState, useEffect } from 'react'
3
+ import { RelatedRichBlockProps } from './RelatedRichBlock.types'
4
+
5
+ import { makeClassName, ClassNames } from '../utils/makeClassName'
6
+ import makeStyleContext from '../utils/makeStyleContext'
7
+ import generateGradient from '../utils/generateGradient'
8
+ import { toCapitalize } from '../utils/converCase'
9
+
10
+ import { Tag } from '../Tag'
11
+ import { RenderBlocks } from '../RenderBlocks'
12
+ import { Image } from '../Image'
13
+
14
+ import styles from './RelatedRichBlock.module.css'
15
+
16
+ import { RelatedBlock } from '../RelatedBlock'
17
+
18
+ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
19
+ block: {
20
+ only_on: onlyOn,
21
+ data: {
22
+ blocks,
23
+ fallback,
24
+ url,
25
+ cover: { urls, gradients, tag, layout, ratio }
26
+ }
27
+ },
28
+ styleContext
29
+ }) => {
30
+ const style: React.CSSProperties = {}
31
+ const styleHeader: React.CSSProperties = {}
32
+
33
+ const [isRich, setIsRich] = useState(false)
34
+
35
+ const cardType = `is${toCapitalize(layout)}`
36
+
37
+ useEffect(() => {
38
+ // setIsRich(Math.random() >= 0.5)
39
+ setIsRich(true)
40
+ }, [])
41
+
42
+ let classNames: ClassNames = [
43
+ [styles.root, true],
44
+ [styles[cardType], !!layout && !!styles[cardType]],
45
+ [styles.hasGradient, !!gradients],
46
+ [styles[onlyOn], !!onlyOn && !!styles[onlyOn]]
47
+ ]
48
+
49
+ let context = ['isInMediaBlock']
50
+
51
+ if (styleContext) {
52
+ classNames = makeStyleContext(classNames, styleContext, styles)
53
+
54
+ context = [...styleContext, 'isInMediaBlock']
55
+ }
56
+
57
+ if (gradients) {
58
+ const theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light']
59
+
60
+ classNames = makeStyleContext(classNames, theme, styles)
61
+
62
+ styleHeader.backgroundImage = generateGradient(
63
+ gradients.bg_rgb,
64
+ 'mediaBlockTop'
65
+ )
66
+ style.backgroundImage = generateGradient(
67
+ gradients.bg_rgb,
68
+ 'mediaBlockBottom'
69
+ )
70
+ }
71
+
72
+ if (!isRich) {
73
+ return <RelatedBlock block={fallback} />
74
+ }
75
+
76
+ return (
77
+ <a
78
+ data-testid="related-rich-block"
79
+ className={makeClassName(classNames)}
80
+ href={url}
81
+ target="_blank"
82
+ >
83
+ {layout === 'rich' && (
84
+ <>
85
+ <div className={styles.overlay} style={style} />
86
+ <div className={styles.overlayHeader} style={styleHeader} />
87
+ </>
88
+ )}
89
+
90
+ <div className={styles.tag}>
91
+ <Tag size="small" theme="inherit" styleContext="rich">
92
+ {tag}
93
+ </Tag>
94
+ </div>
95
+ <div className={styles.cover}>
96
+ <Image optimized={urls} ratio={ratio} display="narrow" />
97
+ </div>
98
+ <div className={styles.body}>
99
+ {blocks.map((item) => (
100
+ <RenderBlocks key={item.id} block={item} styleContext={context} />
101
+ ))}
102
+ </div>
103
+ </a>
104
+ )
105
+ }