UNPKG

@nwebui/react-niagara-px

Version:
31 lines 1.31 kB
import React from "react"; import useWidgetChanged from "./useWidgetChanged"; import { Widget } from "./Widget"; const Line = function ({ nativeWidget, children }) { useWidgetChanged(nativeWidget); const geom = nativeWidget .gets("geom") .split(" ") .map((p) => p.split(",").map((x) => +x)); const fill = nativeWidget.gets("fill") || undefined; const stroke = nativeWidget.gets("stroke") || undefined; const pen = nativeWidget.gets("pen") || undefined; const left = Math.min(geom[0][0], geom[1][0]); const top = Math.min(geom[0][1], geom[1][1]); const width = Math.abs(geom[0][0] - geom[1][0]); const height = Math.abs(geom[0][1] - geom[1][1]); const style = { position: "absolute", top, left, width, height, }; const viewBox = `${left} ${top} ${width} ${height}`; return (React.createElement(Widget, { nativeWidget: nativeWidget, style: style }, React.createElement("svg", { width: "100%", height: "100%", viewBox: viewBox }, React.createElement("line", { x1: geom[0][0], y1: geom[0][1], x2: geom[1][0], y2: geom[1][1], fill: fill, stroke: stroke, strokeWidth: pen })), children)); }; export default Line; //# sourceMappingURL=Line.js.map