@alfalab/core-components-navigation-bar 0.3.6 → 0.4.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 (41) hide show
  1. package/Component.js +7 -11
  2. package/components/back-arrow-addon/Component.js +3 -3
  3. package/components/back-arrow-addon/index.css +12 -12
  4. package/components/back-arrow-addon/index.js +1 -1
  5. package/components/closer/Component.js +1 -1
  6. package/components/closer/index.css +5 -5
  7. package/cssm/Component.js +6 -10
  8. package/cssm/components/back-arrow-addon/Component.js +2 -2
  9. package/cssm/components/back-arrow-addon/index.js +1 -1
  10. package/cssm/index.js +2 -1
  11. package/esm/Component.js +3 -7
  12. package/esm/components/back-arrow-addon/Component.js +3 -3
  13. package/esm/components/back-arrow-addon/index.css +12 -12
  14. package/esm/components/back-arrow-addon/index.js +1 -1
  15. package/esm/components/closer/Component.js +1 -1
  16. package/esm/components/closer/index.css +5 -5
  17. package/esm/index.css +27 -27
  18. package/esm/index.js +2 -1
  19. package/index.css +27 -27
  20. package/index.js +2 -1
  21. package/modern/Component.js +3 -7
  22. package/modern/components/back-arrow-addon/Component.js +3 -3
  23. package/modern/components/back-arrow-addon/index.css +12 -12
  24. package/modern/components/back-arrow-addon/index.js +1 -1
  25. package/modern/components/closer/Component.js +1 -1
  26. package/modern/components/closer/index.css +5 -5
  27. package/modern/index.css +27 -27
  28. package/modern/index.js +2 -1
  29. package/package.json +5 -4
  30. package/src/Component.tsx +282 -0
  31. package/src/components/back-arrow-addon/Component.tsx +82 -0
  32. package/src/components/back-arrow-addon/index.module.css +66 -0
  33. package/src/components/back-arrow-addon/index.ts +1 -0
  34. package/src/components/closer/Component.tsx +80 -0
  35. package/src/components/closer/index.module.css +29 -0
  36. package/src/components/closer/index.ts +1 -0
  37. package/src/index.module.css +118 -0
  38. package/src/index.ts +3 -0
  39. package/src/types.ts +137 -0
  40. package/src/vars.css +6 -0
  41. package/send-stats.js +0 -82
