UNPKG

envio

Version:

A latency and sync speed optimized, developer friendly blockchain data indexer.

58 lines (53 loc) 2.12 kB
// Generated by ReScript, PLEASE EDIT WITH CARE import * as Ink from "ink"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js"; import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js"; import * as JsxRuntime from "react/jsx-runtime"; function BufferedProgressBar(props) { let __loadingColor = props.loadingColor; let __barWidth = props.barWidth; let outOf = props.outOf; let barWidth = __barWidth !== undefined ? __barWidth : 36; let loadingColor = __loadingColor !== undefined ? __loadingColor : "#FFBB2F"; let loadedFraction = props.loaded / outOf; let loadedCount = Primitive_int.min(Math.floor(barWidth * loadedFraction) | 0, barWidth); let bufferedCount = Stdlib_Option.mapOr(props.buffered, loadedCount, buffered => { let bufferedFraction = buffered / outOf; return Primitive_int.min(Math.floor(barWidth * bufferedFraction) | 0, barWidth); }); let loadedFraction$1 = loadedFraction > 0.0 ? loadedFraction : 0.0; let loadedPercentageStr = (loadedFraction$1 * 100 | 0).toString() + "% "; let loadedPercentageStrCount = loadedPercentageStr.length; let loadedSpaces = Primitive_int.max(loadedCount - loadedPercentageStrCount | 0, 0); let loadedCount$1 = Primitive_int.max(loadedCount, loadedPercentageStrCount); let bufferedCount$1 = Primitive_int.max(bufferedCount, loadedCount$1); return JsxRuntime.jsxs(Ink.Box, { children: [ JsxRuntime.jsxs(Ink.Text, { children: [ JsxRuntime.jsx(Ink.Text, { children: " ".repeat(loadedSpaces) }), JsxRuntime.jsx(Ink.Text, { children: loadedPercentageStr }) ], color: "gray", backgroundColor: loadingColor }), JsxRuntime.jsx(Ink.Text, { children: " ".repeat(bufferedCount$1 - loadedCount$1 | 0), backgroundColor: "gray" }), JsxRuntime.jsx(Ink.Text, { children: " ".repeat(barWidth - bufferedCount$1 | 0), backgroundColor: "white" }) ] }); } let make = BufferedProgressBar; export { make, } /* ink Not a pure module */