@pushwoosh/smart-components-kit 1.0.73 → 1.0.74
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/DocsButton/DocsButton.d.ts +3 -0
- package/DocsButton/DocsButton.js +44 -0
- package/DocsButton/index.d.ts +2 -0
- package/DocsButton/index.js +1 -0
- package/DocsButton/types.d.ts +8 -0
- package/DocsButton/types.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DrawerDocs, useDocs } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { DocsIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { useSPAContext } from '@pushwoosh/spa-context';
|
|
5
|
+
const PUSHWOOSH_DOCS_BASE = 'https://docs.pushwoosh.com';
|
|
6
|
+
const WAVESEND_DOCS_BASE = 'https://docs.wavesend.ru';
|
|
7
|
+
export function DocsButton(props) {
|
|
8
|
+
const {
|
|
9
|
+
pathname,
|
|
10
|
+
children,
|
|
11
|
+
color = 'secondary',
|
|
12
|
+
view = 'ghost',
|
|
13
|
+
size
|
|
14
|
+
} = props;
|
|
15
|
+
const {
|
|
16
|
+
environment
|
|
17
|
+
} = useSPAContext();
|
|
18
|
+
const {
|
|
19
|
+
docsOpen,
|
|
20
|
+
openDocsDrawer,
|
|
21
|
+
closeDocsDrawer
|
|
22
|
+
} = useDocs();
|
|
23
|
+
if (environment.isOMO) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const base = environment.isWavesend ? WAVESEND_DOCS_BASE : PUSHWOOSH_DOCS_BASE;
|
|
27
|
+
const normalizedPath = pathname.startsWith('/') ? pathname : `/${pathname}`;
|
|
28
|
+
const url = `${base}${normalizedPath}`;
|
|
29
|
+
return React.createElement(React.Fragment, null, React.createElement(Button, {
|
|
30
|
+
"aria-label": "Documentation",
|
|
31
|
+
color: color,
|
|
32
|
+
view: view,
|
|
33
|
+
size: size,
|
|
34
|
+
icon: React.createElement(DocsIcon, {
|
|
35
|
+
size: "medium",
|
|
36
|
+
view: "lined"
|
|
37
|
+
}),
|
|
38
|
+
onClick: openDocsDrawer
|
|
39
|
+
}, children), React.createElement(DrawerDocs, {
|
|
40
|
+
url: url,
|
|
41
|
+
isOpen: docsOpen,
|
|
42
|
+
onClose: closeDocsDrawer
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DocsButton } from './DocsButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED