synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
52 lines (51 loc) • 1.44 kB
JavaScript
import { jsx as h, jsxs as i, Fragment as l } from "react/jsx-runtime";
import { Component as a } from "react";
const c = 400;
class d extends a {
constructor(e) {
super(e), this.state = {
showMore: !1
}, this.toggleShowMore = this.toggleShowMore.bind(this);
}
toggleShowMore(e) {
e.preventDefault(), this.setState({
showMore: !0
});
}
getCutoff = (e, r) => {
let o = "";
if (!e)
return { previewText: o };
let n = "";
const s = e.split(" ");
let t = 0;
for (; o.length < r && t < s.length; )
o += `${s[t]} `, t += 1;
return t < s.length - 1 && (n = s.slice(t).join(" ")), { previewText: o, hiddenText: n };
};
render() {
const { summary: e, maxCharacterCount: r = c } = this.props, o = e && e.length >= r, { previewText: n, hiddenText: s } = this.getCutoff(
e,
r
), t = o && /* @__PURE__ */ h(
"a",
{
style: { fontSize: "14px", cursor: "pointer", marginLeft: "5px" },
onClick: this.toggleShowMore,
className: "highlight-link",
children: "...Show More"
}
);
return /* @__PURE__ */ i(l, { children: [
/* @__PURE__ */ i("span", { children: [
n,
/* @__PURE__ */ h("span", { className: this.state.showMore ? "" : "SRC-hidden", children: s })
] }),
!this.state.showMore && t
] });
}
}
export {
d as default
};
//# sourceMappingURL=ShowMore.js.map