@alfalab/core-components-navigation-bar 0.8.7 → 1.0.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.
Files changed (126) hide show
  1. package/Component.d.ts +70 -5
  2. package/Component.js +25 -128
  3. package/components/action-icon-addon/Component.d.ts +22 -0
  4. package/components/action-icon-addon/Component.js +32 -0
  5. package/components/action-icon-addon/index.css +44 -0
  6. package/components/action-icon-addon/index.js +9 -0
  7. package/components/action-text-addon/Component.d.ts +26 -0
  8. package/components/action-text-addon/Component.js +25 -0
  9. package/{cssm/components/closer/index.module.css → components/action-text-addon/index.css} +8 -32
  10. package/components/action-text-addon/index.js +9 -0
  11. package/cssm/Component.d.ts +70 -5
  12. package/cssm/Component.js +24 -127
  13. package/cssm/components/action-icon-addon/Component.d.ts +22 -0
  14. package/cssm/components/action-icon-addon/Component.js +31 -0
  15. package/cssm/components/action-icon-addon/index.js +9 -0
  16. package/{modern/components/closer/index.css → cssm/components/action-icon-addon/index.module.css} +23 -28
  17. package/cssm/components/action-text-addon/Component.d.ts +26 -0
  18. package/cssm/components/action-text-addon/Component.js +24 -0
  19. package/cssm/components/action-text-addon/index.js +9 -0
  20. package/cssm/{vars.css → components/action-text-addon/index.module.css} +6 -4
  21. package/cssm/index.d.ts +0 -1
  22. package/cssm/index.module.css +45 -75
  23. package/cssm/shared/index.d.ts +3 -2
  24. package/cssm/shared/index.js +6 -4
  25. package/cssm/utils.d.ts +6 -0
  26. package/cssm/utils.js +15 -0
  27. package/esm/Component.d.ts +70 -5
  28. package/esm/Component.js +26 -128
  29. package/esm/components/action-icon-addon/Component.d.ts +22 -0
  30. package/esm/components/action-icon-addon/Component.js +23 -0
  31. package/esm/components/action-icon-addon/index.css +44 -0
  32. package/esm/components/action-icon-addon/index.js +1 -0
  33. package/esm/components/action-text-addon/Component.d.ts +26 -0
  34. package/esm/components/action-text-addon/Component.js +16 -0
  35. package/esm/components/{closer → action-text-addon}/index.css +8 -33
  36. package/esm/components/action-text-addon/index.js +1 -0
  37. package/esm/index.css +48 -77
  38. package/esm/index.d.ts +0 -1
  39. package/esm/shared/index.d.ts +3 -2
  40. package/esm/shared/index.js +3 -2
  41. package/esm/utils.d.ts +6 -0
  42. package/esm/utils.js +11 -0
  43. package/index.css +48 -77
  44. package/index.d.ts +0 -1
  45. package/modern/Component.d.ts +70 -5
  46. package/modern/Component.js +26 -133
  47. package/modern/components/action-icon-addon/Component.d.ts +22 -0
  48. package/modern/components/action-icon-addon/Component.js +18 -0
  49. package/modern/components/action-icon-addon/index.css +44 -0
  50. package/modern/components/action-icon-addon/index.js +1 -0
  51. package/modern/components/action-text-addon/Component.d.ts +26 -0
  52. package/modern/components/action-text-addon/Component.js +12 -0
  53. package/{components/closer → modern/components/action-text-addon}/index.css +8 -33
  54. package/modern/components/action-text-addon/index.js +1 -0
  55. package/modern/index.css +48 -77
  56. package/modern/index.d.ts +0 -1
  57. package/modern/shared/index.d.ts +3 -2
  58. package/modern/shared/index.js +3 -2
  59. package/modern/utils.d.ts +6 -0
  60. package/modern/utils.js +11 -0
  61. package/package.json +5 -8
  62. package/shared/index.d.ts +3 -2
  63. package/shared/index.js +6 -4
  64. package/src/Component.tsx +183 -264
  65. package/src/components/action-icon-addon/Component.tsx +58 -0
  66. package/src/components/action-icon-addon/index.module.css +40 -0
  67. package/src/components/action-text-addon/Component.tsx +61 -0
  68. package/src/components/action-text-addon/index.module.css +9 -0
  69. package/src/index.module.css +39 -79
  70. package/src/index.ts +0 -1
  71. package/src/shared/index.ts +3 -2
  72. package/src/utils.ts +9 -0
  73. package/utils.d.ts +6 -0
  74. package/utils.js +15 -0
  75. package/components/back-arrow-addon/Component.d.ts +0 -26
  76. package/components/back-arrow-addon/Component.js +0 -35
  77. package/components/back-arrow-addon/index.css +0 -76
  78. package/components/back-arrow-addon/index.js +0 -9
  79. package/components/closer/Component.d.ts +0 -35
  80. package/components/closer/Component.js +0 -32
  81. package/components/closer/index.js +0 -9
  82. package/cssm/components/back-arrow-addon/Component.d.ts +0 -26
  83. package/cssm/components/back-arrow-addon/Component.js +0 -34
  84. package/cssm/components/back-arrow-addon/index.js +0 -9
  85. package/cssm/components/back-arrow-addon/index.module.css +0 -75
  86. package/cssm/components/closer/Component.d.ts +0 -35
  87. package/cssm/components/closer/Component.js +0 -31
  88. package/cssm/components/closer/index.js +0 -9
  89. package/cssm/types.d.ts +0 -118
  90. package/cssm/types.js +0 -2
  91. package/esm/components/back-arrow-addon/Component.d.ts +0 -26
  92. package/esm/components/back-arrow-addon/Component.js +0 -26
  93. package/esm/components/back-arrow-addon/index.css +0 -76
  94. package/esm/components/back-arrow-addon/index.js +0 -1
  95. package/esm/components/closer/Component.d.ts +0 -35
  96. package/esm/components/closer/Component.js +0 -23
  97. package/esm/components/closer/index.js +0 -1
  98. package/esm/types.d.ts +0 -118
  99. package/esm/types.js +0 -1
  100. package/modern/components/back-arrow-addon/Component.d.ts +0 -26
  101. package/modern/components/back-arrow-addon/Component.js +0 -23
  102. package/modern/components/back-arrow-addon/index.css +0 -76
  103. package/modern/components/back-arrow-addon/index.js +0 -1
  104. package/modern/components/closer/Component.d.ts +0 -35
  105. package/modern/components/closer/Component.js +0 -20
  106. package/modern/components/closer/index.js +0 -1
  107. package/modern/types.d.ts +0 -118
  108. package/modern/types.js +0 -1
  109. package/src/components/back-arrow-addon/Component.tsx +0 -79
  110. package/src/components/back-arrow-addon/index.module.css +0 -69
  111. package/src/components/closer/Component.tsx +0 -80
  112. package/src/components/closer/index.module.css +0 -32
  113. package/src/types.ts +0 -143
  114. package/src/vars.css +0 -9
  115. package/types.d.ts +0 -118
  116. package/types.js +0 -2
  117. /package/components/{back-arrow-addon → action-icon-addon}/index.d.ts +0 -0
  118. /package/components/{closer → action-text-addon}/index.d.ts +0 -0
  119. /package/cssm/components/{back-arrow-addon → action-icon-addon}/index.d.ts +0 -0
  120. /package/cssm/components/{closer → action-text-addon}/index.d.ts +0 -0
  121. /package/esm/components/{back-arrow-addon → action-icon-addon}/index.d.ts +0 -0
  122. /package/esm/components/{closer → action-text-addon}/index.d.ts +0 -0
  123. /package/modern/components/{back-arrow-addon → action-icon-addon}/index.d.ts +0 -0
  124. /package/modern/components/{closer → action-text-addon}/index.d.ts +0 -0
  125. /package/src/components/{back-arrow-addon → action-icon-addon}/index.ts +0 -0
  126. /package/src/components/{closer → action-text-addon}/index.ts +0 -0
