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/image.tsx
Views: 687
/*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 { CSSProperties } from "react";11import { MediaURL } 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?: CSSProperties;25alt: string;26width?: number;27height?: number;28priority?: boolean;29}3031export default function Image(props: Props) {32const { src, style, alt, width, height } = props;33if (typeof src === "string") {34return (35<img36src={MediaURL(src)}37style={{ ...style, maxWidth: "100%" }}38alt={alt}39width={width}40height={height}41/>42);43}4445// if (height != null && width != null) {46// return (47// <NextImage48// src={src.src}49// alt={alt}50// height={height}51// width={width}52// priority={priority}53// />54// );55// }5657if (width != null) {58return (59<img60src={src.src}61height={height}62width={width}63alt={alt}64style={{ ...style, maxWidth: "100%" }}65/>66);67}68return (69<div70style={{71width: "100%",72...style,73display: "inline-block",74}}75>76<div style={{ position: "relative", width: "100%" }}>77<img78src={src.src}79height={height}80width={width}81alt={alt}82style={{ ...style, maxWidth: "100%" }}83/>84</div>85</div>86);87}888990