Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/landing/header.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Layout, Tooltip } from "antd";6import Link from "next/link";7import { join } from "path";8import { IS_MOBILE } from "@cocalc/frontend/feature";9import { SoftwareEnvNames } from "@cocalc/util/consts/software-envs";10import { COLORS } from "@cocalc/util/theme";11import AccountNavTab from "components/account/navtab";12import Analytics from "components/analytics";13import DemoCell from "components/demo-cell";14import Logo from "components/logo";15import A from "components/misc/A";16import ChatGPTHelp from "components/openai/chatgpt-help";17import basePath from "lib/base-path";18import { useCustomize } from "lib/customize";19import SubNav, { Page, SubPage } from "./sub-nav";20import LiveDemo from "components/landing/live-demo";21import { Button } from "antd";22import { Icon } from "@cocalc/frontend/components/icon";2324const GAP = "4%";2526const SHOW_AI_CHAT: Readonly<string[]> = ["ai"] as const;2728export const LinkStyle: React.CSSProperties = {29color: "white",30marginRight: GAP,31display: "inline-block",32} as const;3334// The style shouldn't change the size of the label, e.g., don't35// use bold. Otherwise, everything moves a little when you select36// an option, which looks weird.37const SelectedStyle: React.CSSProperties = {38...LinkStyle,39color: COLORS.LANDING.TOP_BG,40borderBottom: "5px solid #c7d9f5",41} as const;4243interface Props {44page?: Page;45subPage?: SubPage;46runnableTag?: string; // if on cocalc.com and have jupyter api use this tag for a little runable editable demo Jupyter cell.47softwareEnv?: SoftwareEnvNames;48}4950export default function Header(props: Props) {51const { page, subPage, softwareEnv, runnableTag } = props;52const {53siteName,54termsOfServiceURL,55account,56onCoCalcCom,57openaiEnabled,58jupyterApiEnabled,59enabledPages,60} = useCustomize();6162if (basePath == null) return null;6364function ask() {65if (onCoCalcCom && !IS_MOBILE) {66return (67<span68style={{69float: "right",70width: "150px", // CRITICAL -- this is to prevent flicker -- see https://github.com/sagemathinc/cocalc/issues/650471}}72>73{true || account ? (74<LiveDemo context="header" type="primary" />75) : (76<Button77type="primary"78href="/support/new?type=question&subject=&body=&title=Ask%20Us%20Anything!"79>80<Icon name="question-circle" /> Contact81</Button>82)}83</span>84);85}86}8788return (89<>90<Analytics />91<Layout.Header92style={{93minHeight: "64px",94height: "auto",95lineHeight: "32px",96padding: "16px",97textAlign: "center",98}}99>100{ask()}101<A href="/">102{/* WARNING: This mess is all to support using the next/image component for the image via our Image component. It's ugly. */}103<div104style={{105position: "relative",106display: "inline-block",107top: "15px",108height: "40px",109width: "40px",110marginTop: "-30px",111marginRight: "64px",112}}113>114<Logo115type="icon"116style={{117height: "40px",118width: "40px",119position: "absolute",120}}121/>122</div>123</A>124{account && (125<Tooltip title={"Browse all of your projects"}>126<a style={LinkStyle} href={join(basePath, "projects")}>127Your Projects128</a>129</Tooltip>130)}131{enabledPages?.store && (132<A href="/store" style={page == "store" ? SelectedStyle : LinkStyle}>133Store134</A>135)}136{enabledPages?.features && (137<A138href="/features/"139style={page == "features" ? SelectedStyle : LinkStyle}140>141Features142</A>143)}144{/* supportedRoutes?.software && (145<A146href="/software"147style={page == "software" ? SelectedStyle : LinkStyle}148>149Software150</A>151)*/}152{enabledPages?.legal && (153<A154style={LinkStyle}155href={termsOfServiceURL}156title="View the terms of service and other legal documents."157>158Legal159</A>160)}161{enabledPages?.info && (162<A163style={page == "info" ? SelectedStyle : LinkStyle}164href="/info"165title="Documentation and links to resources for learning more about CoCalc"166>167Docs168</A>169)}170{enabledPages?.share && (171<Link172href={"/share/public_paths/page/1"}173style={page == "share" ? SelectedStyle : LinkStyle}174title="View files that people have published."175>176Share177</Link>178)}179{enabledPages?.support && (180<A181style={page == "support" ? SelectedStyle : LinkStyle}182href="/support"183title="Create and view support tickets"184>185Support186</A>187)}188{enabledPages?.news && (189<A190style={page == "news" ? SelectedStyle : LinkStyle}191href="/news"192title={`News about ${siteName}`}193>194News195</A>196)}197{enabledPages?.about.index && (198<A199style={page == "about" ? SelectedStyle : LinkStyle}200href="/about"201title={`About ${siteName}`}202>203About204</A>205)}206{account ? (207<AccountNavTab208style={page == "account" ? SelectedStyle : LinkStyle}209/>210) : (211<>212<A213style={page == "sign-up" ? SelectedStyle : LinkStyle}214href="/auth/sign-up"215title={`Sign up for a ${siteName} account.`}216>217Sign Up218</A>219<A220style={page == "sign-in" ? SelectedStyle : LinkStyle}221href="/auth/sign-in"222title={`Sign in to ${siteName} or create an account.`}223>224Sign In225</A>226</>227)}228{enabledPages?.auth.try && (229<A230style={page == "try" ? SelectedStyle : LinkStyle}231href={"/auth/try"}232title={`Try ${siteName} immediately without creating an account.`}233>234Try235</A>236)}{" "}237</Layout.Header>238<SubNav page={page} subPage={subPage} softwareEnv={softwareEnv} />239{openaiEnabled &&240onCoCalcCom &&241page === "features" &&242typeof subPage === "string" &&243SHOW_AI_CHAT.includes(subPage) ? (244<div style={{ width: "700px", maxWidth: "100%", margin: "15px auto" }}>245<ChatGPTHelp246size="large"247prompt={subPage ? `I am using ${subPage}.` : ""}248tag={`features-${subPage}`}249/>250</div>251) : undefined}252{jupyterApiEnabled && onCoCalcCom && runnableTag ? (253<DemoCell tag={runnableTag} />254) : undefined}255</>256);257}258259260