@@ -1,2 +1,3 @@
1
- export { Closer } from '../components/closer/Component.js';
2
- export { BackArrowAddon } from '../components/back-arrow-addon/Component.js';
1
+ export { ActionIconAddon } from '../components/action-icon-addon/Component.js';
2
+ export { ActionTextAddon } from '../components/action-text-addon/Component.js';
3
+ export { getNavigationBarTestIds } from '../utils.js';
package/esm/utils.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ declare function getNavigationBarTestIds(dataTestId: string): {
2
+ navigationBar: string;
3
+ title: string;
4
+ subtitle: string;
5
+ };
6
+ export { getNavigationBarTestIds };
package/esm/utils.js ADDED
@@ -0,0 +1,11 @@
1
+ import { getDataTestId } from '@alfalab/core-components-shared/esm';
2
+
3
+ function getNavigationBarTestIds(dataTestId) {
4
+ return {
5
+ navigationBar: dataTestId,
6
+ title: getDataTestId(dataTestId, 'title'),
7
+ subtitle: getDataTestId(dataTestId, 'subtitle'),
8
+ };
9
+ }
10
+
11
+ export { getNavigationBarTestIds };
package/index.css CHANGED
@@ -1,6 +1,7 @@
1
- /* hash: 1q9r9 */
1
+ /* hash: enrea */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
+ --color-light-neutral-300: #e7e8eb;
4
5
  --color-light-text-primary: rgba(3, 3, 6, 0.88);
