UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

40 lines (39 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const React = require("react"); const hyper = require("../hyper.cjs"); const layout = require("./layout.cjs"); function HeightRangeAnnotation(props) { const { scale } = React.useContext(layout.NoteLayoutContext); const { height, top_height, offsetX = 0, color, lineInset = 1, circleRadius = 2, ...rest } = props; const bottomHeight = scale(height); let pxHeight = 0; if (top_height != null) { pxHeight = Math.abs(scale(top_height) - bottomHeight); } const topHeight = bottomHeight - pxHeight; const isLine = pxHeight > 3 * Math.max(lineInset, circleRadius); const transform = `translate(${offsetX},${topHeight})`; return hyper("g.height-range", { transform, ...rest }, [ hyper.if(isLine)("line", { x1: 0, x2: 0, y1: lineInset, y2: pxHeight - lineInset }), hyper.if(!isLine)("circle", { r: circleRadius, transform: `translate(0,${pxHeight / 2})` }) ]); } exports.HeightRangeAnnotation = HeightRangeAnnotation; //# sourceMappingURL=height-range.cjs.map