Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions app/renderedHTML.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import parse, {
} from "html-react-parser";
import { useHydratedMemo } from "~/useHydrated";
import { Link } from "@remix-run/react";
import { GooeyHelpIcon, TooltipPlacement } from "./components/GooeyTooltip";
import type { TooltipPlacement } from "./components/GooeyTooltip";
import { GooeyHelpIcon } from "./components/GooeyTooltip";

export function RenderedHTML({
body,
lineClamp,
help,
tooltipPlacement,
lineClampExpand,
...attrs
}: {
body: string;
Expand Down Expand Up @@ -42,7 +44,7 @@ export function RenderedHTML({
);
}
return (
<LineClamp lines={lineClamp} key={body}>
<LineClamp lines={lineClamp} key={body} expandable={lineClampExpand}>
<span className="gui-html-container" {...attrs}>
{parsedElements}
</span>
Expand Down Expand Up @@ -141,9 +143,11 @@ const reactParserOptions: HTMLReactParserOptions = {
function LineClamp({
lines,
children,
expandable = true,
}: {
lines?: number;
children: React.ReactNode;
expandable: boolean;
}) {
const contentRef = useRef<HTMLSpanElement>(null);

Expand Down Expand Up @@ -201,19 +205,21 @@ function LineClamp({
lineHeight: "130%",
}}
>
<button
style={{
border: "none",
backgroundColor: "white",
color: "rgba(0, 0, 0, 0.6)",
}}
type={"button"}
onClick={() => {
setExpanded(true);
}}
>
…more
</button>
{expandable && (
<button
style={{
border: "none",
backgroundColor: "white",
color: "rgba(0, 0, 0, 0.6)",
}}
type={"button"}
onClick={() => {
setExpanded(true);
}}
>
…more
</button>
)}
</span>
)}
</span>
Expand Down
4 changes: 3 additions & 1 deletion app/renderedMarkdown.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { marked } from "marked";
import { RenderedHTML } from "~/renderedHTML";
import { TooltipPlacement } from "./components/GooeyTooltip";
import type { TooltipPlacement } from "./components/GooeyTooltip";

export function RenderedMarkdown({
body,
lineClamp,
help,
tooltipPlacement,
lineClampExpand,
...attrs
}: // allowUnsafeHTML,
{
Expand All @@ -30,6 +31,7 @@ export function RenderedMarkdown({
key={body}
body={html}
lineClamp={lineClamp}
lineClampExpand={lineClampExpand}
className="gui-html-container gui-md-container"
help={help}
tooltipPlacement={tooltipPlacement}
Expand Down