5
6
  --color-light-text-secondary: rgba(4, 4, 19, 0.55); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
7
  } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -15,94 +16,64 @@
15
16
  } :root {
16
17
  } :root {
17
18
  --gap-2xs: 4px;
18
- --gap-s: 12px;
19
+ --gap-xs: 8px;
20
+ --gap-m: 16px;
19
21
  } :root {
20
22
  } :root {
21
- } .navigation-bar__header_1ioua {
22
- width: 100%;
23
+ } .navigation-bar__component_chxq7 {
24
+ padding: var(--gap-xs) var(--gap-2xs);
23
25
  box-sizing: border-box;
24
- transition: box-shadow 0.2s ease, background 0.2s ease
25
- } .navigation-bar__header_1ioua.navigation-bar__header_1ioua.navigation-bar__backgroundImage_1ioua {
26
- background-repeat: no-repeat;
27
- background-position: center;
28
- background-size: cover;
29
- } .navigation-bar__mainLine_1ioua {
30
- display: flex;
31
- align-items: stretch;
32
- justify-content: space-between;
33
- z-index: 1;
34
- background-color: inherit;
35
- } .navigation-bar__mainLineSticky_1ioua {
26
+ width: 100%;
27
+ } .navigation-bar__sticky_chxq7 {
36
28
  position: sticky;
37
29
  top: 0;
38
- } .navigation-bar__mainLineWithImageBg_1ioua {
39
- background-color: initial;
40
- } .navigation-bar__content_1ioua {
41
- color: var(--color-light-text-primary);
30
+ z-index: 1;
31
+ } .navigation-bar__border_chxq7 {
32
+ box-shadow: 0 1px 0 0 var(--color-light-neutral-300);
33
+ } .navigation-bar__mainLine_chxq7 {
34
+ display: flex;
35
+ background-color: inherit;
36
+ justify-content: space-between;
37
+ min-height: 40px;
38
+ align-items: stretch;
39
+ } .navigation-bar__left_chxq7 {
40
+ text-align: left;
41
+ } .navigation-bar__center_chxq7 {
42
+ text-align: center;
43
+ } .navigation-bar__children_chxq7 {
44
+ width: 100%;
45
+ } .navigation-bar__content_chxq7 {
42
46
  display: flex;
43
- flex-flow: column nowrap;
44
- justify-content: center;
45
47
  flex-grow: 1;
46
- align-self: baseline;
47
- box-sizing: border-box;
48
- min-height: 48px
49
- } .navigation-bar__content_1ioua.navigation-bar__withBothAddons_1ioua,
50
- .navigation-bar__content_1ioua.navigation-bar__withCompactTitle_1ioua {
51
- font-size: 16px;
52
- line-height: 20px;
53
- font-weight: 500;
54
- align-self: center;
55
- padding-top: var(--gap-2xs);
56
- padding-bottom: var(--gap-2xs)
57
- } .navigation-bar__content_1ioua.navigation-bar__withBothAddons_1ioua > .navigation-bar__children_1ioua,
58
- .navigation-bar__content_1ioua.navigation-bar__withBothAddons_1ioua > .navigation-bar__title_1ioua,
59
- .navigation-bar__content_1ioua.navigation-bar__withCompactTitle_1ioua > .navigation-bar__children_1ioua,
60
- .navigation-bar__content_1ioua.navigation-bar__withCompactTitle_1ioua > .navigation-bar__title_1ioua {
61
- -webkit-line-clamp: 1;
62
- word-break: break-all;
63
- } .navigation-bar__content_1ioua.navigation-bar__contentOnBotDesktop_1ioua.navigation-bar__contentOnBotDesktop_1ioua {
64
- padding-top: var(--gap-s);
65
- } .navigation-bar__content_1ioua.navigation-bar__contentOnBotMobile_1ioua.navigation-bar__contentOnBotMobile_1ioua {
66
- padding-top: var(--gap-s);
67
- } .navigation-bar__title_1ioua {
68
- word-break: break-word;
69
- } .navigation-bar__subtitle_1ioua {
48
+ justify-content: center;
49
+ flex-flow: column nowrap;
50
+ color: var(--color-light-text-primary)
51
+ } .navigation-bar__content_chxq7.navigation-bar__left_chxq7 {
52
+ padding: 0 var(--gap-m);
53
+ } .navigation-bar__content_chxq7 > .navigation-bar__title_chxq7,
54
+ .navigation-bar__content_chxq7 > .navigation-bar__subtitle_chxq7 {
55
+ -webkit-line-clamp: 1;
56
+ display: -webkit-box;
57
+ -webkit-box-orient: vertical;
58
+ overflow: hidden;
59
+ word-break: break-all;
60
+ } .navigation-bar__title_chxq7 {
61
+ font-size: 16px;
62
+ line-height: 20px;
63
+ font-weight: 500
64
+ } .navigation-bar__title_chxq7.navigation-bar__left_chxq7 {
65
+ font-size: 20px;
66
+ line-height: 28px;
67
+ font-weight: 600;
68
+ } .navigation-bar__subtitle_chxq7 {
70
69
  font-size: 14px;
71
70
  line-height: 20px;
72
71
  font-weight: 400;
73
- -webkit-line-clamp: 1;
74
- display: -webkit-box;
75
- -webkit-box-orient: vertical;
76
- overflow: hidden;
77
-
78
72
  color: var(--color-light-text-secondary);
79
- word-break: break-all;
80
- } .navigation-bar__addonsWrapper_1ioua {
81
- display: flex;
82
- } .navigation-bar__rightAddons_1ioua {
83
- margin-left: auto;
84
- } .navigation-bar__addon_1ioua {
73
+ } .navigation-bar__addons_chxq7 {
85
74
  min-width: 48px;
86
- height: 48px;
87
75
  display: flex;
88
76
  justify-content: center;
89
- align-items: center;
90
- flex-shrink: 0;
91
- pointer-events: all;
92
- } .navigation-bar__bottomAddons_1ioua {
93
- pointer-events: all;
94
- } .navigation-bar__closer_1ioua {
77
+ } .navigation-bar__rightAddons_chxq7 {
95
78
  margin-left: auto;
96
- } .navigation-bar__left_1ioua {
97
- text-align: left;
98
- } .navigation-bar__center_1ioua {
99
- text-align: center;
100
- } .navigation-bar__trim_1ioua {
101
- overflow: hidden
102
- } .navigation-bar__trim_1ioua .navigation-bar__title_1ioua,
103
- .navigation-bar__trim_1ioua .navigation-bar__children_1ioua {
104
- -webkit-line-clamp: 2;
105
- display: -webkit-box;
106
- -webkit-box-orient: vertical;
107
- overflow: hidden;
108
- }
79
+ }
package/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from "./Component";
2
- export type { NavigationBarProps } from "./types";
@@ -1,5 +1,70 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { NavigationBarProps } from "./types";
4
- declare const NavigationBar: React.ForwardRefExoticComponent<NavigationBarProps & React.RefAttributes<HTMLDivElement>>;
5
- export { NavigationBar };
1
+ import { FC, ReactNode } from 'react';
2
+ interface NavigationBarProps {
3
+ /**
4
+ * Заголовок
5
+ */
6
+ title?: string;
7
+ /**
8
+ * Подзаголовок
9
+ */
10
+ subtitle?: string;
11
+ /**
12
+ * Контент шапки
13
+ */
14
+ children?: ReactNode;
15
+ /**
16
+ * Выравнивание заголовка
17
+ * @default center
18
+ */
19
+ align?: 'left' | 'center';
20
+ /**
21
+ * Цвет фона
22
+ */
23
+ backgroundColor?: string;
24
+ /**
25
+ * Наличие бордера
26
+ */
27
+ border?: boolean;
28
+ /**
29
+ * Фиксирует шапку
30
+ */
31
+ sticky?: boolean;
32
+ /**
33
+ * Слот снизу
34
+ */
35
+ bottomAddons?: ReactNode;
36
+ /**
37
+ * Слот слева
38
+ */
39
+ leftAddons?: ReactNode;
40
+ /**
41
+ * Слот справа
42
+ */
43
+ rightAddons?: ReactNode;
44
+ /**
45
+ * Дополнительный класс для контента
46
+ */
47
+ contentClassName?: string;
48
+ /**
49
+ * Дополнительный класс
50
+ */
51
+ className?: string;
52
+ /**
53
+ * Дополнительный класс для правого аддона
54
+ */
55
+ rightAddonsClassName?: string;
56
+ /**
57
+ * Дополнительный класс для левого аддона
58
+ */
59
+ leftAddonsClassName?: string;
60
+ /**
61
+ * Дополнительный класс для нижнего аддона
62
+ */
63
+ bottomAddonsClassName?: string;
64
+ /**
65
+ * Идентификатор для систем автоматизированного тестирования.
66
+ */
67
+ dataTestId?: string;
68
+ }
69
+ declare const NavigationBar: FC<NavigationBarProps>;
70
+ export { NavigationBarProps, NavigationBar };
@@ -1,38 +1,17 @@
1
- import React, { forwardRef, useState, useRef, useEffect } from 'react';
2
- import mergeRefs from 'react-merge-refs';
1
+ import React, { useState, useRef, useEffect } from 'react';
3
2
  import cn from 'classnames';
