UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

40 lines (39 loc) 1.02 kB
import { useContext } from "react"; import h from "../hyper.js"; import { NoteLayoutContext } from "./layout.js"; function HeightRangeAnnotation(props) { const { scale } = useContext(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 h("g.height-range", { transform, ...rest }, [ h.if(isLine)("line", { x1: 0, x2: 0, y1: lineInset, y2: pxHeight - lineInset }), h.if(!isLine)("circle", { r: circleRadius, transform: `translate(0,${pxHeight / 2})` }) ]); } export { HeightRangeAnnotation }; //# sourceMappingURL=height-range.js.map