UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

40 lines (33 loc) 1.74 kB
import $f5b828bbb980a05d$export$2e2bcd8739ae039 from "./column-components.de2f942b.js"; import {NoteLayoutContext as $00c4b971e86fe1d8$export$20c7bffdb69233c9} from "./column-components.fea107a9.js"; import {useContext as $icLR5$useContext} from "react"; function $dfac63f354e170ff$export$664019b81938583(props) { const { scale: scale } = (0, $icLR5$useContext)((0, $00c4b971e86fe1d8$export$20c7bffdb69233c9)); const { height: height, top_height: top_height, offsetX: offsetX = 0, color: color, lineInset: lineInset = 1, circleRadius: 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; /* Use a value slightly greater than the circle diameter as the cutoff to switch between line and circle, to account for a circle's greater visual weight than the equivalent line height */ const isLine = pxHeight > 3 * Math.max(lineInset, circleRadius); const transform = `translate(${offsetX},${topHeight})`; return (0, $f5b828bbb980a05d$export$2e2bcd8739ae039)("g.height-range", { transform: transform, ...rest }, [ (0, $f5b828bbb980a05d$export$2e2bcd8739ae039).if(isLine)("line", { x1: 0, x2: 0, y1: lineInset, y2: pxHeight - lineInset }), (0, $f5b828bbb980a05d$export$2e2bcd8739ae039).if(!isLine)("circle", { r: circleRadius, transform: `translate(0,${pxHeight / 2})` }) ]); } export {$dfac63f354e170ff$export$664019b81938583 as HeightRangeAnnotation}; //# sourceMappingURL=column-components.ccf8b5bf.js.map