cloudaxe-opencode/packages/opencode/src/cli/cmd/tui/ui/link.tsx

33 lines
714 B
TypeScript
Raw Normal View History

import type { JSX } from "solid-js"
import type { RGBA } from "@opentui/core"
import open from "open"
export interface LinkProps {
href: string
children?: JSX.Element | string
fg?: RGBA
2026-05-07 21:53:24 +00:00
width?: number | "auto" | `${number}%`
wrapMode?: "word" | "none"
}
/**
* Link component that renders clickable hyperlinks.
* Clicking anywhere on the link text opens the URL in the default browser.
*/
export function Link(props: LinkProps) {
const displayText = props.children ?? props.href
return (
<text
fg={props.fg}
2026-05-07 21:53:24 +00:00
width={props.width}
wrapMode={props.wrapMode}
onMouseUp={() => {
open(props.href).catch(() => {})
}}
>
{displayText}
</text>
)
}