Compare commits

..

No commits in common. "v0.1.0-develop.35" and "v0.1.0-develop.34" have entirely different histories.

4 changed files with 29 additions and 37 deletions

View File

@ -1,5 +1,3 @@
# [0.1.0-develop.35](https://git.lumeweb.com/LumeWeb/sdk/compare/v0.1.0-develop.34...v0.1.0-develop.35) (2023-10-13)
# [0.1.0-develop.34](https://git.lumeweb.com/LumeWeb/sdk/compare/v0.1.0-develop.33...v0.1.0-develop.34) (2023-10-13)
# [0.1.0-develop.33](https://git.lumeweb.com/LumeWeb/sdk/compare/v0.1.0-develop.32...v0.1.0-develop.33) (2023-10-12)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.35",
"version": "0.1.0-develop.34",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.35",
"version": "0.1.0-develop.34",
"dependencies": {
"@lumeweb/kernel-network-registry-client": "0.1.0-develop.10",
"@lumeweb/libkernel": "0.1.0-develop.65",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/sdk",
"version": "0.1.0-develop.35",
"version": "0.1.0-develop.34",
"type": "module",
"main": "lib/index.js",
"types": "lib/src/index.d.ts",

View File

@ -117,7 +117,6 @@ const NetworkIndicator = ({ network }: { network: Network }) => {
</div>
);
};
function getTextDimensions(
fontSize: number,
ratios: { width: number; height: number },
@ -139,33 +138,31 @@ const CircularProgress = ({
width: 0,
height: 0,
});
const radius = 45;
const SVG_SIZE = radius * 2 + 10; // +10 to add some padding around
const STROKE_WIDTH = radius * 0.08; // 8% of the radius for the stroke width
const textSize = radius * 0.5; // half of the radius for text size
useEffect(() => {
const testText = document.createElement("span");
testText.style.fontSize = `${textSize}px`;
testText.style.position = "absolute";
testText.style.left = "-9999px"; // This effectively hides the element
testText.style.left = "-9999px";
testText.textContent = "The quick brown fox jumps over the lazy dog";
document.body.appendChild(testText);
const rect = testText.getBoundingClientRect();
setFontRatio({
width: rect.width / textSize,
height: rect.height / textSize,
});
// Clean up after measurements
document.body.removeChild(testText);
}, []);
}, [textSize]);
const size = 55;
const progressWidth = 2;
const circleWidth = 2;
const radius = size / 2 - 10;
const circumference = 2 * radius * Math.PI;
const { width: textWidth } = getTextDimensions(textSize, fontRatio);
const circumference = 2 * Math.PI * radius;
const offset = circumference * ((100 - chain.sync) / 100);
const textSize = 11;
return (
<svg
@ -173,39 +170,36 @@ const CircularProgress = ({
className,
chainIndicatorVariant({ syncState: chain.syncState }),
])}
width={size}
height={size}
viewBox={`-${size * 0.125} -${size * 0.125} ${size * 1.25} ${
size * 1.25
}`}
width={SVG_SIZE}
height={SVG_SIZE}
viewBox={`0 0 ${SVG_SIZE} ${SVG_SIZE}`}
version="1.1"
xmlns="http://www.w3.org/2000/svg"
style={{ transform: "rotate(-90deg)" }}>
<circle
r={size / 2 - 10}
cx={size / 2}
cy={size / 2}
r={radius}
cx={SVG_SIZE / 2}
cy={SVG_SIZE / 2}
fill="transparent"
stroke="#e0e0e0"
strokeWidth={`${circleWidth}px`}
strokeWidth={STROKE_WIDTH}
strokeDasharray={`${circumference}px`}></circle>
<circle
r={size / 2 - 10}
cx={size / 2}
cy={size / 2}
r={radius}
cx={SVG_SIZE / 2}
cy={SVG_SIZE / 2}
stroke="currentColor"
strokeWidth={`${progressWidth}px`}
strokeWidth={STROKE_WIDTH}
strokeLinecap="round"
strokeDashoffset={`${offset}px`}
fill="transparent"
strokeDasharray={`${circumference}px`}></circle>
<text
x="4px"
y="25px"
x={(SVG_SIZE - textWidth) / 2}
y={(SVG_SIZE + textSize) / 2} // Adding half of the text size for vertical centering
fill="currentColor"
fontSize="26px"
fontWeight="normal"
style={{ transform: "rotate(90deg) translate(0px, -32px)" }}>
fontSize={`${textSize}px`}
fontWeight="normal">
{chain.sync}
</text>
</svg>