Skip to content
328 linesCodeBlameRaw
1/**
2 * The site's footer: the logo, what g1t is and its accounts elsewhere as
3 * icons beside a few links worth having, then who makes g1t, and a row of
4 * the trust pages with the live status dot, the account, and the legal
5 * line. Marketing and signed-out pages show it; the app's account menu
6 * has its own rows (components/shell.tsx).
7 */
8import { GitBranch } from "lucide-react";
9import { useEffect, useState } from "react";
10import { Link } from "react-router";
11
12import type { User } from "@g1t/contracts";
13
14import { useAsksFirst } from "./analytics-consent";
15import { Logo, Mark } from "./logo";
16import { Button } from "./ui/button";
17import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
18import { choose } from "../lib/analytics-consent";
19import { COMPANY, MAKER_PRODUCTS, SOCIAL, copyright, listed } from "../lib/legal";
20import { type OverallState, STATUS_JSON_URL, STATUS_URL, STATUS_WORDS, type StatusReport, dotClass } from "../lib/status";
21
22/** How long one fetched report is reused across the pages of one visit. */
23const STATUS_REUSE_MS = 60_000;
24let lastStatus: { report: StatusReport; at: number } | null = null;
25let pendingStatus: Promise<StatusReport | null> | null = null;
26
27function fetchStatus(): Promise<StatusReport | null> {
28 if (lastStatus && Date.now() - lastStatus.at < STATUS_REUSE_MS) return Promise.resolve(lastStatus.report);
29 pendingStatus ??= fetch(STATUS_JSON_URL, { headers: { accept: "application/json" } })
30 .then((response) => (response.ok ? (response.json() as Promise<StatusReport>) : null))
31 .then((report) => {
32 if (report?.overall) lastStatus = { report, at: Date.now() };
33 return report?.overall ? report : null;
34 })
35 // The status page being unreachable only means no dot.
36 .catch(() => null)
37 .finally(() => {
38 pendingStatus = null;
39 });
40 return pendingStatus;
41}
42
43/**
44 * The live status, from status.g1t.sh once the page is up (or `when` turns
45 * true), so no page waits on it. Kept a minute across pages. Null until it
46 * arrives, or if it cannot.
47 */
48export function useSiteStatus(when = true): StatusReport | null {
49 const [report, setReport] = useState<StatusReport | null>(() => lastStatus?.report ?? null);
50 useEffect(() => {
51 if (!when) return;
52 let live = true;
53 fetchStatus().then((fresh) => {
54 if (live && fresh) setReport(fresh);
55 });
56 return () => {
57 live = false;
58 };
59 }, [when]);
60 return report;
61}
62
63/** The coloured dot, with words for screen readers. */
64export function StatusDot({ state, className = "" }: { state: OverallState | null; className?: string }) {
65 return (
66 <span className={`relative inline-flex size-2 shrink-0 ${className}`}>
67 {state && state !== "up" && state !== "unknown" && (
68 <span aria-hidden className={`absolute inset-0 animate-ping rounded-full opacity-60 ${dotClass(state)}`} />
69 )}
70 <span aria-hidden className={`relative inline-flex size-2 rounded-full ${dotClass(state)}`} />
71 <span className="sr-only">{state ? STATUS_WORDS[state] : "Checking status"}</span>
72 </span>
73 );
74}
75
76/** Where the footer's grid links go. Plain links: some are files or other hosts. */
77const FOOTER_LINKS: { title: string; links: [string, string][] }[] = [
78 {
79 title: "Product",
80 links: [
81 ["Explore", "/explore"],
82 ["Pricing", "/pricing"],
83 ["Download", "/download"],
84 ["Chat", "https://docs.g1t.sh/guides/chat/"],
85 ["Agents", "https://docs.g1t.sh/guides/agents/"],
86 ["Working with g1t", "https://docs.g1t.sh/guides/working-with-g1t/"],
87 ["Bring your own agent", "https://docs.g1t.sh/guides/bring-your-own-agent/"],
88 ["Integrations", "https://docs.g1t.sh/guides/integrations/"],
89 ],
90 },
91 {
92 title: "Developers",
93 links: [
94 ["Documentation", "https://docs.g1t.sh/"],
95 ["API reference", "https://docs.g1t.sh/reference/api/"],
96 ["MCP tools", "https://docs.g1t.sh/reference/mcp/"],
97 ["llms.txt", "/llms.txt"],
98 ],
99 },
100 {
101 title: "Company",
102 links: [
103 ["Flagon, Inc.", COMPANY.url],
104 ["Support", "/support"],
105 ["Security", "/security"],
106 ["Status", STATUS_URL],
107 ],
108 },
109 {
110 title: "Open source",
111 links: [
112 ["Source on g1t", "/flagon-io/g1t"],
113 ["MIT license", "/flagon-io/g1t/blob/main/LICENSE"],
114 ["Run g1t yourself", "https://docs.g1t.sh/guides/self-hosting/"],
115 ],
116 },
117];
118
119/** What the footer says under the logo. */
120const TAGLINE = "Your team and its agents, working in one place.";
121
122/** The icons under it: g1t's accounts elsewhere (lib/legal), then its source. */
123const ICON_LINKS: { label: string; url: string; icon: React.ReactNode }[] = [
124 ...SOCIAL.map((account) => ({
125 label: `g1t on ${account.label}`,
126 url: account.url,
127 icon: (
128 <svg viewBox="0 0 24 24" aria-hidden="true" fill="currentColor" className="size-4">
129 <path d={account.icon.path} />
130 </svg>
131 ),
132 })),
133 { label: "Source on g1t", url: "/flagon-io/g1t", icon: <GitBranch aria-hidden className="size-4" /> },
134];
135
136/** The footer's first column: the logo, the tagline and the icons. */
137function BrandColumn() {
138 return (
139 <div className="col-span-2 sm:col-span-4 lg:col-span-2 lg:pr-8">
140 <Link to="/" aria-label="g1t home" className="inline-flex rounded-sm">
141 <Logo />
142 </Link>
143 <p className="mt-3 max-w-xs text-sm leading-6 text-muted text-balance">{TAGLINE}</p>
144 <ul className="mt-4 -ml-2 flex items-center gap-1">
145 {ICON_LINKS.map((link) => (
146 <li key={link.url}>
147 <Tooltip>
148 <TooltipTrigger asChild>
149 <Button asChild variant="ghost" size="icon-sm">
150 <a href={link.url} aria-label={link.label}>
151 {link.icon}
152 </a>
153 </Button>
154 </TooltipTrigger>
155 <TooltipContent>{link.label}</TooltipContent>
156 </Tooltip>
157 </li>
158 ))}
159 </ul>
160 </div>
161 );
162}
163
164/** The row's own links, after Status. */
165const ROW_LINKS: [string, string][] = [
166 ["Support", "/support"],
167 ["Policies", "/policies"],
168 ["Privacy", "/policies/privacy"],
169 ["Security", "/security"],
170];
171
172/**
173 * Flagon's mark, single-ink, as in Flagon's brand files
174 * (flagon-mark-mono.svg): a flagon, its brew a tone of the text colour.
175 */
176function FlagonMark({ className = "" }: { className?: string }) {
177 return (
178 <svg viewBox="11.3 12.3 41 41" fill="none" aria-hidden="true" className={className}>
179 <defs>
180 <clipPath id="g1t-footer-flagon-body">
181 <path d="M19.5 23 L34.5 23 L36.5 46 Q36.7 48 34.3 48 L19.7 48 Q17.3 48 17.5 46 Z" />
182 </clipPath>
183 </defs>
184 <g clipPath="url(#g1t-footer-flagon-body)">
185 <path
186 d="M13 27 q3.75 -0.7 7.5 0 t7.5 0 t7.5 0 t7.5 0 t7.5 0 L51 52 L13 52 Z"
187 fill="currentColor"
188 fillOpacity="0.22"
189 />
190 </g>
191 <path
192 d="M37 27 L45.5 27 L48.5 30 L48.5 36.5 L45.5 39.5 L38 39.5"
193 stroke="currentColor"
194 strokeWidth="3.1"
195 strokeLinecap="round"
196 strokeLinejoin="round"
197 />
198 <path
199 d="M17.5 21 L36.5 21 L38.6 47 Q39 50 36 50 L18 50 Q15 50 15.4 47 Z"
200 stroke="currentColor"
201 strokeWidth="3.1"
202 strokeLinejoin="round"
203 />
204 <path d="M17 21 Q16.3 16.3 20 15.6 L33 15.6 Q37.2 16.2 37 21 Z" stroke="currentColor" strokeWidth="3" strokeLinejoin="round" />
205 <path d="M36.7 17.1 L39.4 16.1" stroke="currentColor" strokeWidth="2.4" strokeLinejoin="round" />
206 <circle cx="40.3" cy="15.8" r="1.4" fill="currentColor" />
207 </svg>
208 );
209}
210
211/** "g1t is designed, built, and backed by Flagon, Inc., …" */
212export function MakerLine() {
213 const products = MAKER_PRODUCTS.map((product) => product.name);
214 return (
215 <p className="text-sm leading-6 text-muted text-balance">
216 <Mark tight className="mr-1.5 inline-block h-[0.85em] w-auto align-baseline" />
217 <span className="font-semibold text-fg">g1t</span> is designed, built, and backed by{" "}
218 <a href={COMPANY.url} className="whitespace-nowrap font-semibold text-fg hover:underline hover:underline-offset-4">
219 <FlagonMark className="mr-1 inline-block size-[0.95em] -translate-y-px align-middle" />
220 {COMPANY.name}
221 </a>
222 {products.length > 0 ? `, the people behind ${listed(products)}.` : `, ${COMPANY.about} founded by ${COMPANY.founder}.`}
223 </p>
224 );
225}
226
227const ROW_LINK = "rounded-sm transition-colors hover:text-fg";
228
229/**
230 * Status, the trust pages, the account and the legal line, separated by
231 * dots that wrap away cleanly on a phone.
232 */
233export function LegalRow({ user }: { user: User | null | undefined }) {
234 const status = useSiteStatus();
235 const asksFirst = useAsksFirst();
236 const links = [
237 <a key="status" href={STATUS_URL} className={`inline-flex items-center gap-1.5 ${ROW_LINK}`}>
238 <StatusDot state={status?.overall.state ?? null} />
239 Status
240 </a>,
241 ...ROW_LINKS.map(([label, to]) => (
242 <Link key={to} to={to} className={ROW_LINK}>
243 {label}
244 </Link>
245 )),
246 // Where the visitor was asked about the analytics cookie: ask again.
247 ...(asksFirst
248 ? [
249 <button key="consent" type="button" onClick={() => choose(null)} className={ROW_LINK}>
250 Cookie choices
251 </button>,
252 ]
253 : []),
254 ];
255 const account = [
256 user ? (
257 <Link key="me" to={`/u/${user.username}`} className={`font-medium text-fg/90 ${ROW_LINK}`}>
258 {user.username}
259 </Link>
260 ) : (
261 <Link key="login" to="/login" className={ROW_LINK}>
262 Sign in
263 </Link>
264 ),
265 ];
266 const legal = [
267 ...account,
268 <span key="copyright" className="text-faint">
269 {copyright()}
270 </span>,
271 ];
272 const gap = "gap-x-3";
273 const dot = (
274 <span aria-hidden className="text-line-strong">
275 ·
276 </span>
277 );
278 // Two runs, the links and the legal line, so that on a narrow screen the
279 // second starts its own line rather than a line starting with a dot.
280 const run = (items: React.ReactNode[]) =>
281 items.map((item, index) => (
282 <li key={index} className={`flex items-center ${gap}`}>
283 {index > 0 && dot}
284 {item}
285 </li>
286 ));
287 return (
288 <div className={`flex flex-wrap items-center justify-center gap-y-1.5 ${gap} text-[0.8125rem] text-muted`}>
289 <ul className={`flex flex-wrap items-center justify-center gap-y-1.5 ${gap}`}>{run(links)}</ul>
290 {/* Between the two runs only while they share a line. */}
291 <span className="hidden md:inline">{dot}</span>
292 <ul className={`flex flex-wrap items-center justify-center gap-y-1.5 ${gap}`}>{run(legal)}</ul>
293 </div>
294 );
295}
296
297export function SiteFooter({ user }: { user: User | null | undefined }) {
298 return (
299 <footer className="mt-24 border-t border-line">
300 <div className="mx-auto grid max-w-6xl grid-cols-2 gap-x-8 gap-y-10 px-4 pt-12 pb-10 sm:grid-cols-4 lg:grid-cols-6">
301 <BrandColumn />
302 {/* The link columns sit in the same grid as the brand column. */}
303 <nav aria-label="Footer" className="contents">
304 {FOOTER_LINKS.map((group) => (
305 <div key={group.title}>
306 <p className="text-sm font-medium">{group.title}</p>
307 <ul className="mt-3 space-y-2 text-sm text-muted">
308 {group.links.map(([label, to]) => (
309 <li key={to}>
310 <a href={to} className="transition-colors hover:text-fg">
311 {label}
312 </a>
313 </li>
314 ))}
315 </ul>
316 </div>
317 ))}
318 </nav>
319 </div>
320 <div className="border-t border-line">
321 <div className="mx-auto max-w-3xl space-y-4 px-4 py-10 text-center">
322 <MakerLine />
323 <LegalRow user={user} />
324 </div>
325 </div>
326 </footer>
327 );
328}