Download packages/tui/src/ui/link.tsx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/ui/link.tsx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/tui/src/ui/link.tsx
-
curl -L -o link.tsx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/ui/link.tsx
746 Bytes
| 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 | |
| bg?: RGBA | |
| 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} | |
| bg={props.bg} | |
| width={props.width} | |
| wrapMode={props.wrapMode} | |
| onMouseUp={() => { | |
| open(props.href).catch(() => {}) | |
| }} | |
| > | |
| {displayText} | |
| </text> | |
| ) | |
| } | |