4
3
  import { getDataTestId } from '@alfalab/core-components-shared/modern';
5
- import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
6
- import { BackArrowAddon } from './components/back-arrow-addon/Component.js';
7
- import { Closer } from './components/closer/Component.js';
8
4
 
9
- const styles = {"header":"navigation-bar__header_1ioua","backgroundImage":"navigation-bar__backgroundImage_1ioua","mainLine":"navigation-bar__mainLine_1ioua","mainLineSticky":"navigation-bar__mainLineSticky_1ioua","mainLineWithImageBg":"navigation-bar__mainLineWithImageBg_1ioua","content":"navigation-bar__content_1ioua","withBothAddons":"navigation-bar__withBothAddons_1ioua","withCompactTitle":"navigation-bar__withCompactTitle_1ioua","children":"navigation-bar__children_1ioua","title":"navigation-bar__title_1ioua","contentOnBotDesktop":"navigation-bar__contentOnBotDesktop_1ioua","contentOnBotMobile":"navigation-bar__contentOnBotMobile_1ioua","subtitle":"navigation-bar__subtitle_1ioua","addonsWrapper":"navigation-bar__addonsWrapper_1ioua","rightAddons":"navigation-bar__rightAddons_1ioua","addon":"navigation-bar__addon_1ioua","bottomAddons":"navigation-bar__bottomAddons_1ioua","closer":"navigation-bar__closer_1ioua","left":"navigation-bar__left_1ioua","center":"navigation-bar__center_1ioua","trim":"navigation-bar__trim_1ioua"};
5
+ const styles = {"component":"navigation-bar__component_chxq7","sticky":"navigation-bar__sticky_chxq7","border":"navigation-bar__border_chxq7","mainLine":"navigation-bar__mainLine_chxq7","left":"navigation-bar__left_chxq7","center":"navigation-bar__center_chxq7","children":"navigation-bar__children_chxq7","content":"navigation-bar__content_chxq7","title":"navigation-bar__title_chxq7","subtitle":"navigation-bar__subtitle_chxq7","addons":"navigation-bar__addons_chxq7","rightAddons":"navigation-bar__rightAddons_chxq7"};
10
6
  require('./index.css')
