Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/src/packages/next/components/landing/image.tsx
Views: 923
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45// NOTE -- at this point, I'm completely giving up on next's image6// for now. It's always broken and the api keeps changing and it's7// too hard to work with.8// import NextImage from "next/image";910import { CSS } from "components/misc";11import { MediaURL, SHADOW } from "./util";1213// copied from https://github.com/vercel/next.js/blob/eb871d30915d668dd9ba897d4d04ced207ce2e6d/packages/next/image-types/global.d.ts14// since it seems not exported...15export interface StaticImageData {16src: string;17height: number;18width: number;19blurDataURL?: string;20}2122interface Props {23src: string | StaticImageData;24style?: CSS;25alt: string;26width?: number;27height?: number;28priority?: boolean;29shadow?: boolean;30}31323334export default function Image(props: Props) {35const { src, style, alt, width, height, shadow = false } = props;3637const imgStyle: CSS = {38...style,39...(shadow ? SHADOW : {}),40maxWidth: "100%",41} as const;4243if (typeof src === "string") {44return (45<img46src={MediaURL(src)}47style={imgStyle}48alt={alt}49width={width}50height={height}51/>52);53}5455// if (height != null && width != null) {56// return (57// <NextImage58// src={src.src}59// alt={alt}60// height={height}61// width={width}62// priority={priority}63// />64// );65// }6667if (width != null) {68return (69<img70src={src.src}71height={height}72width={width}73alt={alt}74style={imgStyle}75/>76);77}78return (79<div80style={{81width: "100%",82...style,83display: "inline-block",84}}85>86<div style={{ position: "relative", width: "100%" }}>87<img88src={src.src}89height={height}90width={width}91alt={alt}92style={imgStyle}93/>94</div>95</div>96);97}9899100