@gravity-ui/page-constructor 2.8.3 → 2.9.0
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/CHANGELOG.md +14 -0
- package/build/cjs/blocks/Questions/Questions.js +14 -5
- package/build/cjs/components/AnimateBlock/AnimateBlock.d.ts +1 -0
- package/build/cjs/components/AnimateBlock/AnimateBlock.js +2 -2
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +1 -0
- package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.js +36 -0
- package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/cjs/components/ButtonTabs/ButtonTabs.js +2 -2
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +1 -0
- package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.js +58 -0
- package/build/cjs/components/HTML/HTML.d.ts +3 -1
- package/build/cjs/components/HTML/HTML.js +2 -1
- package/build/cjs/components/YFMWrapper/YFMWrapper.d.ts +2 -1
- package/build/cjs/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/cjs/sub-blocks/Content/Content.css +0 -4
- package/build/esm/blocks/Questions/Questions.js +14 -5
- package/build/esm/components/AnimateBlock/AnimateBlock.d.ts +1 -0
- package/build/esm/components/AnimateBlock/AnimateBlock.js +2 -2
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +1 -0
- package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.js +33 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.js +2 -2
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +1 -0
- package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.js +55 -0
- package/build/esm/components/HTML/HTML.d.ts +3 -1
- package/build/esm/components/HTML/HTML.js +2 -1
- package/build/esm/components/YFMWrapper/YFMWrapper.d.ts +2 -1
- package/build/esm/components/YFMWrapper/YFMWrapper.js +1 -1
- package/build/esm/sub-blocks/Content/Content.css +0 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.9.0](https://github.com/gravity-ui/page-constructor/compare/v2.8.4...v2.9.0) (2023-04-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **QuestionBlock:** add schema.org FAQ microdata ([#308](https://github.com/gravity-ui/page-constructor/issues/308)) ([cfca14a](https://github.com/gravity-ui/page-constructor/commit/cfca14a76b458bfa21daa452cb46cb966fae9e88))
|
|
9
|
+
|
|
10
|
+
## [2.8.4](https://github.com/gravity-ui/page-constructor/compare/v2.8.3...v2.8.4) (2023-04-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **Content:** remove links margin ([#306](https://github.com/gravity-ui/page-constructor/issues/306)) ([62972b4](https://github.com/gravity-ui/page-constructor/commit/62972b445e28016fe250c0361c91b84324456fe6))
|
|
16
|
+
|
|
3
17
|
## [2.8.3](https://github.com/gravity-ui/page-constructor/compare/v2.8.2...v2.8.3) (2023-04-14)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -8,6 +8,15 @@ const grid_1 = require("../../grid");
|
|
|
8
8
|
const sub_blocks_1 = require("../../sub-blocks");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const b = (0, utils_1.block)('QuestionsBlock');
|
|
11
|
+
const FaqMicrodataValues = {
|
|
12
|
+
PageType: 'https://schema.org/FAQPage',
|
|
13
|
+
QuestionType: 'https://schema.org/Question',
|
|
14
|
+
QuestionProp: 'mainEntity',
|
|
15
|
+
QuestionTextProp: 'name',
|
|
16
|
+
AnswerType: 'https://schema.org/Answer',
|
|
17
|
+
AnswerProp: 'acceptedAnswer',
|
|
18
|
+
AnswerTextProp: 'text',
|
|
19
|
+
};
|
|
11
20
|
const QuestionsBlock = (props) => {
|
|
12
21
|
const { title, text, additionalInfo, links, buttons, items } = props;
|
|
13
22
|
const [opened, setOpened] = (0, react_1.useState)([0]);
|
|
@@ -21,24 +30,24 @@ const QuestionsBlock = (props) => {
|
|
|
21
30
|
}
|
|
22
31
|
setOpened(newState);
|
|
23
32
|
};
|
|
24
|
-
return (react_1.default.createElement("div", { className: b() },
|
|
33
|
+
return (react_1.default.createElement("div", { className: b(), itemScope: true, itemType: FaqMicrodataValues.PageType },
|
|
25
34
|
react_1.default.createElement(grid_1.Row, null,
|
|
26
35
|
react_1.default.createElement(grid_1.Col, { sizes: { all: 12, md: 4 } },
|
|
27
36
|
react_1.default.createElement("div", { className: b('title') },
|
|
28
37
|
react_1.default.createElement(sub_blocks_1.Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 } }))),
|
|
29
38
|
react_1.default.createElement(grid_1.Col, { sizes: { all: 12, md: 8 } }, items.map(({ title: itemTitle, text: itemText, link, listStyle = 'dash' }, index) => {
|
|
30
39
|
const isOpened = opened.includes(index);
|
|
31
|
-
return (react_1.default.createElement("div", { key: itemTitle, className: b('item') },
|
|
40
|
+
return (react_1.default.createElement("div", { key: itemTitle, className: b('item'), itemScope: true, itemProp: FaqMicrodataValues.QuestionProp, itemType: FaqMicrodataValues.QuestionType },
|
|
32
41
|
react_1.default.createElement("h4", { className: b('item-title'), onClick: () => toggleItem(index) },
|
|
33
|
-
react_1.default.createElement(components_1.HTML,
|
|
42
|
+
react_1.default.createElement(components_1.HTML, { itemProp: FaqMicrodataValues.QuestionTextProp }, itemTitle),
|
|
34
43
|
react_1.default.createElement(components_1.ToggleArrow, { open: isOpened, size: 16, type: 'vertical', iconType: "navigation", className: b('arrow') })),
|
|
35
44
|
react_1.default.createElement(components_1.Foldable, { isOpened: isOpened },
|
|
36
|
-
react_1.default.createElement("div", { className: b('text') },
|
|
45
|
+
react_1.default.createElement("div", { className: b('text'), itemScope: true, itemProp: FaqMicrodataValues.AnswerProp, itemType: FaqMicrodataValues.AnswerType },
|
|
37
46
|
react_1.default.createElement(components_1.YFMWrapper, { content: itemText, modifiers: {
|
|
38
47
|
constructor: true,
|
|
39
48
|
constructorListStyle: true,
|
|
40
49
|
constructorListStyleDash: listStyle === 'dash',
|
|
41
|
-
} }),
|
|
50
|
+
}, itemProp: FaqMicrodataValues.QuestionTextProp }),
|
|
42
51
|
link && react_1.default.createElement(Link_1.default, Object.assign({}, link, { className: b('link') }))))));
|
|
43
52
|
})))));
|
|
44
53
|
};
|
|
@@ -7,6 +7,7 @@ export interface AnimateBlockProps extends AnimateContextProps {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
onScroll?: () => void;
|
|
10
|
+
qa?: string;
|
|
10
11
|
}
|
|
11
12
|
declare const AnimateBlock: (props: WithChildren<AnimateBlockProps>) => JSX.Element;
|
|
12
13
|
export default AnimateBlock;
|
|
@@ -8,12 +8,12 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
const b = (0, utils_1.block)('AnimateBlock');
|
|
9
9
|
const AnimateBlock = (props) => {
|
|
10
10
|
const { animated } = (0, react_1.useContext)(AnimateContext_1.AnimateContext);
|
|
11
|
-
const { children, className, offset = 100, onScroll, style, animate = animated } = props;
|
|
11
|
+
const { children, className, offset = 100, onScroll, style, animate = animated, qa } = props;
|
|
12
12
|
const [playAnimation, setPlayAnimation] = (0, react_1.useState)(false);
|
|
13
13
|
const divClassName = animate
|
|
14
14
|
? b(null, `${playAnimation && 'animate'} ${className}`)
|
|
15
15
|
: className;
|
|
16
|
-
return (react_1.default.createElement("div", { className: divClassName, style: style },
|
|
16
|
+
return (react_1.default.createElement("div", { className: divClassName, style: style, "data-qa": qa },
|
|
17
17
|
react_1.default.createElement(react_waypoint_1.Waypoint
|
|
18
18
|
// trigger animation if element is above screen
|
|
19
19
|
, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const react_2 = require("@testing-library/react");
|
|
6
|
+
const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
|
|
7
|
+
const AnimateBlock_1 = tslib_1.__importDefault(require("../AnimateBlock"));
|
|
8
|
+
const qaId = 'animate-block';
|
|
9
|
+
describe('AnimateBlock', () => {
|
|
10
|
+
test('render AnimateBlock by default', async () => {
|
|
11
|
+
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId }));
|
|
12
|
+
const component = react_2.screen.getByTestId(qaId);
|
|
13
|
+
expect(component).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
test('add className', () => {
|
|
16
|
+
const className = 'my-class';
|
|
17
|
+
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId, className: className }));
|
|
18
|
+
const component = react_2.screen.getByTestId(qaId);
|
|
19
|
+
expect(component).toHaveClass(className);
|
|
20
|
+
});
|
|
21
|
+
test('use passed style', () => {
|
|
22
|
+
const style = { color: 'red' };
|
|
23
|
+
(0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { style: style, qa: qaId }));
|
|
24
|
+
const component = react_2.screen.getByTestId(qaId);
|
|
25
|
+
expect(component).toHaveStyle(style);
|
|
26
|
+
});
|
|
27
|
+
test('call onScroll', async () => {
|
|
28
|
+
const onScroll = jest.fn();
|
|
29
|
+
const user = user_event_1.default.setup();
|
|
30
|
+
(0, react_2.render)(react_1.default.createElement("div", { style: { paddingTop: 100000 } },
|
|
31
|
+
react_1.default.createElement(AnimateBlock_1.default, { onScroll: onScroll, qa: qaId })));
|
|
32
|
+
const component = react_2.screen.getByTestId(qaId);
|
|
33
|
+
await user.hover(component);
|
|
34
|
+
expect(onScroll).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -5,7 +5,7 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const index_1 = require("../index");
|
|
7
7
|
const b = (0, utils_1.block)('button-tabs');
|
|
8
|
-
const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', }) => {
|
|
8
|
+
const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', qa, }) => {
|
|
9
9
|
const activeTabId = (0, react_1.useMemo)(() => {
|
|
10
10
|
if (activeTab) {
|
|
11
11
|
return activeTab;
|
|
@@ -17,6 +17,6 @@ const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', }
|
|
|
17
17
|
onSelectTab(tabId);
|
|
18
18
|
}
|
|
19
19
|
}, [onSelectTab]);
|
|
20
|
-
return (react_1.default.createElement("div", { className: b(null, className) }, items.map(({ id, title }) => (react_1.default.createElement(index_1.Button, { text: title, className: b('item', { active: id === activeTabId }), key: title, size: tabSize, onClick: () => handleClick(id) })))));
|
|
20
|
+
return (react_1.default.createElement("div", { className: b(null, className), "data-qa": qa }, items.map(({ id, title }) => (react_1.default.createElement(index_1.Button, { text: title, className: b('item', { active: id === activeTabId }), key: title, size: tabSize, onClick: () => handleClick(id) })))));
|
|
21
21
|
};
|
|
22
22
|
exports.default = ButtonTabs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const react_2 = require("@testing-library/react");
|
|
6
|
+
const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
|
|
7
|
+
const ButtonTabs_1 = tslib_1.__importDefault(require("../ButtonTabs"));
|
|
8
|
+
const qaId = 'button-tabs-component';
|
|
9
|
+
const items = [
|
|
10
|
+
{
|
|
11
|
+
id: '0',
|
|
12
|
+
title: 'tab-1',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '1',
|
|
16
|
+
title: 'tab-2',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: '2',
|
|
20
|
+
title: 'tab-3',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
describe('ButtonTabs', () => {
|
|
24
|
+
test('render ButtonTabs by default', async () => {
|
|
25
|
+
(0, react_2.render)(react_1.default.createElement(ButtonTabs_1.default, { items: items, qa: qaId }));
|
|
26
|
+
const buttonTabs = react_2.screen.getByTestId(qaId);
|
|
27
|
+
expect(buttonTabs).toBeInTheDocument();
|
|
28
|
+
expect(buttonTabs).toBeVisible();
|
|
29
|
+
expect(buttonTabs).not.toBeDisabled();
|
|
30
|
+
});
|
|
31
|
+
test('has active tab', async () => {
|
|
32
|
+
const activeTabId = 1;
|
|
33
|
+
(0, react_2.render)(react_1.default.createElement(ButtonTabs_1.default, { items: items, qa: qaId, activeTab: String(activeTabId) }));
|
|
34
|
+
const buttons = react_2.screen.getAllByRole('button');
|
|
35
|
+
buttons.forEach((button, index) => {
|
|
36
|
+
if (index === activeTabId) {
|
|
37
|
+
expect(button).toHaveClass('pc-button-tabs__item_active');
|
|
38
|
+
}
|
|
39
|
+
expect(button).toHaveClass('pc-button-block_theme_normal');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
test('add className', () => {
|
|
43
|
+
const className = 'my-class';
|
|
44
|
+
(0, react_2.render)(react_1.default.createElement(ButtonTabs_1.default, { items: items, qa: qaId, className: className }));
|
|
45
|
+
const buttonTabs = react_2.screen.getByTestId(qaId);
|
|
46
|
+
expect(buttonTabs).toHaveClass(className);
|
|
47
|
+
});
|
|
48
|
+
test('call onSelectTab', async () => {
|
|
49
|
+
const user = user_event_1.default.setup();
|
|
50
|
+
const handleOnClick = jest.fn();
|
|
51
|
+
(0, react_2.render)(react_1.default.createElement(ButtonTabs_1.default, { items: items, qa: qaId, onSelectTab: handleOnClick }));
|
|
52
|
+
const buttons = react_2.screen.getAllByRole('button');
|
|
53
|
+
buttons.forEach(async (button, i) => {
|
|
54
|
+
await user.click(button);
|
|
55
|
+
expect(handleOnClick).toHaveBeenCalledTimes(i + 1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -4,11 +4,13 @@ export interface HTMLProps {
|
|
|
4
4
|
children?: string;
|
|
5
5
|
block?: boolean;
|
|
6
6
|
className?: string;
|
|
7
|
+
itemProp?: string;
|
|
7
8
|
}
|
|
8
|
-
declare const HTML: ({ children, block, className }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
|
+
declare const HTML: ({ children, block, className, itemProp }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
10
|
dangerouslySetInnerHTML: {
|
|
10
11
|
__html: string | (string & React.ReactElement<any, string | React.JSXElementConstructor<any>>) | (string & React.ReactFragment) | (string & React.ReactPortal);
|
|
11
12
|
};
|
|
12
13
|
className: string | undefined;
|
|
14
|
+
itemProp: string | undefined;
|
|
13
15
|
}, HTMLElement> | null;
|
|
14
16
|
export default HTML;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const HTML = ({ children, block = false, className }) => {
|
|
5
|
+
const HTML = ({ children, block = false, className, itemProp }) => {
|
|
6
6
|
if (!children) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
return react_1.default.createElement(block ? 'div' : 'span', {
|
|
10
10
|
dangerouslySetInnerHTML: { __html: children },
|
|
11
11
|
className,
|
|
12
|
+
itemProp,
|
|
12
13
|
});
|
|
13
14
|
};
|
|
14
15
|
exports.default = HTML;
|
|
@@ -3,6 +3,7 @@ export interface YFMWrapperProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
content: string;
|
|
5
5
|
modifiers?: Modifiers;
|
|
6
|
+
itemProp?: string;
|
|
6
7
|
}
|
|
7
|
-
declare const YFMWrapper: ({ content, modifiers, className }: YFMWrapperProps & ClassNameProps) => JSX.Element;
|
|
8
|
+
declare const YFMWrapper: ({ content, modifiers, className, itemProp, }: YFMWrapperProps & ClassNameProps) => JSX.Element;
|
|
8
9
|
export default YFMWrapper;
|
|
@@ -8,5 +8,5 @@ const bem_cn_lite_1 = tslib_1.__importDefault(require("bem-cn-lite"));
|
|
|
8
8
|
const snakecase_keys_1 = tslib_1.__importDefault(require("snakecase-keys"));
|
|
9
9
|
const components_1 = require("../../components");
|
|
10
10
|
const yfm = (0, bem_cn_lite_1.default)('yfm');
|
|
11
|
-
const YFMWrapper = ({ content, modifiers, className }) => (react_1.default.createElement(components_1.HTML, { className: yfm(modifiers ? (0, snakecase_keys_1.default)(modifiers) : {}, className) }, content));
|
|
11
|
+
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (react_1.default.createElement(components_1.HTML, { className: yfm(modifiers ? (0, snakecase_keys_1.default)(modifiers) : {}, className), itemProp: itemProp }, content));
|
|
12
12
|
exports.default = YFMWrapper;
|
|
@@ -6,6 +6,15 @@ import { Content } from '../../sub-blocks';
|
|
|
6
6
|
import { block } from '../../utils';
|
|
7
7
|
import './Questions.css';
|
|
8
8
|
const b = block('QuestionsBlock');
|
|
9
|
+
const FaqMicrodataValues = {
|
|
10
|
+
PageType: 'https://schema.org/FAQPage',
|
|
11
|
+
QuestionType: 'https://schema.org/Question',
|
|
12
|
+
QuestionProp: 'mainEntity',
|
|
13
|
+
QuestionTextProp: 'name',
|
|
14
|
+
AnswerType: 'https://schema.org/Answer',
|
|
15
|
+
AnswerProp: 'acceptedAnswer',
|
|
16
|
+
AnswerTextProp: 'text',
|
|
17
|
+
};
|
|
9
18
|
const QuestionsBlock = (props) => {
|
|
10
19
|
const { title, text, additionalInfo, links, buttons, items } = props;
|
|
11
20
|
const [opened, setOpened] = useState([0]);
|
|
@@ -19,24 +28,24 @@ const QuestionsBlock = (props) => {
|
|
|
19
28
|
}
|
|
20
29
|
setOpened(newState);
|
|
21
30
|
};
|
|
22
|
-
return (React.createElement("div", { className: b() },
|
|
31
|
+
return (React.createElement("div", { className: b(), itemScope: true, itemType: FaqMicrodataValues.PageType },
|
|
23
32
|
React.createElement(Row, null,
|
|
24
33
|
React.createElement(Col, { sizes: { all: 12, md: 4 } },
|
|
25
34
|
React.createElement("div", { className: b('title') },
|
|
26
35
|
React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 } }))),
|
|
27
36
|
React.createElement(Col, { sizes: { all: 12, md: 8 } }, items.map(({ title: itemTitle, text: itemText, link, listStyle = 'dash' }, index) => {
|
|
28
37
|
const isOpened = opened.includes(index);
|
|
29
|
-
return (React.createElement("div", { key: itemTitle, className: b('item') },
|
|
38
|
+
return (React.createElement("div", { key: itemTitle, className: b('item'), itemScope: true, itemProp: FaqMicrodataValues.QuestionProp, itemType: FaqMicrodataValues.QuestionType },
|
|
30
39
|
React.createElement("h4", { className: b('item-title'), onClick: () => toggleItem(index) },
|
|
31
|
-
React.createElement(HTML,
|
|
40
|
+
React.createElement(HTML, { itemProp: FaqMicrodataValues.QuestionTextProp }, itemTitle),
|
|
32
41
|
React.createElement(ToggleArrow, { open: isOpened, size: 16, type: 'vertical', iconType: "navigation", className: b('arrow') })),
|
|
33
42
|
React.createElement(Foldable, { isOpened: isOpened },
|
|
34
|
-
React.createElement("div", { className: b('text') },
|
|
43
|
+
React.createElement("div", { className: b('text'), itemScope: true, itemProp: FaqMicrodataValues.AnswerProp, itemType: FaqMicrodataValues.AnswerType },
|
|
35
44
|
React.createElement(YFMWrapper, { content: itemText, modifiers: {
|
|
36
45
|
constructor: true,
|
|
37
46
|
constructorListStyle: true,
|
|
38
47
|
constructorListStyleDash: listStyle === 'dash',
|
|
39
|
-
} }),
|
|
48
|
+
}, itemProp: FaqMicrodataValues.QuestionTextProp }),
|
|
40
49
|
link && React.createElement(Link, Object.assign({}, link, { className: b('link') }))))));
|
|
41
50
|
})))));
|
|
42
51
|
};
|
|
@@ -7,6 +7,7 @@ export interface AnimateBlockProps extends AnimateContextProps {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
onScroll?: () => void;
|
|
10
|
+
qa?: string;
|
|
10
11
|
}
|
|
11
12
|
declare const AnimateBlock: (props: WithChildren<AnimateBlockProps>) => JSX.Element;
|
|
12
13
|
export default AnimateBlock;
|
|
@@ -5,12 +5,12 @@ import { block } from '../../utils';
|
|
|
5
5
|
const b = block('AnimateBlock');
|
|
6
6
|
const AnimateBlock = (props) => {
|
|
7
7
|
const { animated } = useContext(AnimateContext);
|
|
8
|
-
const { children, className, offset = 100, onScroll, style, animate = animated } = props;
|
|
8
|
+
const { children, className, offset = 100, onScroll, style, animate = animated, qa } = props;
|
|
9
9
|
const [playAnimation, setPlayAnimation] = useState(false);
|
|
10
10
|
const divClassName = animate
|
|
11
11
|
? b(null, `${playAnimation && 'animate'} ${className}`)
|
|
12
12
|
: className;
|
|
13
|
-
return (React.createElement("div", { className: divClassName, style: style },
|
|
13
|
+
return (React.createElement("div", { className: divClassName, style: style, "data-qa": qa },
|
|
14
14
|
React.createElement(Waypoint
|
|
15
15
|
// trigger animation if element is above screen
|
|
16
16
|
, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import AnimateBlock from '../AnimateBlock';
|
|
5
|
+
const qaId = 'animate-block';
|
|
6
|
+
describe('AnimateBlock', () => {
|
|
7
|
+
test('render AnimateBlock by default', async () => {
|
|
8
|
+
render(React.createElement(AnimateBlock, { qa: qaId }));
|
|
9
|
+
const component = screen.getByTestId(qaId);
|
|
10
|
+
expect(component).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
test('add className', () => {
|
|
13
|
+
const className = 'my-class';
|
|
14
|
+
render(React.createElement(AnimateBlock, { qa: qaId, className: className }));
|
|
15
|
+
const component = screen.getByTestId(qaId);
|
|
16
|
+
expect(component).toHaveClass(className);
|
|
17
|
+
});
|
|
18
|
+
test('use passed style', () => {
|
|
19
|
+
const style = { color: 'red' };
|
|
20
|
+
render(React.createElement(AnimateBlock, { style: style, qa: qaId }));
|
|
21
|
+
const component = screen.getByTestId(qaId);
|
|
22
|
+
expect(component).toHaveStyle(style);
|
|
23
|
+
});
|
|
24
|
+
test('call onScroll', async () => {
|
|
25
|
+
const onScroll = jest.fn();
|
|
26
|
+
const user = userEvent.setup();
|
|
27
|
+
render(React.createElement("div", { style: { paddingTop: 100000 } },
|
|
28
|
+
React.createElement(AnimateBlock, { onScroll: onScroll, qa: qaId })));
|
|
29
|
+
const component = screen.getByTestId(qaId);
|
|
30
|
+
await user.hover(component);
|
|
31
|
+
expect(onScroll).toHaveBeenCalledTimes(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -3,7 +3,7 @@ import { block } from '../../utils';
|
|
|
3
3
|
import { Button } from '../index';
|
|
4
4
|
import './ButtonTabs.css';
|
|
5
5
|
const b = block('button-tabs');
|
|
6
|
-
const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', }) => {
|
|
6
|
+
const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', qa, }) => {
|
|
7
7
|
const activeTabId = useMemo(() => {
|
|
8
8
|
if (activeTab) {
|
|
9
9
|
return activeTab;
|
|
@@ -15,6 +15,6 @@ const ButtonTabs = ({ className, items, activeTab, onSelectTab, tabSize = 'l', }
|
|
|
15
15
|
onSelectTab(tabId);
|
|
16
16
|
}
|
|
17
17
|
}, [onSelectTab]);
|
|
18
|
-
return (React.createElement("div", { className: b(null, className) }, items.map(({ id, title }) => (React.createElement(Button, { text: title, className: b('item', { active: id === activeTabId }), key: title, size: tabSize, onClick: () => handleClick(id) })))));
|
|
18
|
+
return (React.createElement("div", { className: b(null, className), "data-qa": qa }, items.map(({ id, title }) => (React.createElement(Button, { text: title, className: b('item', { active: id === activeTabId }), key: title, size: tabSize, onClick: () => handleClick(id) })))));
|
|
19
19
|
};
|
|
20
20
|
export default ButtonTabs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import ButtonTabs from '../ButtonTabs';
|
|
5
|
+
const qaId = 'button-tabs-component';
|
|
6
|
+
const items = [
|
|
7
|
+
{
|
|
8
|
+
id: '0',
|
|
9
|
+
title: 'tab-1',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: '1',
|
|
13
|
+
title: 'tab-2',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: '2',
|
|
17
|
+
title: 'tab-3',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
describe('ButtonTabs', () => {
|
|
21
|
+
test('render ButtonTabs by default', async () => {
|
|
22
|
+
render(React.createElement(ButtonTabs, { items: items, qa: qaId }));
|
|
23
|
+
const buttonTabs = screen.getByTestId(qaId);
|
|
24
|
+
expect(buttonTabs).toBeInTheDocument();
|
|
25
|
+
expect(buttonTabs).toBeVisible();
|
|
26
|
+
expect(buttonTabs).not.toBeDisabled();
|
|
27
|
+
});
|
|
28
|
+
test('has active tab', async () => {
|
|
29
|
+
const activeTabId = 1;
|
|
30
|
+
render(React.createElement(ButtonTabs, { items: items, qa: qaId, activeTab: String(activeTabId) }));
|
|
31
|
+
const buttons = screen.getAllByRole('button');
|
|
32
|
+
buttons.forEach((button, index) => {
|
|
33
|
+
if (index === activeTabId) {
|
|
34
|
+
expect(button).toHaveClass('pc-button-tabs__item_active');
|
|
35
|
+
}
|
|
36
|
+
expect(button).toHaveClass('pc-button-block_theme_normal');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test('add className', () => {
|
|
40
|
+
const className = 'my-class';
|
|
41
|
+
render(React.createElement(ButtonTabs, { items: items, qa: qaId, className: className }));
|
|
42
|
+
const buttonTabs = screen.getByTestId(qaId);
|
|
43
|
+
expect(buttonTabs).toHaveClass(className);
|
|
44
|
+
});
|
|
45
|
+
test('call onSelectTab', async () => {
|
|
46
|
+
const user = userEvent.setup();
|
|
47
|
+
const handleOnClick = jest.fn();
|
|
48
|
+
render(React.createElement(ButtonTabs, { items: items, qa: qaId, onSelectTab: handleOnClick }));
|
|
49
|
+
const buttons = screen.getAllByRole('button');
|
|
50
|
+
buttons.forEach(async (button, i) => {
|
|
51
|
+
await user.click(button);
|
|
52
|
+
expect(handleOnClick).toHaveBeenCalledTimes(i + 1);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -4,11 +4,13 @@ export interface HTMLProps {
|
|
|
4
4
|
children?: string;
|
|
5
5
|
block?: boolean;
|
|
6
6
|
className?: string;
|
|
7
|
+
itemProp?: string;
|
|
7
8
|
}
|
|
8
|
-
declare const HTML: ({ children, block, className }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
|
+
declare const HTML: ({ children, block, className, itemProp }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
10
|
dangerouslySetInnerHTML: {
|
|
10
11
|
__html: string | (string & React.ReactElement<any, string | React.JSXElementConstructor<any>>) | (string & React.ReactFragment) | (string & React.ReactPortal);
|
|
11
12
|
};
|
|
12
13
|
className: string | undefined;
|
|
14
|
+
itemProp: string | undefined;
|
|
13
15
|
}, HTMLElement> | null;
|
|
14
16
|
export default HTML;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
const HTML = ({ children, block = false, className }) => {
|
|
2
|
+
const HTML = ({ children, block = false, className, itemProp }) => {
|
|
3
3
|
if (!children) {
|
|
4
4
|
return null;
|
|
5
5
|
}
|
|
6
6
|
return React.createElement(block ? 'div' : 'span', {
|
|
7
7
|
dangerouslySetInnerHTML: { __html: children },
|
|
8
8
|
className,
|
|
9
|
+
itemProp,
|
|
9
10
|
});
|
|
10
11
|
};
|
|
11
12
|
export default HTML;
|
|
@@ -3,6 +3,7 @@ export interface YFMWrapperProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
content: string;
|
|
5
5
|
modifiers?: Modifiers;
|
|
6
|
+
itemProp?: string;
|
|
6
7
|
}
|
|
7
|
-
declare const YFMWrapper: ({ content, modifiers, className }: YFMWrapperProps & ClassNameProps) => JSX.Element;
|
|
8
|
+
declare const YFMWrapper: ({ content, modifiers, className, itemProp, }: YFMWrapperProps & ClassNameProps) => JSX.Element;
|
|
8
9
|
export default YFMWrapper;
|
|
@@ -5,5 +5,5 @@ import block from 'bem-cn-lite';
|
|
|
5
5
|
import toSnakeCase from 'snakecase-keys';
|
|
6
6
|
import { HTML } from '../../components';
|
|
7
7
|
const yfm = block('yfm');
|
|
8
|
-
const YFMWrapper = ({ content, modifiers, className }) => (React.createElement(HTML, { className: yfm(modifiers ? toSnakeCase(modifiers) : {}, className) }, content));
|
|
8
|
+
const YFMWrapper = ({ content, modifiers, className, itemProp, }) => (React.createElement(HTML, { className: yfm(modifiers ? toSnakeCase(modifiers) : {}, className), itemProp: itemProp }, content));
|
|
9
9
|
export default YFMWrapper;
|