11
7
 
12
- /* eslint-disable complexity */
13
- const ADDONS_HEIGHT = 48;
14
- const NavigationBar = forwardRef(({ addonClassName, className, contentClassName, closerClassName, leftAddons, rightAddons, bottomAddons, bottomAddonsClassName, children, align = 'left', trim = true, title, titleSize = 'default', subtitle, hasCloser, hasBackButton, backButtonClassName, backButtonProps, dataTestId, imageUrl, closerIcon, onClose, view, scrollableParentRef, sticky, onBack, }, ref) => {
15
- const [scrollTop, setScrollTop] = useState(0);
8
+ const NavigationBar = ({ align = 'center', rightAddons, leftAddons, bottomAddons, sticky, border, subtitle, title, children, backgroundColor = 'var(--color-light-base-bg-primary)', className, contentClassName, rightAddonsClassName, leftAddonsClassName, bottomAddonsClassName, dataTestId, }) => {
16
9
  const [titleMargin, setTitleMargin] = useState({ left: 0, right: 0 });
17
- const bottomContentRef = useRef(null);
18
- const headerRef = useRef(null);
19
- const mainLinePaddingTopRef = useRef('0px');
20
10
  const leftAddonsRef = useRef(null);
21
11
  const rightAddonsRef = useRef(null);
22
- const compactTitle = view === 'mobile' && titleSize === 'compact';
23
- const hasLeftPart = Boolean(leftAddons || hasBackButton);
24
- const hasRightPart = Boolean(rightAddons || hasCloser);
25
- const hasContent = Boolean(title || children);
26
- const withAnimation = Boolean(view === 'mobile' && hasLeftPart && sticky && !compactTitle);
27
- const showContentOnTop = hasContent && (compactTitle || !hasLeftPart);
28
- const showContentOnBot = hasContent && !compactTitle && hasLeftPart;
29
- const showStaticContentOnTop = !withAnimation && showContentOnTop;
30
- const showStaticContentOnBot = !withAnimation && showContentOnBot;
31
- const showAnimatedContentOnTop = withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
32
- const showAnimatedContentOnBot = withAnimation && showContentOnBot;
33
- const headerPaddingTop = mainLinePaddingTopRef.current;
34
- useLayoutEffect_SAFE_FOR_SSR(() => {
35
- if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
12
+ const hasLeftAddons = leftAddons && align !== 'left';
13
+ useEffect(() => {
14
+ if (hasLeftAddons) {
36
15
  const leftAddonsWidth = leftAddonsRef.current?.offsetWidth || 0;
37
16
  const rightAddonsWidth = rightAddonsRef.current?.offsetWidth || 0;
38
17
  const marginSize = Math.abs(rightAddonsWidth - leftAddonsWidth);
@@ -45,116 +24,30 @@ const NavigationBar = forwardRef(({ addonClassName, className, contentClassName,
45
24
  return isStateChanged ? newState : prev;
46
25
  });
47
26
  }
48
- }, [
49
- align,
50
- showStaticContentOnTop,
51
- showAnimatedContentOnTop,
52
- leftAddons,
53
- rightAddons,
54
- hasBackButton,
55
- hasCloser,
56
- ]);
57
- useEffect(() => {
58
- const parent = scrollableParentRef?.current;
59
- const handleScroll = (ev) => {
60
- const divElement = ev.target;
61
- setScrollTop(divElement.scrollTop);
62
- };
63
- if (withAnimation && headerRef.current) {
64
- mainLinePaddingTopRef.current = getComputedStyle(headerRef.current).paddingTop;
65
- }
66
- if (withAnimation && parent) {
67
- parent.addEventListener('scroll', handleScroll);
68
- }
69
- return () => parent?.removeEventListener('scroll', handleScroll);
70
- }, [scrollableParentRef, withAnimation]);
71
- const renderBackButton = () => {
72
- let textOpacity = 1;
73
- if (withAnimation) {
74
- const height = hasContent ? ADDONS_HEIGHT : ADDONS_HEIGHT / 2;
75
- textOpacity = Math.max(0, 1 - scrollTop / height);
76
- }
77
- else if (compactTitle) {
78
- textOpacity = 0;
79
- }
80
- return (React.createElement("div", { className: cn(styles.addon, backButtonClassName) },
81
- React.createElement(BackArrowAddon, { "data-test-id": getDataTestId(dataTestId, 'back-button'), ...backButtonProps, textOpacity: textOpacity, view: view, onClick: onBack })));
82
- };
83
- const renderContent = (args = {}) => {
84
- const { extraClassName, wrapperRef, style, hidden } = args;
85
- return (React.createElement("div", { style: { ...style, visibility: hidden ? 'hidden' : 'visible' }, ref: wrapperRef, className: cn(styles.content, extraClassName, contentClassName, styles[align], {
86
- [styles.trim]: trim,
87
- [styles.withCompactTitle]: view === 'mobile' && compactTitle && hasContent,
88
- }), "aria-hidden": hidden },
27
+ }, [hasLeftAddons, leftAddons, rightAddons]);
28
+ return (React.createElement("div", { className: cn(styles.component, {
29
+ [styles.border]: border,
30
+ [styles.sticky]: sticky,
31
+ }, className), style: {
32
+ ...(backgroundColor && { backgroundColor }),
33
+ }, "data-test-id": dataTestId },
34
+ React.createElement("div", { className: cn(styles.mainLine, styles[align], contentClassName) },
35
+ hasLeftAddons && (React.createElement("div", { className: cn(styles.addons, leftAddonsClassName), ref: leftAddonsRef }, leftAddons)),
89
36
  children && React.createElement("div", { className: styles.children }, children),
90
- title && (React.createElement("div", { className: styles.title, "data-test-id": hidden ? undefined : getDataTestId(dataTestId, 'title') }, title)),
91
- compactTitle && subtitle && React.createElement("div", { className: styles.subtitle }, subtitle)));
92
- };
93
- const renderCloser = () => (React.createElement("div", { className: cn(styles.addon, styles.closer, closerClassName) },
94
- React.createElement(Closer, { view: view, icon: closerIcon, dataTestId: getDataTestId(dataTestId, 'closer'), onClose: onClose })));
95
- return (React.createElement("div", { ref: mergeRefs([ref, headerRef]), className: cn(styles.header, className, { [styles.backgroundImage]: imageUrl }), "data-test-id": getDataTestId(dataTestId), style: {
96
- ...(imageUrl && { backgroundImage: `url(${imageUrl})` }),
97
- ...(withAnimation &&
98
- bottomContentRef.current && {
99
- top: -bottomContentRef.current.scrollHeight,
100
- }),
101
- } },
102
- React.createElement("div", { className: cn(styles.mainLine, {
103
- [styles.mainLineSticky]: withAnimation,
104
- [styles.mainLineWithImageBg]: imageUrl,
105
- }), style: {
106
- ...(withAnimation
107
- ? {
108
- marginTop: `-${headerPaddingTop}`,
109
- paddingTop: headerPaddingTop,
110
- }
111
- : null),
112
- } },
113
- hasLeftPart && (React.createElement("div", { className: styles.addonsWrapper, ref: leftAddonsRef },
114
- hasBackButton && renderBackButton(),
115
- leftAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, leftAddons)))),
116
- showStaticContentOnTop &&
117
- renderContent({
37
+ title && (React.createElement("div", { className: cn(styles.content, { [styles[align]]: !hasLeftAddons }), style: {
118
38
  ...(align === 'center'
119
39
  ? {
120
- style: {
121
- marginLeft: titleMargin.left,
122
- marginRight: titleMargin.right,
123
- },
40
+ marginLeft: titleMargin.left,
41
+ marginRight: titleMargin.right,
124
42
  }
125
43
  : null),
126
- }),
127
- showAnimatedContentOnTop &&
128
- renderContent({
129
- extraClassName: styles.withBothAddons,
130
- style: {
131
- opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT),
132
- ...(align === 'center'
133
- ? {
134
- marginLeft: titleMargin.left,
135
- marginRight: titleMargin.right,
136
- }
137
- : null),
138
- },
139
- }),
140
- hasRightPart && (React.createElement("div", { className: cn(styles.addonsWrapper, styles.rightAddons), ref: rightAddonsRef },
141
- rightAddons && (React.createElement("div", { className: cn(styles.addon, addonClassName) }, rightAddons)),
142
- hasCloser && renderCloser()))),
143
- showAnimatedContentOnBot &&
144
- renderContent({
145
- wrapperRef: bottomContentRef,
146
- extraClassName: styles.underAddons,
147
- style: { opacity: Math.max(0, 1 - scrollTop / ADDONS_HEIGHT) },
148
- hidden: scrollTop / ADDONS_HEIGHT > 1,
149
- }),
150
- showStaticContentOnBot &&
151
- renderContent({
152
- extraClassName: cn({
153
- [styles.contentOnBotDesktop]: view === 'desktop',
154
- [styles.contentOnBotMobile]: view === 'mobile',
155
- }),
156
- }),
157
- bottomAddons && (React.createElement("div", { className: cn(styles.bottomAddons, bottomAddonsClassName) }, bottomAddons))));
158
- });
44
+ } },
45
+ React.createElement("div", { className: cn(styles.title, {
46
+ [styles[align]]: !hasLeftAddons && !subtitle,
47
+ }), "data-test-id": getDataTestId(dataTestId, 'title') }, title),
48
+ subtitle && (React.createElement("div", { className: styles.subtitle, "data-test-id": getDataTestId(dataTestId, 'subtitle') }, subtitle)))),
49
+ rightAddons && (React.createElement("div", { className: cn(styles.rightAddons, styles.addons, rightAddonsClassName), ref: rightAddonsRef }, rightAddons))),
50
+ bottomAddons && React.createElement("div", { className: bottomAddonsClassName }, bottomAddons)));
51
+ };
159
52
 
