Skip to content
Myr

install-page.tsx

This file

Path

apps/web/src/features/agents/install-page.tsx

204 lines · 6.5 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–204why, one step back
1import type { SetupInput, SetupSnippet } from "@repo/agent-kit/agent-setup";
2import { installChannels } from "@repo/agent-kit/install-channels";3import type {4 InstallChannel,5 InstallLink,6} from "@repo/agent-kit/install-channels";7import { Check, Copy } from "lucide-react";8import { Fragment } from "react";910import { Button } from "../../components/ui/button.tsx";11import {12 Tabs,13 TabsContent,14 TabsList,15 TabsTrigger,16} from "../../components/ui/tabs.tsx";17import { signInHref } from "../auth/session-slot.tsx";18import { LINK } from "../shared/classes.ts";19import { CommandLine } from "../shared/command.tsx";20import { useCopy } from "../shared/copy-action.tsx";21import { AppLink } from "../shared/link.tsx";22import { docsPath, EXPLORE_PATH, INSTALL_PATH } from "../shared/paths.ts";23import { GUTTER } from "../shared/shell/gutter.ts";2425export const INSTALL_TITLE = "Install";2627const SIGN_IN_PATH = "/auth/signin";2829export const INSTALL_LEDE =30 "Every way in reaches the same gate and hears the same refusals. Install the CLI for a terminal, connect an agent over MCP, or point anything that reads text at llms.txt.";3132/** A config file or a sentence to paste: kept as written, scrolled sideways, never wrapped. */33const SnippetBlock = ({ snippet }: { readonly snippet: SetupSnippet }) => {34 const { copied, copy } = useCopy(snippet.text);3536 return (37 <div className="border-rule bg-surface flex max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3">38 <pre39 aria-label={snippet.label}40 className={`text-mono leading-terminal min-w-0 flex-1 overflow-x-auto py-0.5 font-mono ${41 snippet.language === "text" ? "whitespace-pre-wrap" : "whitespace-pre"42 }`}43 // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- a scrolling region must take focus to be scrolled without a pointer (WCAG 2.1.1)44 tabIndex={0}45 >46 <code className="select-all">{snippet.text}</code>47 </pre>48 <Button49 className="shrink-0"50 onClick={copy}51 size="sm"52 type="button"53 variant="ghost"54 >55 {copied ? <Check aria-hidden="true" /> : <Copy aria-hidden="true" />}56 <span aria-live="polite">{copied ? "Copied" : "Copy"}</span>57 </Button>58 </div>59 );60};6162const Snippet = ({ snippet }: { readonly snippet: SetupSnippet }) => (63 <figure className="flex min-w-0 flex-col gap-1.5">64 <figcaption className="text-ui text-muted-foreground">65 {snippet.label}66 </figcaption>67 {snippet.language === "sh" ? (68 <CommandLine command={snippet.text} />69 ) : (70 <SnippetBlock snippet={snippet} />71 )}72 </figure>73);7475/** One snippet at a time, each in its panel; every panel is in the page, so the HTML carries every snippet. */76const SnippetTabs = ({77 snippets,78}: {79 readonly snippets: readonly SetupSnippet[];80}) => (81 <Tabs defaultValue={snippets[0]?.name}>82 <TabsList variant="line">83 {snippets.map(({ name }) => (84 <TabsTrigger key={name} value={name}>85 {name}86 </TabsTrigger>87 ))}88 </TabsList>89 {snippets.map((snippet) => (90 <TabsContent91 className="pt-2"92 keepMounted93 key={snippet.name}94 value={snippet.name}95 >96 <Snippet snippet={snippet} />97 </TabsContent>98 ))}99 </Tabs>100);101102/** Signing in brings the reader back here, as the top bar's control does. */103export const installHref = ({ path }: InstallLink) =>104 path === SIGN_IN_PATH ? signInHref(INSTALL_PATH) : path;105106/** A page of the web through the router; a file or a server page the web serves as a plain link. */107const Reference = ({ link }: { readonly link: InstallLink }) =>108 link.page ? (109 <AppLink className={`text-foreground ${LINK}`} to={link.path}>110 {link.label}111 </AppLink>112 ) : (113 <a className={`text-foreground ${LINK}`} href={installHref(link)}>114 {link.label}115 </a>116 );117118const References = ({ links }: { readonly links: readonly InstallLink[] }) =>119 links.length === 0 ? null : (120 <p className="text-ui text-muted-foreground mt-auto pt-1">121 {links.map((link, index) => (122 <Fragment key={link.path}>123 {index === 0 ? null : " · "}124 <Reference link={link} />125 </Fragment>126 ))}127 </p>128 );129130/** None for a channel with no command, tabs where a channel offers one of several, else each in turn. */131const Snippets = ({ channel }: { readonly channel: InstallChannel }) => {132 if (channel.snippets.length === 0) {133 return null;134 }135136 return channel.tabbed ? (137 <SnippetTabs snippets={channel.snippets} />138 ) : (139 <div className="flex min-w-0 flex-col gap-4">140 {channel.snippets.map((snippet) => (141 <Snippet key={snippet.name} snippet={snippet} />142 ))}143 </div>144 );145};146147const ChannelCard = ({ channel }: { readonly channel: InstallChannel }) => (148 <section149 aria-labelledby={channel.id}150 className={`bg-card flex min-w-0 flex-col gap-3 rounded-md border p-4 ${151 channel.planned ? "border-rule border-dashed" : "border-rule"152 }`}153 >154 <div className="flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1">155 {/* The anchor's target: its margin clears the sticky top bar, with room above the title. */}156 <h2157 className="text-title scroll-mt-[calc(var(--top-bar)+1.5rem)]"158 id={channel.id}159 >160 {channel.title}161 </h2>162 <p className="text-label text-muted-foreground ml-auto">163 {channel.audience}164 </p>165 </div>166 <p className="max-w-(--measure)">{channel.summary}</p>167 <Snippets channel={channel} />168 <References links={channel.links} />169 </section>170);171172export const InstallView = (input: SetupInput) => (173 <main174 className={`flex min-w-0 flex-1 flex-col gap-8 pt-8 pb-16 outline-none ${GUTTER}`}175 id="main"176 tabIndex={-1}177 >178 <div className="flex max-w-(--measure) flex-col gap-3">179 <h1 className="text-headline">{INSTALL_TITLE}</h1>180 <p className="text-want text-muted-foreground font-normal">181 {INSTALL_LEDE}182 </p>183 </div>184 <div className="columns:grid-cols-2 grid items-start gap-5">185 {installChannels(input).map((channel) => (186 <ChannelCard channel={channel} key={channel.id} />187 ))}188 </div>189 <p className="text-ui text-muted-foreground">190 Next:{" "}191 <AppLink192 className={`text-foreground ${LINK}`}193 to={docsPath("answer-an-ask")}194 >195 answer an ask196 </AppLink>197 , or{" "}198 <AppLink className={`text-foreground ${LINK}`} to={EXPLORE_PATH}>199 explore the projects200 </AppLink>201 .202 </p>203 </main>204);