Files
opencode/packages/web/src/components/share/content-text.tsx
Dax f884766445 v2 message format and upgrade to ai sdk v5 (#743)
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Liang-Shih Lin <liangshihlin@proton.me>
Co-authored-by: Dominik Engelhardt <dominikengelhardt@ymail.com>
Co-authored-by: Jay V <air@live.ca>
Co-authored-by: adamdottv <2363879+adamdottv@users.noreply.github.com>
2025-07-07 15:53:43 -04:00

36 lines
943 B
TypeScript

import style from "./content-text.module.css"
import { createSignal } from "solid-js"
import { createOverflow } from "./common"
interface Props {
text: string
expand?: boolean
compact?: boolean
}
export function ContentText(props: Props) {
const [expanded, setExpanded] = createSignal(false)
const overflow = createOverflow()
return (
<div
class={style.root}
data-expanded={expanded() || props.expand === true ? true : undefined}
data-compact={props.compact === true ? true : undefined}
>
<pre data-slot="text" ref={overflow.ref}>
{props.text}
</pre>
{((!props.expand && overflow.status) || expanded()) && (
<button
type="button"
data-component="text-button"
data-slot="expand-button"
onClick={() => setExpanded((e) => !e)}
>
{expanded() ? "Show less" : "Show more"}
</button>
)}
</div>
)
}