@getpara/react-common 1.10.0 → 1.12.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,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-GOCCUU3Z.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { CpslIcon } from "@getpara/react-components";
|
|
7
|
+
const BannerContainerWrapper = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
width: 100%;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
`;
|
|
14
|
+
const BannerContainer = styled.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
max-width: ${({ $maxWidth }) => $maxWidth || "100%"};
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
padding: 6px;
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
position: relative;
|
|
24
|
+
z-index: 10;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
`;
|
|
30
|
+
const WarningIcon = styled(CpslIcon)`
|
|
31
|
+
--icon-color: #fbbc04;
|
|
32
|
+
--width: ${({ $size }) => $size || "24px"};
|
|
33
|
+
--height: ${({ $size }) => $size || "24px"};
|
|
34
|
+
margin-right: 6px;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
`;
|
|
37
|
+
const BannerText = styled.span`
|
|
38
|
+
font-family: var(--cpsl-default-font);
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
font-size: ${({ $fontSize }) => $fontSize || "14px"};
|
|
41
|
+
color: var(--cpsl-color-black);
|
|
42
|
+
flex: 1;
|
|
43
|
+
`;
|
|
44
|
+
const NetworkSpeedBanner = ({
|
|
45
|
+
fontSize,
|
|
46
|
+
iconSize,
|
|
47
|
+
maxWidth
|
|
48
|
+
}) => {
|
|
49
|
+
const [isSlowNetwork, setIsSlowNetwork] = useState(false);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
var _a;
|
|
52
|
+
const connection = navigator == null ? void 0 : navigator.connection;
|
|
53
|
+
const checkNetworkSpeed = () => {
|
|
54
|
+
if (connection) {
|
|
55
|
+
const isSlow = connection.effectiveType === "2g" || connection.effectiveType === "slow-2g" || connection.downlink && connection.downlink < 0.5;
|
|
56
|
+
setIsSlowNetwork(isSlow);
|
|
57
|
+
} else {
|
|
58
|
+
setIsSlowNetwork(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
checkNetworkSpeed();
|
|
62
|
+
(_a = connection == null ? void 0 : connection.addEventListener) == null ? void 0 : _a.call(connection, "change", checkNetworkSpeed);
|
|
63
|
+
const intervalId = setInterval(checkNetworkSpeed, 15e3);
|
|
64
|
+
return () => {
|
|
65
|
+
var _a2;
|
|
66
|
+
clearInterval(intervalId);
|
|
67
|
+
(_a2 = connection == null ? void 0 : connection.removeEventListener) == null ? void 0 : _a2.call(connection, "change", checkNetworkSpeed);
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
if (!isSlowNetwork) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsx(BannerContainerWrapper, { children: /* @__PURE__ */ jsxs(BannerContainer, { $maxWidth: maxWidth, children: [
|
|
74
|
+
/* @__PURE__ */ jsx(WarningIcon, { $size: iconSize, icon: "alertTriangle" }),
|
|
75
|
+
/* @__PURE__ */ jsx(BannerText, { $fontSize: fontSize, children: "Your network is slow. This may impact your experience." })
|
|
76
|
+
] }) });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
NetworkSpeedBanner
|
|
80
|
+
};
|
package/dist/components/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"*.css"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@getpara/react-components": "1.
|
|
15
|
-
"@getpara/web-sdk": "1.
|
|
14
|
+
"@getpara/react-components": "1.12.0",
|
|
15
|
+
"@getpara/web-sdk": "1.12.0",
|
|
16
16
|
"@moonpay/moonpay-react": "^1.8.3",
|
|
17
17
|
"@ramp-network/ramp-instant-sdk": "^4.0.5",
|
|
18
18
|
"@stripe/crypto": "^0.0.4",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"resolutions": {
|
|
44
44
|
"styled-components": "^6"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
|
|
47
47
|
}
|