@doyourjob/gravity-ui-page-constructor-addons 2.1.19 → 2.1.21-dev.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.
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CloseIcon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloseIcon = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const CloseIcon = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true" }, props),
7
+ react_1.default.createElement("path", { d: "M15.5838 14.9948L14.9948 15.5838L0 0.589046L0.589046 0L15.5838 14.9948Z", fill: "currentColor" }),
8
+ react_1.default.createElement("path", { d: "M0.000647411 14.9948L0.589693 15.5838L15.5845 0.589046L14.9954 0L0.000647411 14.9948Z", fill: "currentColor" })));
9
+ exports.CloseIcon = CloseIcon;
@@ -4,7 +4,6 @@ unpredictable css rules order in build */
4
4
  z-index: calc(var(--pc-addons-navigation-popup-z-index) + 1);
5
5
  width: 100%;
6
6
  color: var(--g-color-text-brand-contrast);
7
- background-color: var(--g-color-base-brand);
8
7
  overflow: hidden;
9
8
  animation: expand-mobile 0.5s ease forwards;
10
9
  }
@@ -23,12 +22,22 @@ unpredictable css rules order in build */
23
22
  animation: expand-desktop 0.5s ease forwards;
24
23
  }
25
24
  }
25
+ .pc-addons-header-stripe__root_closing {
26
+ animation: constrict-mobile 0.5s ease forwards;
27
+ }
28
+
29
+ @media (min-width: 769px) {
30
+ .pc-addons-header-stripe__root_closing {
31
+ animation: constrict-desktop 0.5s ease forwards;
32
+ }
33
+ }
26
34
  .pc-addons-header-stripe__content {
27
35
  position: relative;
28
36
  display: flex;
29
37
  overflow: hidden;
30
38
  align-items: center;
31
39
  height: 56px;
40
+ border-radius: 12px;
32
41
  }
33
42
 
34
43
  .pc-addons-header-stripe__content_with-close {
@@ -42,7 +51,7 @@ unpredictable css rules order in build */
42
51
 
43
52
  @media (min-width: 769px) {
44
53
  .pc-addons-header-stripe__content {
45
- height: 36px;
54
+ height: 28px;
46
55
  }
47
56
  }
48
57
  .pc-addons-header-stripe__item {
@@ -103,14 +112,14 @@ unpredictable css rules order in build */
103
112
  position: absolute;
104
113
  top: 0;
105
114
  right: 0;
106
- width: 32px;
115
+ padding: 0 12px;
107
116
  height: 100%;
108
117
  border: none;
109
118
  display: flex;
110
119
  align-items: center;
111
120
  justify-content: center;
112
121
  background: transparent;
113
- color: inherit;
122
+ color: #737373;
114
123
  cursor: pointer;
115
124
  }
116
125
 
@@ -126,11 +135,27 @@ 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;
132
149
  }
133
150
  to {
134
- max-height: 36px;
151
+ max-height: 28px;
152
+ }
153
+ }
154
+ @keyframes constrict-desktop {
155
+ from {
156
+ max-height: 28px;
157
+ }
158
+ to {
159
+ max-height: 0;
135
160
  }
136
161
  }
@@ -4,6 +4,8 @@ type HeaderStripeItemType = {
4
4
  link?: string;
5
5
  target?: string;
6
6
  onlyDesktop?: boolean;
7
+ background?: string;
8
+ textColor?: string;
7
9
  } | string;
8
10
  export type HeaderStripeProps = {
9
11
  duration?: number;
@@ -13,7 +15,8 @@ export type HeaderStripeProps = {
13
15
  items: HeaderStripeItemType[];
14
16
  onlyDesktop?: boolean;
15
17
  isAbsolute?: boolean;
18
+ canClose?: boolean;
16
19
  onClose?: () => void;
17
20
  };
18
- export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, onClose, }: HeaderStripeProps) => React.JSX.Element;
21
+ export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }: HeaderStripeProps) => React.JSX.Element;
19
22
  export {};
@@ -4,9 +4,10 @@ exports.HeaderStripe = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const gravity_ui_page_constructor_1 = require("@doyourjob/gravity-ui-page-constructor");
7
- const icons_1 = require("@gravity-ui/icons");
8
7
  const uikit_1 = require("@gravity-ui/uikit");
9
8
  const cn_1 = require("../../utils/cn");
