Skip to content

Commit 7c89d6b

Browse files
authored
Merge pull request #32 from GooeyAI/lineClampExpand_prop
read lineClampExpand prop
2 parents 35bac0d + 79376f5 commit 7c89d6b

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

app/renderedHTML.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import parse, {
88
} from "html-react-parser";
99
import { useHydratedMemo } from "~/useHydrated";
1010
import { Link } from "@remix-run/react";
11-
import { GooeyHelpIcon, TooltipPlacement } from "./components/GooeyTooltip";
11+
import type { TooltipPlacement } from "./components/GooeyTooltip";
12+
import { GooeyHelpIcon } from "./components/GooeyTooltip";
1213

1314
export function RenderedHTML({
1415
body,
1516
lineClamp,
1617
help,
1718
tooltipPlacement,
19+
lineClampExpand,
1820
...attrs
1921
}: {
2022
body: string;
@@ -42,7 +44,7 @@ export function RenderedHTML({
4244
);
4345
}
4446
return (
45-
<LineClamp lines={lineClamp} key={body}>
47+
<LineClamp lines={lineClamp} key={body} expandable={lineClampExpand}>
4648
<span className="gui-html-container" {...attrs}>
4749
{parsedElements}
4850
</span>
@@ -141,9 +143,11 @@ const reactParserOptions: HTMLReactParserOptions = {
141143
function LineClamp({
142144
lines,
143145
children,
146+
expandable = true,
144147
}: {
145148
lines?: number;
146149
children: React.ReactNode;
150+
expandable: boolean;
147151
}) {
148152
const contentRef = useRef<HTMLSpanElement>(null);
149153

@@ -201,19 +205,21 @@ function LineClamp({
201205
lineHeight: "130%",
202206
}}
203207
>
204-
<button
205-
style={{
206-
border: "none",
207-
backgroundColor: "white",
208-
color: "rgba(0, 0, 0, 0.6)",
209-
}}
210-
type={"button"}
211-
onClick={() => {
212-
setExpanded(true);
213-
}}
214-
>
215-
…more
216-
</button>
208+
{expandable && (
209+
<button
210+
style={{
211+
border: "none",
212+
backgroundColor: "white",
213+
color: "rgba(0, 0, 0, 0.6)",
214+
}}
215+
type={"button"}
216+
onClick={() => {
217+
setExpanded(true);
218+
}}
219+
>
220+
…more
221+
</button>
222+
)}
217223
</span>
218224
)}
219225
</span>

app/renderedMarkdown.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { marked } from "marked";
22
import { RenderedHTML } from "~/renderedHTML";
3-
import { TooltipPlacement } from "./components/GooeyTooltip";
3+
import type { TooltipPlacement } from "./components/GooeyTooltip";
44

55
export function RenderedMarkdown({
66
body,
77
lineClamp,
88
help,
99
tooltipPlacement,
10+
lineClampExpand,
1011
...attrs
1112
}: // allowUnsafeHTML,
1213
{
@@ -30,6 +31,7 @@ export function RenderedMarkdown({
3031
key={body}
3132
body={html}
3233
lineClamp={lineClamp}
34+
lineClampExpand={lineClampExpand}
3335
className="gui-html-container gui-md-container"
3436
help={help}
3537
tooltipPlacement={tooltipPlacement}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)