@meduza/ui-kit-2 0.2.4 → 0.2.6
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/AnnouncementInText/AnnouncementInText.stories.d.ts +10 -0
- package/dist/AnnouncementInText/AnnouncementInText.types.d.ts +4 -0
- package/dist/AnnouncementInText/index.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/ui-kit-2.cjs.development.js +104 -48
- 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 +104 -49
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +3141 -2942
- package/package.json +1 -1
- package/src/AnnouncementInText/AnnouncementInText.module.css +188 -0
- package/src/AnnouncementInText/AnnouncementInText.stories.module.css +5 -0
- package/src/AnnouncementInText/AnnouncementInText.stories.tsx +35 -0
- package/src/AnnouncementInText/AnnouncementInText.test.tsx +20 -0
- package/src/AnnouncementInText/AnnouncementInText.types.ts +4 -0
- package/src/AnnouncementInText/index.tsx +61 -0
- package/src/RenderBlocks/index.tsx +4 -0
- package/src/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
@import '../vars.css';
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
position: relative;
|
|
5
|
+
z-index: 10;
|
|
6
|
+
|
|
7
|
+
display: block;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
|
|
10
|
+
margin: calc(15rem / 16) 0;
|
|
11
|
+
padding: 55px 12px 12px;
|
|
12
|
+
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
|
|
15
|
+
color: #000;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
outline-width: 0;
|
|
18
|
+
background-color: #f7f7f7;
|
|
19
|
+
|
|
20
|
+
font-family: $secondaryFont;
|
|
21
|
+
|
|
22
|
+
@media $mobile {
|
|
23
|
+
min-height: 302px;
|
|
24
|
+
margin: 25px 0 20px;
|
|
25
|
+
padding: 20px 35px 20px 20px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.root::before,
|
|
30
|
+
.root::after {
|
|
31
|
+
position: absolute;
|
|
32
|
+
|
|
33
|
+
content: '';
|
|
34
|
+
|
|
35
|
+
background-repeat: no-repeat;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.root::before {
|
|
39
|
+
z-index: 1;
|
|
40
|
+
top: 0;
|
|
41
|
+
right: 0;
|
|
42
|
+
|
|
43
|
+
width: 133px;
|
|
44
|
+
height: 94px;
|
|
45
|
+
|
|
46
|
+
background-image: url('https://meduza.io/image/attachments/images/007/350/982/original/Rf-ceQIzOIuzPr1dkhgsyg.png');
|
|
47
|
+
background-size: 133px 94px;
|
|
48
|
+
|
|
49
|
+
@media $mobile {
|
|
50
|
+
width: 178px;
|
|
51
|
+
height: 66px;
|
|
52
|
+
|
|
53
|
+
background-image: url('https://meduza.io/image/attachments/images/007/350/467/original/WaQIwXV75NXWXqWQFp_MGQ.png');
|
|
54
|
+
background-size: 178px 66px;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.root::after {
|
|
59
|
+
z-index: -1;
|
|
60
|
+
top: 0;
|
|
61
|
+
right: 0;
|
|
62
|
+
bottom: 0;
|
|
63
|
+
left: 0;
|
|
64
|
+
|
|
65
|
+
background-image: url('https://meduza.io/image/attachments/images/007/351/482/original/Qm9dzko-_FjCOXoJJCjV2g.png');
|
|
66
|
+
background-position: center bottom;
|
|
67
|
+
background-size: 650px 170px;
|
|
68
|
+
|
|
69
|
+
@media $mobile {
|
|
70
|
+
background-image: url('https://meduza.io/image/attachments/images/007/350/475/original/qs_KJfUrIyxzMx0mvk8-jg.png');
|
|
71
|
+
background-size: 100% auto;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.body {
|
|
76
|
+
position: relative;
|
|
77
|
+
z-index: 10;
|
|
78
|
+
|
|
79
|
+
max-width: 545px;
|
|
80
|
+
margin-bottom: 33px;
|
|
81
|
+
|
|
82
|
+
@media $mobile {
|
|
83
|
+
margin-bottom: 60px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.body p {
|
|
88
|
+
margin: 0;
|
|
89
|
+
|
|
90
|
+
font-size: 16px;
|
|
91
|
+
line-height: 22px;
|
|
92
|
+
|
|
93
|
+
@media $mobile {
|
|
94
|
+
font-size: 18px;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.title {
|
|
99
|
+
max-width: 315px;
|
|
100
|
+
margin: 0 0 10px;
|
|
101
|
+
|
|
102
|
+
font-size: 27px;
|
|
103
|
+
font-weight: 700;
|
|
104
|
+
line-height: 30px;
|
|
105
|
+
|
|
106
|
+
@media $mobile {
|
|
107
|
+
max-width: initial;
|
|
108
|
+
margin: 0 0 10px;
|
|
109
|
+
|
|
110
|
+
font-size: 32px;
|
|
111
|
+
line-height: 38px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.footer {
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-flow: row nowrap;
|
|
118
|
+
justify-content: flex-end;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.button {
|
|
122
|
+
display: block;
|
|
123
|
+
|
|
124
|
+
width: 100%;
|
|
125
|
+
max-width: 315px;
|
|
126
|
+
padding: 13px 0;
|
|
127
|
+
|
|
128
|
+
text-align: center;
|
|
129
|
+
text-decoration: none;
|
|
130
|
+
letter-spacing: 1px;
|
|
131
|
+
text-transform: uppercase;
|
|
132
|
+
|
|
133
|
+
color: #fff;
|
|
134
|
+
border-radius: 25px;
|
|
135
|
+
background-color: #000;
|
|
136
|
+
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
line-height: 16px;
|
|
140
|
+
|
|
141
|
+
@media $mobile {
|
|
142
|
+
max-width: 315px;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.button:hover {
|
|
147
|
+
background-color: #8064e2;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.button::after {
|
|
151
|
+
position: absolute;
|
|
152
|
+
z-index: 20;
|
|
153
|
+
top: 0;
|
|
154
|
+
right: 0;
|
|
155
|
+
bottom: 0;
|
|
156
|
+
left: 0;
|
|
157
|
+
|
|
158
|
+
content: '';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* Mods */
|
|
162
|
+
|
|
163
|
+
.center {
|
|
164
|
+
@media $mobile {
|
|
165
|
+
width: 100%;
|
|
166
|
+
max-width: 650px;
|
|
167
|
+
margin-right: auto;
|
|
168
|
+
margin-left: auto;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.isInCard,
|
|
173
|
+
.isInSlide {
|
|
174
|
+
margin-right: -11px;
|
|
175
|
+
margin-left: -11px;
|
|
176
|
+
|
|
177
|
+
@media $mobile {
|
|
178
|
+
margin-right: 0;
|
|
179
|
+
margin-left: 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.en.root::before {
|
|
184
|
+
@media $mobileMax {
|
|
185
|
+
top: -8px;
|
|
186
|
+
right: -23px;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { AnnouncementInText } from './'
|
|
3
|
+
import { PreviewWrapper } from '../_storybook/PreviewWrapper'
|
|
4
|
+
|
|
5
|
+
import styles from './AnnouncementInText.stories.module.css'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Main / AnnouncementInText',
|
|
9
|
+
component: AnnouncementInText,
|
|
10
|
+
parameters: {
|
|
11
|
+
themeWrapperSideBySide: true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Example: React.FC = () => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<div className={styles.root}>
|
|
19
|
+
<AnnouncementInText lang="ru" styleContext={['center']} />
|
|
20
|
+
<AnnouncementInText lang="en" styleContext={['center']} />
|
|
21
|
+
</div>
|
|
22
|
+
</>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Default: React.FC = () => (
|
|
27
|
+
<>
|
|
28
|
+
<PreviewWrapper theme="light">
|
|
29
|
+
<Example />
|
|
30
|
+
</PreviewWrapper>
|
|
31
|
+
<PreviewWrapper theme="dark">
|
|
32
|
+
<Example />
|
|
33
|
+
</PreviewWrapper>
|
|
34
|
+
</>
|
|
35
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { AnnouncementInText } from './'
|
|
4
|
+
import { AnnouncementInTextProps } from './AnnouncementInText.types'
|
|
5
|
+
|
|
6
|
+
import styles from './AnnouncementInText.module.css'
|
|
7
|
+
|
|
8
|
+
describe('Announcement In Text', () => {
|
|
9
|
+
let props: AnnouncementInTextProps
|
|
10
|
+
|
|
11
|
+
const renderComponent = () => render(<AnnouncementInText {...props} />)
|
|
12
|
+
|
|
13
|
+
it('should have root style', () => {
|
|
14
|
+
const { getByTestId } = renderComponent()
|
|
15
|
+
|
|
16
|
+
const announcementInText = getByTestId('announcement-in-text')
|
|
17
|
+
|
|
18
|
+
expect(announcementInText).toHaveClass(styles.root)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { AnnouncementInTextProps } from './AnnouncementInText.types'
|
|
3
|
+
import { makeClassName, ClassNames } from '../utils/makeClassName'
|
|
4
|
+
import makeStyleContext from '../utils/makeStyleContext'
|
|
5
|
+
|
|
6
|
+
import styles from './AnnouncementInText.module.css'
|
|
7
|
+
|
|
8
|
+
export const AnnouncementInText: React.FC<AnnouncementInTextProps> = ({
|
|
9
|
+
styleContext,
|
|
10
|
+
lang = 'ru'
|
|
11
|
+
}) => {
|
|
12
|
+
let classNames: ClassNames = [
|
|
13
|
+
[styles.root, true],
|
|
14
|
+
[styles[lang], styles[lang]]
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
if (styleContext) {
|
|
18
|
+
classNames = makeStyleContext(classNames, styleContext, styles)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const data = {
|
|
22
|
+
ru: {
|
|
23
|
+
title: 'Подарите себе «Медузу»',
|
|
24
|
+
text:
|
|
25
|
+
'В 2021 году «Медуза» смогла выжить — благодаря читателям. Но нам по-прежнему нужна поддержка. Один раз или регулярно, маленькая сумма или большая — любая помощь критически важна. В 2022-м наша редакция может рассчитывать только на вас. А вы знаете, что делать.',
|
|
26
|
+
button: 'О да, я знаю!',
|
|
27
|
+
href: 'https://mdza.io/FNtRa28cc1o'
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
en: {
|
|
31
|
+
title: 'This holiday season, make Meduza your gift to yourself',
|
|
32
|
+
text:
|
|
33
|
+
'Meduza survived 2021 thanks to readers like you. To make it through another year, we need your continued support. One-time contributions and especially recurring donations will sustain Meduza’s work in 2022. Whatever you can give, your help is critical. The future of our newsroom is in your hands. You know what to do.',
|
|
34
|
+
button: 'Let’s do this!',
|
|
35
|
+
href: 'https://mdza.io/c-m1LRBgwEA'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const localeData = data[lang]
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
data-testid="announcement-in-text"
|
|
44
|
+
className={makeClassName(classNames)}
|
|
45
|
+
>
|
|
46
|
+
<div className={styles.body}>
|
|
47
|
+
<h3
|
|
48
|
+
className={styles.title}
|
|
49
|
+
dangerouslySetInnerHTML={{ __html: localeData.title }}
|
|
50
|
+
/>
|
|
51
|
+
<p dangerouslySetInnerHTML={{ __html: localeData.text }} />
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div className={styles.footer}>
|
|
55
|
+
<a className={styles.button} href={localeData.href}>
|
|
56
|
+
{localeData.button}
|
|
57
|
+
</a>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
@@ -17,6 +17,7 @@ import { Table } from '../Table'
|
|
|
17
17
|
import { MaterialNote } from '../MaterialNote'
|
|
18
18
|
import { SensitiveBlock } from '../SensitiveBlock'
|
|
19
19
|
import { DonatesTeaser } from '../DonatesTeaser'
|
|
20
|
+
import { AnnouncementInText } from '../AnnouncementInText'
|
|
20
21
|
|
|
21
22
|
export const RenderBlocks: React.FC<RenderBlocksProps> = ({
|
|
22
23
|
block,
|
|
@@ -126,6 +127,9 @@ export const RenderBlocks: React.FC<RenderBlocksProps> = ({
|
|
|
126
127
|
case 'material_note':
|
|
127
128
|
return <MaterialNote block={block} styleContext={styleContext} />
|
|
128
129
|
|
|
130
|
+
case 'announcement_in_text':
|
|
131
|
+
return <AnnouncementInText styleContext={styleContext} lang={lang} />
|
|
132
|
+
|
|
129
133
|
default: {
|
|
130
134
|
return null
|
|
131
135
|
}
|