@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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const generateGradient: (color: string) => string;
|
|
1
|
+
declare const generateGradient: (color: string, type: string) => string;
|
|
2
2
|
export default generateGradient;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.21",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "UIKit for Meduza",
|
|
5
5
|
"repository": "https://github.com/meduza-corp/ui-kit-2.git",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@storybook/react": "^6.0.21",
|
|
68
68
|
"@testing-library/jest-dom": "^5.11.1",
|
|
69
69
|
"@testing-library/react": "^10.4.7",
|
|
70
|
+
"@types/jest": "26.0.14",
|
|
70
71
|
"@types/react": "^16.9.43",
|
|
71
72
|
"@types/react-dom": "^16.9.8",
|
|
72
73
|
"@typescript-eslint/eslint-plugin": "^4.2.0",
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"eslint-plugin-react": "^7.21.0",
|
|
80
81
|
"husky": "^4.2.5",
|
|
81
82
|
"identity-obj-proxy": "^3.0.0",
|
|
83
|
+
"jest": "^26.5.3",
|
|
82
84
|
"lint-staged": "^10.2.11",
|
|
83
85
|
"plop": "^2.7.1",
|
|
84
86
|
"postcss-import": "^12.0.1",
|
|
@@ -97,6 +99,7 @@
|
|
|
97
99
|
"stylelint-config-sass-guidelines": "^7.0.0",
|
|
98
100
|
"stylelint-config-standard": "^20.0.0",
|
|
99
101
|
"stylelint-order": "^4.1.0",
|
|
102
|
+
"ts-jest": "26.4.1",
|
|
100
103
|
"ts-loader": "^8.0.1",
|
|
101
104
|
"tsconfig-paths-webpack-plugin": "^3.2.0",
|
|
102
105
|
"tsdx": "^0.13.2",
|
package/src/.DS_Store
ADDED
|
Binary file
|
|
@@ -2,13 +2,16 @@ import React from 'react'
|
|
|
2
2
|
import { render } from '@testing-library/react'
|
|
3
3
|
|
|
4
4
|
import { BookmarkButton } from './'
|
|
5
|
-
import { BookmarkButtonProps } from './BookmarkButton.types'
|
|
6
5
|
import styles from './BookmarkButton.module.css'
|
|
7
6
|
|
|
8
7
|
describe('Bookmark Button', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const renderComponent = () =>
|
|
9
|
+
render(
|
|
10
|
+
<BookmarkButton
|
|
11
|
+
onClick={(): void => alert('true')}
|
|
12
|
+
isInBookmarks={false}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
12
15
|
|
|
13
16
|
it('should have root style', () => {
|
|
14
17
|
const { getByTestId } = renderComponent()
|
|
@@ -17,4 +20,14 @@ describe('Bookmark Button', () => {
|
|
|
17
20
|
|
|
18
21
|
expect(bookmarkButton).toHaveClass(styles.root)
|
|
19
22
|
})
|
|
23
|
+
|
|
24
|
+
// it('should change class on click', () => {
|
|
25
|
+
// const { getByTestId } = renderComponent()
|
|
26
|
+
|
|
27
|
+
// const bookmarkButton = getByTestId('bookmark-button')
|
|
28
|
+
|
|
29
|
+
// fireEvent.click(bookmarkButton)
|
|
30
|
+
|
|
31
|
+
// expect(bookmarkButton).toHaveClass(styles.isInBookmarks)
|
|
32
|
+
// })
|
|
20
33
|
})
|
|
@@ -5,10 +5,11 @@ import { CardTitleProps } from './CardTitle.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './CardTitle.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: CardTitleProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Card Title', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<CardTitle block={mock as CardTitleProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
|
@@ -5,10 +5,11 @@ import { ChapterBlockProps } from './ChapterBlock.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './ChapterBlock.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: ChapterBlockProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Chapter Block', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<ChapterBlock block={mock as ChapterBlockProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
package/src/Cover/Cover.test.tsx
CHANGED
|
@@ -4,11 +4,11 @@ import { Cover } from './'
|
|
|
4
4
|
import { CoverProps } from './Cover.types'
|
|
5
5
|
|
|
6
6
|
import styles from './Cover.module.css'
|
|
7
|
+
import mock from './mock.json'
|
|
7
8
|
|
|
8
9
|
describe('Cover', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const renderComponent = () => render(<Cover {...props} />)
|
|
10
|
+
const renderComponent = () =>
|
|
11
|
+
render(<Cover block={mock as CoverProps['block']} />)
|
|
12
12
|
|
|
13
13
|
it('should have root style', () => {
|
|
14
14
|
const { getByTestId } = renderComponent()
|
package/src/Cover/Cover.types.ts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
import { OptimizedImageItem } from '../types'
|
|
2
|
+
|
|
1
3
|
export interface CoverProps {
|
|
2
|
-
block:
|
|
4
|
+
block: {
|
|
5
|
+
only_on?: string
|
|
6
|
+
data: {
|
|
7
|
+
blocks: any
|
|
8
|
+
cover: {
|
|
9
|
+
credit?: string
|
|
10
|
+
caption?: string
|
|
11
|
+
cc: string
|
|
12
|
+
urls: {
|
|
13
|
+
w325: OptimizedImageItem
|
|
14
|
+
w600: OptimizedImageItem
|
|
15
|
+
}
|
|
16
|
+
mobile_ratio: number
|
|
17
|
+
gradients: {
|
|
18
|
+
text_rgb: string
|
|
19
|
+
bg_rgb: string
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
3
24
|
styleContext?: string[] | string
|
|
4
25
|
}
|
package/src/Cover/index.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export const Cover: React.FC<CoverProps> = ({
|
|
|
38
38
|
|
|
39
39
|
classNames = makeStyleContext(classNames, theme, styles)
|
|
40
40
|
|
|
41
|
-
style.backgroundImage = generateGradient(gradients.bg_rgb)
|
|
41
|
+
style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom')
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const renderCC = (context?: string): JSX.Element => (
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { render } from '@testing-library/react'
|
|
3
3
|
import { DocumentItemsCount } from './'
|
|
4
|
-
import { DocumentItemsCountProps } from './DocumentItemsCount.types'
|
|
4
|
+
// import { DocumentItemsCountProps } from './DocumentItemsCount.types'
|
|
5
5
|
|
|
6
6
|
import styles from './DocumentItemsCount.module.css'
|
|
7
7
|
|
|
8
8
|
describe('Document Items Count', () => {
|
|
9
|
-
let props: DocumentItemsCountProps
|
|
9
|
+
// let props: DocumentItemsCountProps
|
|
10
10
|
|
|
11
|
-
const renderComponent = () =>
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<DocumentItemsCount type="card" items={4} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
|
@@ -3,6 +3,8 @@ import { render } from '@testing-library/react'
|
|
|
3
3
|
import mock from './mock.json'
|
|
4
4
|
import { DotsOnImage } from './'
|
|
5
5
|
|
|
6
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
7
|
+
|
|
6
8
|
import styles from './DotsOnImage.module.css'
|
|
7
9
|
|
|
8
10
|
describe('Dots On Image', () => {
|
|
@@ -11,8 +13,8 @@ describe('Dots On Image', () => {
|
|
|
11
13
|
const renderComponent = () => render(<DotsOnImage block={data} />)
|
|
12
14
|
|
|
13
15
|
it('should have root style', () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const { getByTestId } = renderComponent()
|
|
17
|
+
mockAllIsIntersecting(true)
|
|
16
18
|
const dotsOnImage = getByTestId('dots-on-image')
|
|
17
19
|
|
|
18
20
|
expect(dotsOnImage).toHaveClass(styles.root)
|
|
@@ -5,13 +5,26 @@ import { EmbedBlockProps } from './EmbedBlock.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './EmbedBlock.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import mock from './mock.json'
|
|
9
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
describe('Embed Block', () => {
|
|
12
|
+
const renderComponent = () =>
|
|
13
|
+
render(
|
|
14
|
+
<div>
|
|
15
|
+
{mock.blocks.map((block) => (
|
|
16
|
+
<EmbedBlockContainer
|
|
17
|
+
block={block as EmbedBlockProps['block']}
|
|
18
|
+
lang="ru"
|
|
19
|
+
key={block.id}
|
|
20
|
+
/>
|
|
21
|
+
))}
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
12
24
|
|
|
13
25
|
it('should have root style', () => {
|
|
14
26
|
const { getByTestId } = renderComponent()
|
|
27
|
+
mockAllIsIntersecting(true)
|
|
15
28
|
|
|
16
29
|
const embedBlock = getByTestId('embed-block')
|
|
17
30
|
|
package/src/EmbedBlock/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ export const EmbedBlockContainer: React.FC<EmbedBlockProps> = ({
|
|
|
8
8
|
styleContext,
|
|
9
9
|
lang
|
|
10
10
|
}) => {
|
|
11
|
-
if (block.data.wrap_with_iframe) {
|
|
11
|
+
if (block.data && block.data.wrap_with_iframe) {
|
|
12
12
|
return <IframeBlock block={block} styleContext={styleContext} lang={lang} />
|
|
13
13
|
}
|
|
14
14
|
return <EmbedBlock block={block} styleContext={styleContext} />
|
|
@@ -4,14 +4,16 @@ import { GroupedBlock } from './'
|
|
|
4
4
|
import { GroupedBlockProps } from './GroupedBlock.types'
|
|
5
5
|
|
|
6
6
|
import styles from './GroupedBlock.module.css'
|
|
7
|
+
import mock from './mock.json'
|
|
8
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
7
9
|
|
|
8
10
|
describe('Grouped Block', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const renderComponent = () => render(<GroupedBlock {...props} />)
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<GroupedBlock block={mock as GroupedBlockProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
|
16
|
+
mockAllIsIntersecting(true)
|
|
15
17
|
|
|
16
18
|
const groupedBlock = getByTestId('grouped-block')
|
|
17
19
|
|
|
@@ -5,10 +5,11 @@ import { HalfBlockProps } from './HalfBlock.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './HalfBlock.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: HalfBlockProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Half Block', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<HalfBlock block={mock as HalfBlockProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
package/src/Image/Image.test.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import { Image } from './'
|
|
|
4
4
|
|
|
5
5
|
import styles from './Image.module.css'
|
|
6
6
|
|
|
7
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
8
|
+
|
|
7
9
|
import mock from './mock.json'
|
|
8
10
|
|
|
9
11
|
describe('Image', () => {
|
|
@@ -25,6 +27,7 @@ describe('Image', () => {
|
|
|
25
27
|
|
|
26
28
|
it('should have root style', () => {
|
|
27
29
|
const { getByTestId } = renderComponent()
|
|
30
|
+
mockAllIsIntersecting(true)
|
|
28
31
|
|
|
29
32
|
const image = getByTestId('image')
|
|
30
33
|
|
package/src/Image/Image.types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { PictureProps } from './Image.types'
|
|
3
3
|
import { imageBreakpoints, imageConditionalKeys } from '../constants'
|
|
4
|
-
import { toCamel } from '../utils/
|
|
4
|
+
import { toCamel } from '../utils/converCase'
|
|
5
5
|
|
|
6
6
|
export const RenderPicture: React.FC<PictureProps> = ({
|
|
7
7
|
source,
|
|
@@ -3,18 +3,20 @@ import { render } from '@testing-library/react'
|
|
|
3
3
|
import { ImportantLead } from './'
|
|
4
4
|
import { ImportantLeadProps } from './ImportantLead.types'
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import mock from './mock.json'
|
|
7
7
|
|
|
8
8
|
describe('Important Lead', () => {
|
|
9
|
-
let props: ImportantLeadProps
|
|
10
9
|
|
|
11
|
-
const renderComponent = () =>
|
|
10
|
+
const renderComponent = () =>
|
|
11
|
+
render(
|
|
12
|
+
<div>
|
|
13
|
+
<ImportantLead block={mock as ImportantLeadProps['block']} />
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
12
16
|
|
|
13
|
-
it('should have
|
|
14
|
-
const {
|
|
17
|
+
it('should have some blocks', () => {
|
|
18
|
+
const { getByText } = renderComponent()
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
expect(importantLead).toHaveClass(styles.root)
|
|
20
|
+
getByText('Hello Component')
|
|
19
21
|
})
|
|
20
22
|
})
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "important_lead",
|
|
3
3
|
"data": [
|
|
4
|
+
{
|
|
5
|
+
"type": "p",
|
|
6
|
+
"data": "Hello Component",
|
|
7
|
+
"length": 0,
|
|
8
|
+
"id": "3-0-932322024caa3bc0ff717400f1ba00da2dc3879b55eb574a5de2817dea059184e551"
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"type": "p",
|
|
6
12
|
"data": "<strong>Что:</strong> Приговор по делу «Седьмой студии»",
|
package/src/Lazy/Lazy.test.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import { render } from '@testing-library/react'
|
|
|
3
3
|
import { Lazy } from './'
|
|
4
4
|
import { LazyProps } from './Lazy.types'
|
|
5
5
|
|
|
6
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
7
|
+
|
|
6
8
|
import styles from './Lazy.module.css'
|
|
7
9
|
|
|
8
10
|
describe('Lazy', () => {
|
|
@@ -12,6 +14,7 @@ describe('Lazy', () => {
|
|
|
12
14
|
|
|
13
15
|
it('should have root style', () => {
|
|
14
16
|
const { getByTestId } = renderComponent()
|
|
17
|
+
mockAllIsIntersecting(true)
|
|
15
18
|
|
|
16
19
|
const lazy = getByTestId('lazy')
|
|
17
20
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { ListBlock } from './'
|
|
3
3
|
import { PreviewWrapper } from '../_storybook/PreviewWrapper'
|
|
4
|
+
import { ListBlockProps } from './ListBlock.types'
|
|
4
5
|
|
|
5
6
|
import styles from './ListBlock.stories.module.css'
|
|
6
7
|
|
|
@@ -19,7 +20,7 @@ const Example: React.FC = () => {
|
|
|
19
20
|
<>
|
|
20
21
|
<div className={styles.root}>
|
|
21
22
|
{mock.blocks.map((item) => (
|
|
22
|
-
<ListBlock block={item} key={item.id} />
|
|
23
|
+
<ListBlock block={item as ListBlockProps['block']} key={item.id} />
|
|
23
24
|
))}
|
|
24
25
|
</div>
|
|
25
26
|
</>
|
|
@@ -4,17 +4,21 @@ import { ListBlock } from './'
|
|
|
4
4
|
import { ListBlockProps } from './ListBlock.types'
|
|
5
5
|
|
|
6
6
|
import styles from './ListBlock.module.css'
|
|
7
|
+
import mock from './mock.json'
|
|
7
8
|
|
|
8
9
|
describe('List Block', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const renderComponent = () =>
|
|
11
|
+
render(
|
|
12
|
+
<div>
|
|
13
|
+
<ListBlock block={mock.blocks[0] as ListBlockProps['block']} />
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
12
16
|
|
|
13
17
|
it('should have root style', () => {
|
|
14
18
|
const { getByTestId } = renderComponent()
|
|
15
19
|
|
|
16
20
|
const listBlock = getByTestId('list-block')
|
|
17
21
|
|
|
18
|
-
expect(listBlock).toHaveClass(styles.
|
|
22
|
+
expect(listBlock).toHaveClass(styles.ul)
|
|
19
23
|
})
|
|
20
24
|
})
|
package/src/ListBlock/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export const ListBlock: React.FC<ListBlockProps> = ({
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<TagName className={makeClassName(classNames)}>
|
|
25
|
+
<TagName className={makeClassName(classNames)} data-testid="list-block">
|
|
26
26
|
{data.map((item, index) => (
|
|
27
27
|
<li key={index} dangerouslySetInnerHTML={{ __html: item }} />
|
|
28
28
|
))}
|
package/src/ListBlock/mock.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"Вместе с Сергеем Скрипалем в 2018 году были отравлены его дочь, полицейский и случайные прохожие Чарли Роули и Дон Стерджесс, нашедшие флакон с остатками вещества (Стерджесс погибла)."
|
|
19
19
|
],
|
|
20
20
|
"length": 452,
|
|
21
|
-
"id": "15-
|
|
21
|
+
"id": "15-aa8590a46fd0bfceb559be9679920c31efefefc4267320389013f8886d653b5bdbe208"
|
|
22
22
|
}
|
|
23
23
|
]
|
|
24
24
|
}
|
|
@@ -5,10 +5,11 @@ import { MaterialNoteProps } from './MaterialNote.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './MaterialNote.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: MaterialNoteProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Material Note', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<MaterialNote block={mock as MaterialNoteProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
package/src/Meta/Meta.module.css
CHANGED
|
@@ -5,10 +5,11 @@ import { QuoteBlockProps } from './QuoteBlock.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './QuoteBlock.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: QuoteBlockProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Quote Block', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<QuoteBlock block={mock as QuoteBlockProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
|
@@ -3,18 +3,27 @@ import { render } from '@testing-library/react'
|
|
|
3
3
|
import { RawHtmlBlock } from './'
|
|
4
4
|
import { RawHtmlBlockProps } from './RawHtmlBlock.types'
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils'
|
|
7
|
+
import mock from './mock.json'
|
|
7
8
|
|
|
8
9
|
describe('Raw Html Block', () => {
|
|
9
|
-
|
|
10
|
+
const renderComponent = () =>
|
|
11
|
+
render(
|
|
12
|
+
<div>
|
|
13
|
+
{mock.blocks.map((item) => (
|
|
14
|
+
<RawHtmlBlock
|
|
15
|
+
block={item as RawHtmlBlockProps['block']}
|
|
16
|
+
key={item.id}
|
|
17
|
+
lightBox={null}
|
|
18
|
+
/>
|
|
19
|
+
))}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
it('should have some blocks', () => {
|
|
24
|
+
const { getByText } = renderComponent()
|
|
25
|
+
mockAllIsIntersecting(true)
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
const { getByTestId } = renderComponent()
|
|
15
|
-
|
|
16
|
-
const rawHtmlBlock = getByTestId('raw-html-block')
|
|
17
|
-
|
|
18
|
-
expect(rawHtmlBlock).toHaveClass(styles.root)
|
|
27
|
+
getByText('Hello Component')
|
|
19
28
|
})
|
|
20
29
|
})
|
|
@@ -5,10 +5,11 @@ import { RelatedBlockProps } from './RelatedBlock.types'
|
|
|
5
5
|
|
|
6
6
|
import styles from './RelatedBlock.module.css'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
let props: RelatedBlockProps
|
|
8
|
+
import mock from './mock.json'
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
describe('Related Block', () => {
|
|
11
|
+
const renderComponent = () =>
|
|
12
|
+
render(<RelatedBlock block={mock as RelatedBlockProps['block']} />)
|
|
12
13
|
|
|
13
14
|
it('should have root style', () => {
|
|
14
15
|
const { getByTestId } = renderComponent()
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
export interface RelatedBlockProps {
|
|
2
|
-
block:
|
|
2
|
+
block: {
|
|
3
|
+
data: {
|
|
4
|
+
title: string
|
|
5
|
+
related: {
|
|
6
|
+
title: string
|
|
7
|
+
second_title?: string
|
|
8
|
+
layout: string
|
|
9
|
+
url?: string
|
|
10
|
+
full_url?: string
|
|
11
|
+
id: string
|
|
12
|
+
}[]
|
|
13
|
+
}
|
|
14
|
+
only_on?: string
|
|
15
|
+
}
|
|
3
16
|
styleContext?: string[] | string
|
|
4
17
|
}
|