9
+ const CloseIcon_1 = require("./CloseIcon");
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,10 +59,21 @@ 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
+ const contentStyle = (0, react_1.useMemo)(() => {
63
+ const item = filteredItems[activeIndex];
64
+ const properties = {};
65
+ if (typeof item === 'object' && item.background) {
66
+ properties.background = item.background;
67
+ }
68
+ if (typeof item === 'object' && item.textColor) {
69
+ properties.color = item.textColor;
70
+ }
71
+ return properties;
72
+ }, [filteredItems, activeIndex]);
73
+ return (react_1.default.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop, closing: isClosing }), style: rootStyle },
57
74
  react_1.default.createElement(gravity_ui_page_constructor_1.Grid, null,
58
75
  react_1.default.createElement(gravity_ui_page_constructor_1.Col, null,
59
- react_1.default.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }) },
76
+ react_1.default.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }), style: contentStyle },
60
77
  filteredItems.map((item, index) => {
61
78
  const isActive = index === activeIndex;
62
79
  const isPrev = filteredItems.length > 1 &&
@@ -70,7 +87,7 @@ const HeaderStripe = ({ duration = 8000, items, textColor, background, backgroun
70
87
  }) },
71
88
  react_1.default.createElement("div", { className: b('item-content') }, renderItemContent(item))));
72
89
  }),
73
- onClose && (react_1.default.createElement("button", { className: b('close'), onClick: onClose },
74
- react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, className: b('close-icon'), size: 16 }))))))));
90
+ canClose && (react_1.default.createElement("button", { "aria-label": (0, i18n_1.default)('close'), className: b('close'), onClick: handleClose },
91
+ react_1.default.createElement(uikit_1.Icon, { data: CloseIcon_1.CloseIcon, className: b('close-icon'), size: 16 }))))))));
75
92
  };
76
93
  exports.HeaderStripe = HeaderStripe;
@@ -0,0 +1,3 @@
1
+ {
2
+ "close": "Close"
3
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: (key: string, params?: import("@gravity-ui/i18n").Params | undefined) => string;
2
+ export default _default;
@@ -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);
@@ -0,0 +1,3 @@
1
+ {
2
+ "close": "Закрыть"
3
+ }
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CloseIcon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const CloseIcon = (props) => (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true" }, props),
3
+ React.createElement("path", { d: "M15.5838 14.9948L14.9948 15.5838L0 0.589046L0.589046 0L15.5838 14.9948Z", fill: "currentColor" }),
4
+ React.createElement("path", { d: "M0.000647411 14.9948L0.589693 15.5838L15.5845 0.589046L14.9954 0L0.000647411 14.9948Z", fill: "currentColor" })));
@@ -4,7 +4,6 @@ unpredictable css rules order in build */
4
4
  z-index: calc(var(--pc-addons-navigation-popup-z-index) + 1);
5
5
  width: 100%;
6
6
  color: var(--g-color-text-brand-contrast);
7
- background-color: var(--g-color-base-brand);
8
7
  overflow: hidden;
9
8
  animation: expand-mobile 0.5s ease forwards;
10
9
  }
@@ -23,12 +22,22 @@ unpredictable css rules order in build */
23
22
  animation: expand-desktop 0.5s ease forwards;
24
23
  }
25
24
  }
25
+ .pc-addons-header-stripe__root_closing {
26
+ animation: constrict-mobile 0.5s ease forwards;
27
+ }
28
+
29
+ @media (min-width: 769px) {
30
+ .pc-addons-header-stripe__root_closing {
31
+ animation: constrict-desktop 0.5s ease forwards;
32
+ }
33
+ }
26
34
  .pc-addons-header-stripe__content {
27
35
  position: relative;
28
36
  display: flex;
29
37
  overflow: hidden;
30
38
  align-items: center;
31
39
  height: 56px;
40
+ border-radius: 12px;
32
41
  }
33
42
 
34
43
  .pc-addons-header-stripe__content_with-close {
@@ -42,7 +51,7 @@ unpredictable css rules order in build */
42
51
 
43
52
  @media (min-width: 769px) {
44
53
  .pc-addons-header-stripe__content {
45
- height: 36px;
54
+ height: 28px;
46
55
  }
47
56
  }
48
57
  .pc-addons-header-stripe__item {
@@ -103,14 +112,14 @@ unpredictable css rules order in build */
103
112
  position: absolute;
104
113
  top: 0;
105
114
  right: 0;
106
- width: 32px;
115
+ padding: 0 12px;
107
116
  height: 100%;
108
117
  border: none;
109
118
  display: flex;
110
119
  align-items: center;
111
120
  justify-content: center;
112
121
  background: transparent;
113
- color: inherit;
122
+ color: #737373;
114
123
  cursor: pointer;
115
124
  }
116
125
 
@@ -126,11 +135,27 @@ 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;
132
149
  }
133
150
  to {
134
- max-height: 36px;
151
+ max-height: 28px;
152
+ }
153
+ }
154
+ @keyframes constrict-desktop {
155
+ from {
156
+ max-height: 28px;
157
+ }
158
+ to {
159
+ max-height: 0;
135
160
  }
136
161
  }
@@ -5,6 +5,8 @@ type HeaderStripeItemType = {
5
5
  link?: string;
6
6
  target?: string;
7
7
  onlyDesktop?: boolean;
8
+ background?: string;
9
+ textColor?: string;
8
10
  } | string;
9
11
  export type HeaderStripeProps = {
10
12
  duration?: number;
@@ -14,7 +16,8 @@ export type HeaderStripeProps = {
14
16
  items: HeaderStripeItemType[];
15
17
  onlyDesktop?: boolean;
16
18
  isAbsolute?: boolean;
19
+ canClose?: boolean;
17
20
  onClose?: () => void;
18
21
  };
19
- export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, onClose, }: HeaderStripeProps) => React.JSX.Element;
22
+ export declare const HeaderStripe: ({ duration, items, textColor, background, backgroundImage, onlyDesktop, canClose, onClose, }: HeaderStripeProps) => React.JSX.Element;
20
23
  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
- import { Xmark } from '@gravity-ui/icons';
4
3
  import { Icon, useMobile } from '@gravity-ui/uikit';
5
4
  import { block } from '../../utils/cn';
5
+ import { CloseIcon } from './CloseIcon';
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,10 +56,21 @@ 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
+ const contentStyle = useMemo(() => {
60
+ const item = filteredItems[activeIndex];
61
+ const properties = {};
62
+ if (typeof item === 'object' && item.background) {
63
+ properties.background = item.background;
64
+ }
65
+ if (typeof item === 'object' && item.textColor) {
66
+ properties.color = item.textColor;
67
+ }
68
+ return properties;
69
+ }, [filteredItems, activeIndex]);
70
+ return (React.createElement("div", { className: b('root', { 'only-desktop': onlyDesktop, closing: isClosing }), style: rootStyle },
54
71
  React.createElement(Grid, null,
55
72
  React.createElement(Col, null,
56
- React.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }) },
73
+ React.createElement("div", { className: b('content', { 'with-close': Boolean(onClose) }), style: contentStyle },
57
74
  filteredItems.map((item, index) => {
58
75
  const isActive = index === activeIndex;
59
76
  const isPrev = filteredItems.length > 1 &&
@@ -67,6 +84,6 @@ export const HeaderStripe = ({ duration = 8000, items, textColor, background, ba
67
84
  }) },
68
85
  React.createElement("div", { className: b('item-content') }, renderItemContent(item))));
69
86
  }),
70
- onClose && (React.createElement("button", { className: b('close'), onClick: onClose },
71
- React.createElement(Icon, { data: Xmark, className: b('close-icon'), size: 16 }))))))));
87
+ canClose && (React.createElement("button", { "aria-label": i18n('close'), className: b('close'), onClick: handleClose },
88
+ React.createElement(Icon, { data: CloseIcon, className: b('close-icon'), size: 16 }))))))));
72
89
  };
@@ -0,0 +1,3 @@
1
+ {
2
+ "close": "Close"
3
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: (key: string, params?: import("@gravity-ui/i18n").Params | undefined) => string;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { registerKeyset } from '../../../utils/registerKeyset';
2
+ import en from './en.json';
3
+ import ru from './ru.json';
4
+ const COMPONENT = 'HeaderStripe';
5
+ export default registerKeyset({ en, ru }, COMPONENT);
@@ -0,0 +1,3 @@
1
+ {
2
+ "close": "Закрыть"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor-addons",
3
- "version": "2.1.19",
3
+ "version": "2.1.21-dev.0",
4
4
  "description": "Components and plugins for @doyourjob/gravity-ui-page-constructor",
5
5
  "license": "MIT",
6
6
  "repository": {