package/src/types.ts ADDED
@@ -0,0 +1,137 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ import type { CloserProps } from './components/closer';
4
+
5
+ export type NavigationBarProps = {
6
+ /**
7
+ * Контент шапки
8
+ */
9
+ children?: ReactNode;
10
+
11
+ /**
12
+ * Заголовок шапки
13
+ */
14
+ title?: string;
15
+
16
+ /**
17
+ * Подзаголовок (доступен только в мобильной версии)
18
+ */
19
+ subtitle?: string;
20
+
21
+ /**
22
+ * Размер заголовка (compact доступен только в мобильной версии)
23
+ */
24
+ titleSize?: 'default' | 'compact';
25
+
26
+ /**
27
+ * Доп. класс для аддонов
28
+ */
29
+ addonClassName?: string;
30
+
31
+ /**
32
+ * Слот слева
33
+ */
34
+ leftAddons?: ReactNode;
35
+
36
+ /**
37
+ * Слот справа
38
+ */
39
+ rightAddons?: ReactNode;
40
+
41
+ /**
42
+ * Дополнительный класс для closer
43
+ */
44
+ closerClassName?: string;
45
+
46
+ /**
47
+ * Слот снизу
48
+ */
49
+ bottomAddons?: ReactNode;
50
+
51
+ /**
52
+ * Наличие компонента крестика
53
+ */
54
+ hasCloser?: boolean;
55
+
56
+ /**
57
+ * Наличие кнопки "Назад"
58
+ */
59
+ hasBackButton?: boolean;
60
+
61
+ /**
62
+ * Дополнительный класс для правого аддона
63
+ */
64
+ backButtonClassName?: string;
65
+
66
+ /**
67
+ * Дополнительный класс
68
+ */
69
+ className?: string;
70
+
71
+ /**
72
+ * Дополнительный класс для контента
73
+ */
74
+ contentClassName?: string;
75
+
76
+ /**
77
+ * Дополнительный класс для нижнего аддона
78
+ */
79
+ bottomAddonsClassName?: string;
80
+
81
+ /**
82
+ * Выравнивание заголовка
83
+ */
84
+ align?: 'left' | 'center';
85
+
86
+ /**
87
+ * Обрезать ли заголовок
88
+ */
89
+ trim?: boolean;
90
+
91
+ /**
92
+ * Фиксирует шапку
93
+ */
94
+ sticky?: boolean;
95
+
96
+ /**
97
+ * Идентификатор для систем автоматизированного тестирования
98
+ */
99
+ dataTestId?: string;
100
+
101
+ /**
102
+ * Фоновое изображение
103
+ */
104
+ imageUrl?: string;
105
+
106
+ /**
107
+ * Иконка closer.
108
+ */
109
+ closerIcon?: React.ElementType;
110
+
111
+ /**
112
+ * Обработчик закрытия
113
+ */
114
+ onClose?: CloserProps['onClose'];
115
+
116
+ /**
117
+ * обработчик клика по кнопке "назад"
118
+ */
119
+ onBack?: () => void;
120
+
121
+ /**
122
+ * Вид шапки - мобильный или десктоп
123
+ */
124
+ view: 'desktop' | 'mobile';
125
+
126
+ /**
127
+ * Ссылка на родительскую ноду overflow: auto
128
+ */
129
+ scrollableParentRef?: React.RefObject<HTMLDivElement>;
130
+ };
131
+
132
+ export type ContentParams = {
133
+ extraClassName?: string;
134
+ wrapperRef?: React.RefObject<HTMLDivElement>;
135
+ style?: React.CSSProperties;
136
+ hidden?: boolean;
137
+ };
package/src/vars.css ADDED
@@ -0,0 +1,6 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+
3
+ :root {
4
+ /* closer-mobile */
5
+ --navigation-bar-closer-mobile-color: var(--color-light-graphic-secondary);
6
+ }
package/send-stats.js DELETED
@@ -1,82 +0,0 @@
1
- const http = require('http');
2
- const fs = require('fs');
3
- const { promisify } = require('util');
4
- const path = require('path');
5
-
6
- const readFile = promisify(fs.readFile);
7
-
8
- async function main() {
9
- const remoteHost = process.env.NIS_HOST || 'digital';
10
- const remotePort = process.env.NIS_PORT || 80;
11
- const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
12
-
13
- try {
14
- const [_, node, os, arch] =
15
- /node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
16
- const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
17
- const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
18
-
19
- let ownPackageJson, packageJson;
20
-
21
- try {
22
- const result = await Promise.all([
23
- readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
24
- readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
25
- ]);
26
-
27
- ownPackageJson = JSON.parse(result[0]);
28
- packageJson = JSON.parse(result[1]);
29
- } catch (err) {
30
- ownPackageJson = '';
31
- packageJson = '';
32
- }
33
-
34
- const data = {
35
- node,
36
- npm,
37
- yarn,
38
- os,
39
- arch,
40
- ownPackageJson: JSON.stringify(ownPackageJson),
41
- packageJson: JSON.stringify(packageJson),
42
- };
43
-
44
- const body = JSON.stringify(data);
45
-
46
- const options = {
47
- host: remoteHost,
48
- port: remotePort,
49
- path: remotePath,
50
- method: 'POST',
51
- headers: {
52
- 'Content-Type': 'application/json',
53
- 'Content-Length': body.length,
54
- },
55
- };
56
-
57
- return new Promise((resolve, reject) => {
58
- const req = http.request(options, (res) => {
59
- res.on('end', () => {
60
- resolve();
61
- });
62
- });
63
-
64
- req.on('error', () => {
65
- reject();
66
- });
67
-
68
- req.write(body);
69
- req.end();
70
- });
71
- } catch (error) {
72
- throw error;
73
- }
74
- }
75
-
76
- main()
77
- .then(() => {
78
- process.exit(0);
79
- })
80
- .catch(() => {
81
- process.exit(0);
82
- });