@doyourjob/gravity-ui-page-constructor-addons 2.1.19 → 2.1.20
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/build/cjs/components/HeaderStripe/HeaderStripe.css +25 -0
- package/build/cjs/components/HeaderStripe/HeaderStripe.d.ts +2 -1
- package/build/cjs/components/HeaderStripe/HeaderStripe.js +9 -3
- package/build/cjs/components/HeaderStripe/i18n/en.json +3 -0
- package/build/cjs/components/HeaderStripe/i18n/index.d.ts +2 -0
- package/build/cjs/components/HeaderStripe/i18n/index.js +8 -0
- package/build/cjs/components/HeaderStripe/i18n/ru.json +3 -0
- package/build/esm/components/HeaderStripe/HeaderStripe.css +25 -0
- package/build/esm/components/HeaderStripe/HeaderStripe.d.ts +2 -1
- package/build/esm/components/HeaderStripe/HeaderStripe.js +10 -4
- package/build/esm/components/HeaderStripe/i18n/en.json +3 -0
- package/build/esm/components/HeaderStripe/i18n/index.d.ts +2 -0
- package/build/esm/components/HeaderStripe/i18n/index.js +5 -0
- package/build/esm/components/HeaderStripe/i18n/ru.json +3 -0
- package/package.json +1 -1
|
@@ -23,6 +23,15 @@ unpredictable css rules order in build */
|
|
|
23
23
|
animation: expand-desktop 0.5s ease forwards;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
.pc-addons-header-stripe__root_closing {
|
|
27
|
+
animation: constrict-mobile 0.5s ease forwards;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (min-width: 769px) {
|
|
31
|
+
.pc-addons-header-stripe__root_closing {
|
|
32
|
+
animation: constrict-desktop 0.5s ease forwards;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
.pc-addons-header-stripe__content {
|
|
27
36
|
position: relative;
|
|
28
37
|
display: flex;
|
|
@@ -126,6 +135,14 @@ unpredictable css rules order in build */
|
|
|
126
135
|
max-height: 56px;
|
|
127
136
|
}
|
|
128
137
|
}
|
|
138
|
+
@keyframes constrict-mobile {
|
|
139
|
+
from {
|
|
140
|
+
max-height: 56px;
|
|
141
|
+
}
|
|
142
|
+
to {
|
|
143
|
+
max-height: 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
129
146
|
@keyframes expand-desktop {
|
|
130
147
|
from {
|
|
131
148
|
max-height: 0;
|
|
@@ -133,4 +150,12 @@ unpredictable css rules order in build */
|
|
|
133
150
|
to {
|
|
134
151
|
max-height: 36px;
|
|
135
152
|
}
|
|
153
|
+
}
|
|
154
|
+
@keyframes constrict-desktop {
|
|
155
|
+
from {
|
|
156
|
+
max-height: 36px;
|
|
157
|
+
}
|
|
158
|
+
to {
|
|
159
|
+
max-height: 0;
|
|
160
|
+
}
|
|
136
161
|
}
|
|
@@ -13,7 +13,8 @@ export type HeaderStripeProps = {
|
|
|
13
13
|
items: HeaderStripeItemType[];
|
|
14
14
|
onlyDesktop?: boolean;
|
|
15
15
|
isAbsolute?: boolean;
|
|
16
|
+
canClose?: boolean;
|
|
16
17
|
onClose?: () => void;
|
|
17
18
|
};
|
|
18
|
-
export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, onClose, }: HeaderStripeProps) => React.JSX.Element;
|
|
19
|
+
export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }: HeaderStripeProps) => React.JSX.Element;
|
|
19
20
|
export {};
|
|
@@ -7,6 +7,7 @@ const gravity_ui_page_constructor_1 = require("@doyourjob/gravity-ui-page-constr
|
|
|
7
7
|
const icons_1 = require("@gravity-ui/icons");
|
|
8
8
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
9
9
|
const cn_1 = require("../../utils/cn");
|
|
10
|
+
const i18n_1 = tslib_1.__importDefault(require("./i18n"));
|
|
10
11
|
const b = (0, cn_1.block)('header-stripe');
|
|
11
12
|
const renderItemContent = (item) => {
|
|
12
13
|
if (typeof item === 'string') {
|
|
@@ -19,12 +20,17 @@ const renderItemContent = (item) => {
|
|
|
19
20
|
return item.text;
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroundImage, onlyDesktop, onClose, }) => {
|
|
23
|
+
const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }) => {
|
|
23
24
|
const [activeIndex, setActiveIndex] = (0, react_1.useState)(0);
|
|
25
|
+
const [isClosing, setIsClosing] = (0, react_1.useState)(false);
|
|
24
26
|
const isMobile = (0, uikit_1.useMobile)();
|
|
25
27
|
const filteredItems = (0, react_1.useMemo)(() => isMobile
|
|
26
28
|
? items.filter((item) => (typeof item === 'object' ? !item.onlyDesktop : true))
|
|
27
29
|
: items, [items, isMobile]);
|
|
30
|
+
const handleClose = (0, react_1.useCallback)(() => {
|
|
31
|
+
setIsClosing(true);
|
|
32
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
33
|
+
}, [onClose]);
|
|
28
34
|
(0, react_1.useEffect)(() => {
|
|
29
35
|
if (filteredItems.length > 0) {
|
|
30
36
|
setActiveIndex(0);
|
|
@@ -53,7 +59,7 @@ const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroun
|
|
|
53
59
|
}
|
|
54
60
|
return properties;
|
|
55
61
|
}, [textColor, background, backgroundImage]);
|
|
56
|
-
return (react_1.default.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop }), style: rootStyle },
|
|
62
|
+
return (react_1.default.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop, closing: isClosing }), style: rootStyle },
|
|
57
63
|
react_1.default.createElement(gravity_ui_page_constructor_1.Grid, null,
|
|
58
64
|
react_1.default.createElement(gravity_ui_page_constructor_1.Col, null,
|
|
59
65
|
react_1.default.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }) },
|
|
@@ -70,7 +76,7 @@ const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroun
|
|
|
70
76
|
}) },
|
|
71
77
|
react_1.default.createElement("div", { className: b('item-content') }, renderItemContent(item))));
|
|
72
78
|
}),
|
|
73
|
-
|
|
79
|
+
canClose && (react_1.default.createElement("button", { "aria-label": (0, i18n_1.default)('close'), className: b('close'), onClick: handleClose },
|
|
74
80
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, className: b('close-icon'), size: 16 }))))))));
|
|
75
81
|
};
|
|
76
82
|
exports.HeaderStripe = HeaderStripe;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const registerKeyset_1 = require("../../../utils/registerKeyset");
|
|
5
|
+
const en_json_1 = tslib_1.__importDefault(require("./en.json"));
|
|
6
|
+
const ru_json_1 = tslib_1.__importDefault(require("./ru.json"));
|
|
7
|
+
const COMPONENT = 'HeaderStripe';
|
|
8
|
+
exports.default = (0, registerKeyset_1.registerKeyset)({ en: en_json_1.default, ru: ru_json_1.default }, COMPONENT);
|
|
@@ -23,6 +23,15 @@ unpredictable css rules order in build */
|
|
|
23
23
|
animation: expand-desktop 0.5s ease forwards;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
.pc-addons-header-stripe__root_closing {
|
|
27
|
+
animation: constrict-mobile 0.5s ease forwards;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (min-width: 769px) {
|
|
31
|
+
.pc-addons-header-stripe__root_closing {
|
|
32
|
+
animation: constrict-desktop 0.5s ease forwards;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
.pc-addons-header-stripe__content {
|
|
27
36
|
position: relative;
|
|
28
37
|
display: flex;
|
|
@@ -126,6 +135,14 @@ unpredictable css rules order in build */
|
|
|
126
135
|
max-height: 56px;
|
|
127
136
|
}
|
|
128
137
|
}
|
|
138
|
+
@keyframes constrict-mobile {
|
|
139
|
+
from {
|
|
140
|
+
max-height: 56px;
|
|
141
|
+
}
|
|
142
|
+
to {
|
|
143
|
+
max-height: 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
129
146
|
@keyframes expand-desktop {
|
|
130
147
|
from {
|
|
131
148
|
max-height: 0;
|
|
@@ -133,4 +150,12 @@ unpredictable css rules order in build */
|
|
|
133
150
|
to {
|
|
134
151
|
max-height: 36px;
|
|
135
152
|
}
|
|
153
|
+
}
|
|
154
|
+
@keyframes constrict-desktop {
|
|
155
|
+
from {
|
|
156
|
+
max-height: 36px;
|
|
157
|
+
}
|
|
158
|
+
to {
|
|
159
|
+
max-height: 0;
|
|
160
|
+
}
|
|
136
161
|
}
|
|
@@ -14,7 +14,8 @@ export type HeaderStripeProps = {
|
|
|
14
14
|
items: HeaderStripeItemType[];
|
|
15
15
|
onlyDesktop?: boolean;
|
|
16
16
|
isAbsolute?: boolean;
|
|
17
|
+
canClose?: boolean;
|
|
17
18
|
onClose?: () => void;
|
|
18
19
|
};
|
|
19
|
-
export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, onClose, }: HeaderStripeProps) => React.JSX.Element;
|
|
20
|
+
export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }: HeaderStripeProps) => React.JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { Col, Grid } from '@doyourjob/gravity-ui-page-constructor';
|
|
3
3
|
import { Xmark } from '@gravity-ui/icons';
|
|
4
4
|
import { Icon, useMobile } from '@gravity-ui/uikit';
|
|
5
5
|
import { block } from '../../utils/cn';
|
|
6
|
+
import i18n from './i18n';
|
|
6
7
|
import './HeaderStripe.css';
|
|
7
8
|
const b = block('header-stripe');
|
|
8
9
|
const renderItemContent = (item) => {
|
|
@@ -16,12 +17,17 @@ const renderItemContent = (item) => {
|
|
|
16
17
|
return item.text;
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
|
-
export const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroundImage, onlyDesktop, onClose, }) => {
|
|
20
|
+
export const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }) => {
|
|
20
21
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
22
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
21
23
|
const isMobile = useMobile();
|
|
22
24
|
const filteredItems = useMemo(() => isMobile
|
|
23
25
|
? items.filter((item) => (typeof item === 'object' ? !item.onlyDesktop : true))
|
|
24
26
|
: items, [items, isMobile]);
|
|
27
|
+
const handleClose = useCallback(() => {
|
|
28
|
+
setIsClosing(true);
|
|
29
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
30
|
+
}, [onClose]);
|
|
25
31
|
useEffect(() => {
|
|
26
32
|
if (filteredItems.length > 0) {
|
|
27
33
|
setActiveIndex(0);
|
|
@@ -50,7 +56,7 @@ export const HeaderStripe = ({ duration = 8000, items, textColor, background, ba
|
|
|
50
56
|
}
|
|
51
57
|
return properties;
|
|
52
58
|
}, [textColor, background, backgroundImage]);
|
|
53
|
-
return (React.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop }), style: rootStyle },
|
|
59
|
+
return (React.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop, closing: isClosing }), style: rootStyle },
|
|
54
60
|
React.createElement(Grid, null,
|
|
55
61
|
React.createElement(Col, null,
|
|
56
62
|
React.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }) },
|
|
@@ -67,6 +73,6 @@ export const HeaderStripe = ({ duration = 8000, items, textColor, background, ba
|
|
|
67
73
|
}) },
|
|
68
74
|
React.createElement("div", { className: b('item-content') }, renderItemContent(item))));
|
|
69
75
|
}),
|
|
70
|
-
|
|
76
|
+
canClose && (React.createElement("button", { "aria-label": i18n('close'), className: b('close'), onClick: handleClose },
|
|
71
77
|
React.createElement(Icon, { data: Xmark, className: b('close-icon'), size: 16 }))))))));
|
|
72
78
|
};
|