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/components/close-x2.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 from "react";
7
import { CSS } from "@cocalc/frontend/app-framework";
8
import { Icon } from "./icon";
9
10
interface Props {
11
style?: React.CSSProperties;
12
close?: () => void;
13
}
14
15
const DEFAULT_STYLE: CSS = {
16
cursor: "pointer",
17
fontSize: "13pt",
18
};
19
20
function isSame(prev, next) {
21
if (prev == null || next == null) {
22
return false;
23
}
24
return prev.close != next.close;
25
}
26
27
export const CloseX2: React.FC<Props> = React.memo((props: Props) => {
28
const { close = undefined, style = DEFAULT_STYLE } = props;
29
30
if (!close) {
31
return null;
32
} else {
33
return (
34
<div className={"pull-right lighten"} style={style} onClick={close}>
35
<Icon name={"times"} />
36
</div>
37
);
38
}
39
}, isSame);
40
41