Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
tsx 85 lines 2.14 KB
Raw
1 import * as React from "react"
2
3 import { cn } from "@/lib/utils"
4
5 const lineVariantClasses = {
6 default: "text-[var(--terminal-fg)]",
7 dim: "text-[var(--terminal-dim)]",
8 success: "text-[var(--terminal-green)]",
9 error: "text-[var(--terminal-red)]",
10 warning: "text-[var(--terminal-orange)]",
11 thought: "text-[var(--terminal-purple)]",
12 command: "text-[var(--terminal-blue)]",
13 } as const
14
15 export type TerminalLineVariant = keyof typeof lineVariantClasses
16
17 export type TerminalLineProps = Omit<React.HTMLAttributes<HTMLDivElement>, "prefix"> & {
18 variant?: TerminalLineVariant
19 prefix?: React.ReactNode
20 /** Preserve `\n` in content. Off by default so JSX formatting does not affect layout. */
21 preserveWhitespace?: boolean
22 }
23
24 export function TerminalLine({
25 variant = "default",
26 prefix,
27 preserveWhitespace = false,
28 className,
29 children,
30 style,
31 ...props
32 }: TerminalLineProps) {
33 return (
34 <div
35 className={cn(
36 "flex min-w-0 items-start gap-2 py-0.5",
37 lineVariantClasses[variant],
38 className
39 )}
40 style={style}
41 {...props}
42 >
43 {prefix ? <span className="shrink-0 select-none">{prefix}</span> : null}
44 <div
45 className={cn(
46 "min-w-0 flex-1 break-words",
47 preserveWhitespace ? "whitespace-pre-wrap" : "whitespace-normal"
48 )}
49 >
50 {children}
51 </div>
52 </div>
53 )
54 }
55
56 export type TerminalPromptProps = React.HTMLAttributes<HTMLSpanElement> & {
57 symbol?: string
58 tone?: "input" | "command"
59 }
60
61 export function TerminalPrompt({
62 symbol = "❯",
63 tone = "command",
64 className,
65 ...props
66 }: TerminalPromptProps) {
67 return (
68 <span
69 className={cn("terminal-prompt shrink-0 select-none", className)}
70 style={{
71 color:
72 tone === "input" ? "var(--terminal-teal)" : "var(--terminal-green)",
73 fontSize: tone === "input" ? 9 : undefined,
74 lineHeight: tone === "input" ? "16px" : undefined,
75 display: tone === "input" ? "inline-flex" : undefined,
76 alignItems: tone === "input" ? "center" : undefined,
77 height: tone === "input" ? 16 : undefined,
78 }}
79 {...props}
80 >
81 {symbol}
82 </span>
83 )
84 }
85