UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

59 lines (58 loc) 2.02 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const React = require("react"); const h = require("@macrostrat/hyper"); const classNames = require("classnames"); const swatch = require("./swatch.cjs"); const facies = require("../../context/facies.cjs"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const h__default = /* @__PURE__ */ _interopDefault(h); const classNames__default = /* @__PURE__ */ _interopDefault(classNames); function FaciesCard({ facies: facies2 }) { return h__default.default("div.header", [ h__default.default("p.name", { style: { marginRight: 20, textAlign: "left" } }, facies2.name), h__default.default(swatch.FaciesSwatch, { facies: facies2 }) ]); } class FaciesDescriptionSmall extends React.Component { constructor(props) { super(props); this.renderEach = this.renderEach.bind(this); } static contextType = facies.FaciesContext; static defaultProps = { selected: null, isEditable: false }; renderEach(d) { let onClick = null; const style = {}; if (this.props.onClick != null) { onClick = () => this.props.onClick(d); style.cursor = "pointer"; } const { selected } = this.props; if (selected === d.id) { style.backgroundColor = d.color; style.color = "white"; } const className = classNames__default.default({ selected: selected === d.id }); return h__default.default( "div.facies.bp3-card.bp3-elevation-0", { key: d.id, onClick, style, className }, h__default.default(FaciesCard, { facies: d }) ); } render() { const { facies: facies2 } = this.context; return h__default.default("div.facies-description-small", [ h__default.default("h5", "Facies"), h__default.default("div", facies2.map(this.renderEach)) ]); } } exports.FaciesCard = FaciesCard; exports.FaciesDescriptionSmall = FaciesDescriptionSmall; //# sourceMappingURL=description.cjs.map