@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.
- package/dist/Cover/Cover.types.d.ts +21 -1
- package/dist/DotsOnImage/DotsOnImage.types.d.ts +1 -1
- package/dist/Image/Image.types.d.ts +1 -6
- package/dist/ListBlock/ListBlock.stories.d.ts +2 -1
- package/dist/ListBlock/ListBlock.types.d.ts +7 -1
- package/dist/RelatedBlock/RelatedBlock.types.d.ts +14 -1
- package/dist/RelatedRichBlock/RelatedRichBlock.stories.d.ts +10 -0
- package/dist/RelatedRichBlock/RelatedRichBlock.types.d.ts +4 -0
- package/dist/RelatedRichBlock/index.d.ts +3 -0
- package/dist/RichTitle/RichTitle.types.d.ts +8 -1
- package/dist/SimpleTitle/SimpleTitle.types.d.ts +6 -1
- package/dist/SourceBlock/SourceBlock.types.d.ts +12 -1
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/ui-kit-2.cjs.development.js +147 -47
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +147 -48
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +1157 -961
- package/dist/utils/converCase.d.ts +2 -0
- package/dist/utils/generateGradient.d.ts +1 -1
- package/package.json +4 -1
- package/src/.DS_Store +0 -0
- package/src/BookmarkButton/BookmarkButton.test.tsx +17 -4
- package/src/CardTitle/CardTitle.test.tsx +4 -3
- package/src/ChapterBlock/ChapterBlock.test.tsx +4 -3
- package/src/Cover/Cover.test.tsx +3 -3
- package/src/Cover/Cover.types.ts +22 -1
- package/src/Cover/index.tsx +1 -1
- package/src/DocumentItemsCount/DocumentItemsCount.test.tsx +4 -3
- package/src/DotsOnImage/DotsOnImage.test.tsx +4 -2
- package/src/DotsOnImage/DotsOnImage.types.ts +1 -1
- package/src/EmbedBlock/EmbedBlock.test.tsx +16 -3
- package/src/EmbedBlock/index.tsx +1 -1
- package/src/GroupedBlock/GroupedBlock.test.tsx +5 -3
- package/src/HalfBlock/HalfBlock.test.tsx +4 -3
- package/src/Image/Image.test.tsx +3 -0
- package/src/Image/Image.types.ts +1 -6
- package/src/Image/RenderPicture.tsx +1 -1
- package/src/ImportantLead/ImportantLead.test.tsx +10 -8
- package/src/ImportantLead/mock.json +6 -0
- package/src/Lazy/Lazy.test.tsx +3 -0
- package/src/ListBlock/ListBlock.stories.tsx +2 -1
- package/src/ListBlock/ListBlock.test.tsx +8 -4
- package/src/ListBlock/ListBlock.types.ts +6 -1
- package/src/ListBlock/index.tsx +1 -1
- package/src/ListBlock/mock.json +1 -1
- package/src/MaterialNote/MaterialNote.test.tsx +4 -3
- package/src/Meta/Meta.module.css +1 -1
- package/src/QuoteBlock/QuoteBlock.test.tsx +4 -3
- package/src/RawHtmlBlock/RawHtmlBlock.test.tsx +18 -9
- package/src/RawHtmlBlock/mock.json +6 -0
- package/src/RelatedBlock/RelatedBlock.test.tsx +4 -3
- package/src/RelatedBlock/RelatedBlock.types.ts +14 -1
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +165 -0
- package/src/RelatedRichBlock/RelatedRichBlock.stories.module.css +12 -0
- package/src/RelatedRichBlock/RelatedRichBlock.stories.tsx +55 -0
- package/src/RelatedRichBlock/RelatedRichBlock.test.tsx +20 -0
- package/src/RelatedRichBlock/RelatedRichBlock.types.ts +4 -0
- package/src/RelatedRichBlock/index.tsx +105 -0
- package/src/RelatedRichBlock/mock.json +354 -0
- package/src/RenderBlocks/RenderBlocks.stories.module.css +3 -0
- package/src/RenderBlocks/RenderBlocks.stories.tsx +4 -1
- package/src/RenderBlocks/RenderBlocks.test.tsx +15 -9
- package/src/RenderBlocks/index.tsx +5 -0
- package/src/RenderBlocks/mock.json +83 -0
- package/src/RichTitle/RichTitle.module.css +37 -7
- package/src/RichTitle/RichTitle.test.tsx +4 -3
- package/src/RichTitle/RichTitle.types.ts +8 -1
- package/src/SimpleBlock/SimpleBlock.test.tsx +16 -9
- package/src/SimpleBlock/mock.json +6 -0
- package/src/SimpleTitle/SimpleTitle.test.tsx +4 -3
- package/src/SimpleTitle/SimpleTitle.types.ts +6 -1
- package/src/SourceBlock/SourceBlock.test.tsx +4 -3
- package/src/SourceBlock/SourceBlock.types.ts +13 -1
- package/src/Spoiler/Spoiler.test.tsx +4 -3
- package/src/Table/Table.test.tsx +3 -3
- package/src/Timestamp/Timestamp.test.tsx +4 -3
- package/src/ToolbarButton/ToolbarButton.test.tsx +8 -3
- package/src/_storybook/PreviewWrapper/PreviewWrapper.module.css +3 -1
- package/src/index.tsx +1 -0
- package/src/types.ts +6 -0
- package/src/utils/{toCamel.ts → converCase.ts} +3 -0
- package/src/utils/generateGradient.ts +21 -15
- 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,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,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
|
+
}
|