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/compare.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Alert, Table } from "antd";6import { ReactNode } from "react";78import { Icon } from "@cocalc/frontend/components/icon";9import { COLORS } from "@cocalc/util/theme";10import Contact from "components/landing/contact";11import { Text } from "components/misc";12import A from "components/misc/A";13import DATA from "./compare.json";1415function cmp(a, b) {16a = `${a}`;17b = `${b}`;18if (a < b) return -1;19if (a > b) return 1;20return 0;21}22interface Props {23name?: string;24disclaimer?: boolean;25title?: ReactNode;26}2728export default function Compare(props: Props) {29const { name, disclaimer, title } = props;30const v: JSX.Element[] = [];31for (const table of DATA) {32if (name != null && table.name != name) continue;33v.push(34<ComparisonTable35key={table.name}36table={table}37disclaimer={disclaimer}38title={title}39/>40);41}42return <div style={{ background: "white", width: "100%" }}>{v}</div>;43}4445// undefined = unknown46// null = "not applicable"47type SupportType = boolean | undefined | null;48type Support =49| SupportType50| string51| { type?: SupportType; note?: string; link?: string };5253interface TableData {54title: string;55link: string;56products: { key: string; name: string; link?: string }[];57rows: { [title_or_key: string]: Support }[];58}5960function ComparisonTable({61table,62disclaimer,63title,64}: {65table: TableData;66disclaimer?: boolean;67title: ReactNode;68}) {69const columns = [70{71title: "Feature",72dataIndex: "feature",73key: "feature",74width: "25%",75},76];77for (const product of table.products) {78columns.push({79width: `${75 / table.products.length}%`,80title: (product.link ? (81<A href={product.link} alt="Link to information about this product">82{product.name}83</A>84) : (85product.name86)) as any,87key: product.key,88dataIndex: product.key,89// @ts-ignore90render: (support?: Support) => {91if (support === undefined) {92return (93<Icon94name="question-circle"95style={{ color: COLORS.GRAY, fontSize: "20px" }}96/>97);98}99if (typeof support == "boolean" || support === null) {100return <SupportMarker type={support} />;101}102let type: SupportType;103let note: string | undefined;104let link: string | undefined = "";105if (typeof support == "string") {106type = true;107note = support;108} else {109type = support.type;110note = support.note;111link = support.link;112}113return (114<>115<SupportMarker type={type} /> {type !== undefined && <br />}116{note && (117<div style={{ color: "#666", fontSize: "9pt" }}>{note}</div>118)}119{link && (120<A style={{ fontSize: "7pt" }} href={link}>121{link}122</A>123)}124</>125);126},127sorter: (a, b) => cmp(a[product.key], b[product.key]),128});129}130return (131<div132style={{133margin: "auto",134padding: "30px",135overflowX: "auto",136}}137>138{title ? (139title140) : (141<h1 style={{ textAlign: "center" }}>142{table.title} 143<A144href={table.link}145style={{ fontSize: "11pt" }}146alt="Link to learn more about this"147>148learn more149</A>150</h1>151)}152<Table153dataSource={table.rows}154columns={columns}155bordered156pagination={false}157rowKey={"feature"}158/>159{disclaimer && <Disclaimer />}160</div>161);162}163164function SupportMarker({ type }) {165if (type === true) {166return <Icon name="check" style={{ color: "green", fontSize: "20px" }} />;167} else if (type === false) {168return <Icon name="times" style={{ color: "red", fontSize: "20px" }} />;169} else if (type === null) {170return <span style={{ color: "#888" }}>N/A</span>;171} else {172return null;173}174}175176export function Disclaimer() {177return (178<Alert179style={{ margin: "30px auto", maxWidth: "900px" }}180message=""181description={182<Text style={{ fontSize: "10pt" }}>183These comparisons were made in good faith; however, they may contain184errors, since we know CoCalc better and the products are constantly185improving. <Contact /> if anything looks wrong or incomplete!186</Text>187}188type="warning"189showIcon190/>191);192}193194195