CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/app/logo.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { React, useTypedRedux } from "../app-framework";
7
import { APP_ICON } from "../art";
8
import { appBasePath } from "@cocalc/frontend/customize/app-base-path";
9
import { A } from "@cocalc/frontend/components/A";
10
import { Tooltip } from "antd";
11
12
const STYLE: React.CSSProperties = {
13
display: "inline-block",
14
backgroundSize: "contain",
15
backgroundRepeat: "no-repeat",
16
position: "relative",
17
} as const;
18
19
interface Props {
20
size: number;
21
}
22
23
export const AppLogo: React.FC<Props> = React.memo((props: Props) => {
24
const { size } = props;
25
const marginVal = Math.max(1, Math.round(size / 20));
26
const margin = `${marginVal}px`;
27
const dimension = `${size - 2 * marginVal}px`;
28
29
const logo_square: string | undefined = useTypedRedux(
30
"customize",
31
"logo_square"
32
);
33
34
const backgroundImage = `url('${logo_square ? logo_square : APP_ICON}')`;
35
36
return (
37
<A
38
href={appBasePath}
39
style={{
40
height: dimension,
41
width: dimension,
42
margin: margin,
43
display: "inline-block",
44
}}
45
>
46
<Tooltip
47
title="Open the main website in a new tab."
48
mouseEnterDelay={1}
49
mouseLeaveDelay={0}
50
placement="right"
51
>
52
<div
53
style={{
54
...STYLE,
55
height: dimension,
56
width: dimension,
57
backgroundImage,
58
}}
59
></div>
60
</Tooltip>
61
</A>
62
);
63
});
64
65