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/logo.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { isEmpty } from "lodash";67import { unreachable } from "@cocalc/util/misc";8import Image from "components/landing/image";9import useCustomize from "lib/use-customize";10import fullLogo from "public/logo/full.svg";11import icon from "public/logo/icon.svg";12import rectangular from "public/logo/rectangular.svg";13import { CSS } from "./misc";1415interface Props {16type: "rectangular" | "icon" | "full";17style?: React.CSSProperties;18width?: number; // px19priority?: boolean;20}2122export default function Logo(props: Props) {23const { priority, type } = props;24const { logoRectangularURL, logoSquareURL, siteName } = useCustomize();2526function config(): { alt: string; src: string; custom: boolean } {27switch (type) {28case "rectangular":29return {30alt: `Rectangular ${siteName} Logo`,31src: logoRectangularURL ? logoRectangularURL : rectangular,32custom: !!logoRectangularURL,33};34case "icon":35return {36alt: "CoCalc Logo Icon",37src: logoSquareURL ? logoSquareURL : icon,38custom: !!logoSquareURL,39};40case "full":41return {42alt: `${siteName} Logo`,43src: fullLogo,44custom: false,45};46default:47unreachable(type);48return { alt: "Logo", src: icon, custom: false };49}50}5152const { alt, src, custom } = config();5354const style: CSS = {55...(isEmpty(props.style) && { maxWidth: "100%" }),56...props.style,57};5859if (props.width) {60style.width = `${props.width}px`;61style.maxWidth = `${props.width}px`;62}6364if (type === "full" && logoSquareURL && logoRectangularURL) {65// we "fake" a full logo it by stacking the square logo on top of the rectangular one in a div66return (67<div68style={{69...props.style,70textAlign: "center",71marginLeft: "auto",72marginRight: "auto",73}}74>75<Image76alt={alt}77src={logoSquareURL}78style={{79width: "50%",80}}81/>82<div>83<Image84src={logoRectangularURL}85alt={alt}86style={{ width: "100%", marginTop: "1rem" }}87/>88</div>89</div>90);91} else if (custom) {92return <Image alt={alt} src={src} style={style} />;93} else {94return <Image alt={alt} src={src} style={style} priority={priority} />;95}96}979899