@rabbitio/ui-kit 1.0.0-beta.6 → 1.0.0-beta.7
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/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import s from "./asset-icon.module.scss";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
|
|
6
|
+
export const AssetIcon = ({
|
|
7
|
+
assetIconSrc,
|
|
8
|
+
assetIconProtocolScr = null,
|
|
9
|
+
fallbackSrc = null,
|
|
10
|
+
small = false,
|
|
11
|
+
}) => {
|
|
12
|
+
const handleFailedLoad = (e) => {
|
|
13
|
+
e.target.onerror = null;
|
|
14
|
+
e.target.src = fallbackSrc;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={s["asset-icon"] + (small ? " " + s["small"] : "")}>
|
|
19
|
+
<img
|
|
20
|
+
src={assetIconSrc}
|
|
21
|
+
className={
|
|
22
|
+
s["asset-icon-primary"] + (small ? " " + s["small"] : "")
|
|
23
|
+
}
|
|
24
|
+
alt={" "}
|
|
25
|
+
onError={handleFailedLoad}
|
|
26
|
+
/>
|
|
27
|
+
{assetIconProtocolScr ? (
|
|
28
|
+
<img
|
|
29
|
+
src={assetIconProtocolScr}
|
|
30
|
+
className={
|
|
31
|
+
s["asset-icon-secondary"] +
|
|
32
|
+
(small ? " " + s["small"] : "")
|
|
33
|
+
}
|
|
34
|
+
alt={" "}
|
|
35
|
+
onError={handleFailedLoad}
|
|
36
|
+
/>
|
|
37
|
+
) : (
|
|
38
|
+
""
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
AssetIcon.propTypes = {
|
|
45
|
+
assetIconSrc: PropTypes.string.isRequired,
|
|
46
|
+
assetIconProtocolScr: PropTypes.string,
|
|
47
|
+
fallbackSrc: PropTypes.string,
|
|
48
|
+
small: PropTypes.bool,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
AssetIcon.defaultProps = {
|
|
52
|
+
assetIconProtocolScr: null,
|
|
53
|
+
fallbackSrc: null,
|
|
54
|
+
small: false,
|
|
55
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import "../../../styles/index";
|
|
2
|
+
|
|
3
|
+
.asset-icon {
|
|
4
|
+
width: 34px;
|
|
5
|
+
height: 34px;
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&.small {
|
|
9
|
+
width: 24px;
|
|
10
|
+
height: 24px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-primary {
|
|
14
|
+
height: 34px;
|
|
15
|
+
width: 34px;
|
|
16
|
+
|
|
17
|
+
&.small {
|
|
18
|
+
width: 24px;
|
|
19
|
+
height: 24px;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-secondary {
|
|
24
|
+
width: 17px;
|
|
25
|
+
height: 17px;
|
|
26
|
+
|
|
27
|
+
position: absolute;
|
|
28
|
+
right: -3px;
|
|
29
|
+
bottom: -3px;
|
|
30
|
+
box-shadow: -2px -2px 4px 1px rgba(SolidColor("dark"), 0.3);
|
|
31
|
+
border-radius: 100%;
|
|
32
|
+
|
|
33
|
+
&.small {
|
|
34
|
+
width: 12px;
|
|
35
|
+
height: 12px;
|
|
36
|
+
|
|
37
|
+
right: -2px;
|
|
38
|
+
bottom: -2px;
|
|
39
|
+
box-shadow: -1px -1px 8px 1px rgba(SolidColor("dark"), 0.3);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
export const SupportChat = ({ url, websiteToken, welcomeMessage = "" }) => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
window.chatwootSettings = {
|
|
7
|
+
position: "right",
|
|
8
|
+
type: "standard",
|
|
9
|
+
launcherTitle: welcomeMessage,
|
|
10
|
+
};
|
|
11
|
+
(function (d, t) {
|
|
12
|
+
var BASE_URL = url;
|
|
13
|
+
var g = d.createElement(t),
|
|
14
|
+
s = d.getElementsByTagName(t)[0];
|
|
15
|
+
g.src = BASE_URL + "/packs/js/sdk.js";
|
|
16
|
+
g.defer = true;
|
|
17
|
+
g.async = true;
|
|
18
|
+
s.parentNode.insertBefore(g, s);
|
|
19
|
+
g.onload = function () {
|
|
20
|
+
window.chatwootSDK.run({
|
|
21
|
+
websiteToken: websiteToken,
|
|
22
|
+
baseUrl: BASE_URL,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})(document, "script");
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
SupportChat.propTypes = {
|
|
33
|
+
url: PropTypes.string.isRequired,
|
|
34
|
+
websiteToken: PropTypes.string.isRequired,
|
|
35
|
+
welcomeMessage: PropTypes.string,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
SupportChat.defaultProps = {
|
|
39
|
+
welcomeMessage: "",
|
|
40
|
+
};
|
package/stories/index.js
CHANGED