160
53
  export { NavigationBar };
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ interface ActionIconAddonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * Тип действия
6
+ */
7
+ action?: 'back' | 'floatingBack' | 'close';
8
+ /**
9
+ * Дополнительный класс
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Обработчик клика
14
+ */
15
+ onClick?: () => void;
16
+ /**
17
+ * Идентификатор для систем автоматизированного тестирования.
18
+ */
19
+ dataTestId?: string;
20
+ }
21
+ declare const ActionIconAddon: React.FC<ActionIconAddonProps>;
22
+ export { ActionIconAddonProps, ActionIconAddon };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { ButtonDesktop } from '@alfalab/core-components-button/modern/desktop';
4
+ import { ChevronLeftMIcon } from '@alfalab/icons-glyph/ChevronLeftMIcon';
5
+ import { CrossMIcon } from '@alfalab/icons-glyph/CrossMIcon';
6
+
7
+ const styles = {"component":"navigation-bar__component_1ngip","iconWrapper":"navigation-bar__iconWrapper_1ngip","back":"navigation-bar__back_1ngip","floating":"navigation-bar__floating_1ngip"};
8
+ require('./index.css')
9
+
10
+ const iconComponents = {
11
+ back: React.createElement(ChevronLeftMIcon, null),
12
+ floatingBack: React.createElement(ChevronLeftMIcon, { className: styles.floating }),
13
+ close: React.createElement(CrossMIcon, { className: styles.floating }),
14
+ };
15
+ const ActionIconAddon = ({ onClick, className, action = 'back', dataTestId, ...htmlAttributes }) => (React.createElement(ButtonDesktop, { view: 'text', size: 's', onClick: onClick, "aria-label": action === 'close' ? 'закрыть' : 'назад', className: cn(styles.component, className), dataTestId: dataTestId, ...htmlAttributes },
16
+ React.createElement("div", { className: cn(styles.iconWrapper, { [styles[action]]: Boolean(styles[action]) }) }, iconComponents[action])));
17
+
18
+ export { ActionIconAddon };
@@ -0,0 +1,44 @@
1
+ /* hash: aan4f */
2
+ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
+ } /* deprecated */ :root {
4
+ --color-light-neutral-translucent-100: rgba(38, 55, 88, 0.06);
5
+ --color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47);
6
+ --color-light-neutral-translucent-700-hover: rgba(4, 4, 19, 0.55);
7
+ --color-light-neutral-translucent-700-press: rgba(1, 1, 12, 0.63); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
8
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
9
+ } :root {
10
+ } :root {
11
+
12
+ /* Hard */
13
+
14
+ /* Up */
15
+
16
+ /* Hard up */
17
+ } :root {
18
+ --border-radius-circle: 50%;
19
+ --border-radius-pill: 99px;
20
+ } :root {
21
+ } :root {
22
+ } :root {
23
+ } .navigation-bar__component_1ngip {
24
+ height: 100%;
25
+ border-radius: var(--border-radius-pill);
26
+ min-width: 48px;
27
+ } .navigation-bar__iconWrapper_1ngip {
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ height: 30px;
32
+ width: 30px;
33
+ border-radius: var(--border-radius-circle);
34
+ background: var(--color-light-neutral-translucent-100);
35
+ vertical-align: middle
36
+ } .navigation-bar__iconWrapper_1ngip.navigation-bar__back_1ngip {
37
+ background: transparent;
38
+ } .navigation-bar__floating_1ngip path {
39
+ fill: var(--color-light-neutral-translucent-700);
40
+ } .navigation-bar__floating_1ngip:hover path {
41
+ fill: var(--color-light-neutral-translucent-700-hover);
42
+ } .navigation-bar__floating_1ngip:active path {
43
+ fill: var(--color-light-neutral-translucent-700-press);
44
+ }
@@ -0,0 +1 @@
1
+ export { ActionIconAddon } from './Component.js';
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ interface ActionTextAddonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * Текст после иконки
6
+ */
7
+ text: string;
8
+ /**
9
+ * Тип действия
10
+ */
11
+ action?: 'primary' | 'secondary';
12
+ /**
13
+ * Дополнительный класс
14
+ */
15
+ className?: string;
16
+ /**
17
+ * Обработчик клика
18
+ */
19
+ onClick?: () => void;
20
+ /**
21
+ * Идентификатор для систем автоматизированного тестирования.
22
+ */
23
+ dataTestId?: string;
24
+ }
25
+ declare const ActionTextAddon: React.FC<ActionTextAddonProps>;
26
+ export { ActionTextAddonProps, ActionTextAddon };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { ButtonDesktop } from '@alfalab/core-components-button/modern/desktop';
4
+ import { Typography } from '@alfalab/core-components-typography/modern';
5
+
6
+ const styles = {"component":"navigation-bar__component_bdo4g","text":"navigation-bar__text_bdo4g"};
7
+ require('./index.css')
8
+
9
+ const ActionTextAddon = ({ text = 'Назад', onClick, className, action, dataTestId, ...htmlAttributes }) => (React.createElement(ButtonDesktop, { view: 'text', size: 's', onClick: onClick, "aria-label": text, className: cn(styles.component, className), dataTestId: dataTestId, ...htmlAttributes },
10
+ React.createElement(Typography.Text, { className: styles.text, view: 'component', weight: action === 'primary' ? 'medium' : 'regular' }, text)));
11
+
12
+ export { ActionTextAddon };