MCPcopy Create free account
hub / github.com/Remocn/remocn / CodeBlockCommand

Function CodeBlockCommand

components/docs/code-block-command.tsx:37–135  ·  view source on GitHub ↗
({
  prompt,
  pnpm,
  yarn,
  npm,
  bun,
  component,
  variant = "muted",
}: CodeBlockCommandProps)

Source from the content-addressed store, hash-verified

35 */
36 variant?: "muted" | "outline" | "plain";
37}
38
39export function CodeBlockCommand({
40 prompt,
41 pnpm,
42 yarn,
43 npm,
44 bun,
45 component,
46 variant = "muted",
47}: CodeBlockCommandProps) {
48 const [packageManager, setPackageManager] = usePackageManager();
49 const trackEvent = useTrackEvent();
50
51 const tabs = useMemo(
52 () => ({ prompt, pnpm, yarn, npm, bun }),
53 [prompt, pnpm, yarn, npm, bun],
54 );
55
56 const tabsFiltered = useMemo(
57 () => Object.entries(tabs).filter(([, value]) => !!value),
58 [tabs],
59 );
60
61 const activeCommand = tabs[packageManager] || "";
62
63 return (
64 <div
65 className={cn(
66 "not-prose relative overflow-hidden rounded-xl",
67 variant === "outline" && "border border-border bg-card",
68 variant === "muted" && "bg-muted",
69 )}
70 >
71 <TabsPrimitive.Root
72 value={packageManager}
73 onValueChange={(value) => setPackageManager(value as PackageManager)}
74 className="flex flex-col"
75 >
76 <div className="px-4 shadow-[inset_0_-1px_0_0] shadow-border">
77 <TabsPrimitive.List className="relative z-0 flex h-10 w-fit items-center gap-1 [&_svg]:me-2 [&_svg]:size-4 [&_svg]:text-muted-foreground">
78 {getIconForPackageManager(packageManager)}
79
80 {tabsFiltered.map(([key]) => (
81 <TabsPrimitive.Tab
82 key={key}
83 value={key}
84 className={cn(
85 "relative h-7 rounded-md px-2 font-mono text-sm font-medium whitespace-nowrap transition-colors outline-none",
86 "text-muted-foreground hover:text-foreground",
87 "data-active:text-foreground",
88 "focus-visible:ring-2 focus-visible:ring-ring/40",
89 )}
90 >
91 {key}
92 </TabsPrimitive.Tab>
93 ))}
94

Callers

nothing calls this directly

Calls 4

useTrackEventFunction · 0.90
cnFunction · 0.90
usePackageManagerFunction · 0.85
getIconForPackageManagerFunction · 0.85

Tested by

no test coverage detected