A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: fullscreen outputs (#1932)
Myles Scolnick43b6ea9889be
diff --git a/frontend/src/components/editor/Output.tsx b/frontend/src/components/editor/Output.tsxindex 23d09f0e27..6fa4930b60 100644--- a/frontend/src/components/editor/Output.tsx+++ b/frontend/src/components/editor/Output.tsx@@ -1,5 +1,6 @@/* Copyright 2024 Marimo. All rights reserved. */-import React, { memo, useEffect, useMemo, useRef, useState } from "react";+import React from "react";+import { memo, useEffect, useMemo, useRef, useState } from "react";import type { OutputMessage } from "@/core/kernel/messages";@@ -16,7 +17,11 @@ import { ErrorBoundary } from "./boundary/ErrorBoundary";import "./output/Outputs.css";import { Button } from "../ui/button";-import { ChevronsDownUpIcon, ChevronsUpDownIcon } from "lucide-react";+import {+ ChevronsDownUpIcon,+ ChevronsUpDownIcon,+ ExpandIcon,+} from "lucide-react";import { Tooltip } from "../ui/tooltip";import { useExpandedOutput } from "@/core/cells/outputs";import { invariant } from "@/utils/invariant";@@ -140,29 +145,30 @@ export const OutputArea = React.memo(({ output, cellId, stale, allowExpand, className }: OutputAreaProps) => {if (output === null) {return null;- } else if (output.channel === "output" && output.data === "") {+ }+ if (output.channel === "output" && output.data === "") {return null;- } else {- // TODO(akshayka): More descriptive title- // 1. This output is stale (this cell has been edited but not run)- // 2. This output is stale (this cell is queued to run)- // 3. This output is stale (its inputs have changed)- const title = stale ? "This output is stale" : undefined;- const Container = allowExpand ? ExpandableOutput : Div;-- return (- <ErrorBoundary>- <Container- title={title}- cellId={cellId}- id={`output-${cellId}`}- className={cn(stale && "marimo-output-stale", className)}- >- <OutputRenderer message={output} />- </Container>- </ErrorBoundary>- );}++ // TODO(akshayka): More descriptive title+ // 1. This output is stale (this cell has been edited but not run)+ // 2. This output is stale (this cell is queued to run)+ // 3. This output is stale (its inputs have changed)+ const title = stale ? "This output is stale" : undefined;+ const Container = allowExpand ? ExpandableOutput : Div;++ return (+ <ErrorBoundary>+ <Container+ title={title}+ cellId={cellId}+ id={`output-${cellId}`}+ className={cn(stale && "marimo-output-stale", className)}+ >+ <OutputRenderer message={output} />+ </Container>+ </ErrorBoundary>+ );},);OutputArea.displayName = "OutputArea";@@ -210,34 +216,51 @@ const ExpandableOutput = React.memo(return (<><div>- {(isOverflowing || isExpanded) && (- <div className="relative print:hidden">- <Button- data-testid="expand-output-button"- className={cn(- "absolute top-6 -right-12 z-10",- // Force show button if expanded- !isExpanded && "hover-action",- )}- onClick={() => setIsExpanded(!isExpanded)}- size="xs"- variant="text"- >- {isExpanded ? (- <Tooltip content="Collapse output" side="left">- <ChevronsDownUpIcon className="h-4 w-4" />- </Tooltip>- ) : (- <Tooltip content="Expand output" side="left">- <ChevronsUpDownIcon className="h-4 w-4" />- </Tooltip>- )}- </Button>+ <div className="relative print:hidden">+ <div className="absolute top-6 -right-11 z-10 flex flex-col gap-1">+ <Tooltip content="Fullscreen" side="left">+ <Button+ data-testid="fullscreen-output-button"+ className="hover-action hover:bg-muted"+ onClick={async () => {+ await containerRef.current?.requestFullscreen();+ }}+ size="xs"+ variant="text"+ >+ <ExpandIcon className="h-4 w-4" />+ </Button>+ </Tooltip>+ {(isOverflowing || isExpanded) && (+ <Button+ data-testid="expand-output-button"+ className={cn(+ // Force show button if expanded+ !isExpanded && "hover-action hover:bg-muted",+ )}+ onClick={() => setIsExpanded(!isExpanded)}+ size="xs"+ variant="text"+ >+ {isExpanded ? (+ <Tooltip content="Collapse output" side="left">+ <ChevronsDownUpIcon className="h-4 w-4" />+ </Tooltip>+ ) : (+ <Tooltip content="Expand output" side="left">+ <ChevronsUpDownIcon className="h-4 w-4" />+ </Tooltip>+ )}+ </Button>+ )}</div>- )}+ </div><div{...props}- className={cn("relative", props.className)}+ className={cn(+ "relative fullscreen:bg-background fullscreen:flex fullscreen:items-center fullscreen:justify-center",+ props.className,+ )}ref={containerRef}style={isExpanded ? { maxHeight: "none" } : undefined}>diff --git a/frontend/src/core/MarimoApp.tsx b/frontend/src/core/MarimoApp.tsxindex 2463bce3ca..074ec42b96 100644--- a/frontend/src/core/MarimoApp.tsx+++ b/frontend/src/core/MarimoApp.tsx@@ -84,7 +84,7 @@ const Providers = memo(({ children }: PropsWithChildren) => {return (<ErrorBoundary><Suspense>- <TooltipProvider>+ <TooltipProvider delayDuration={400}><DayPickerProvider initialProps={{}}><SlotzProvider controller={slotsController}><ModalProvider>diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.jsindex 828f1bf67e..9b89bac5c3 100644--- a/frontend/tailwind.config.js+++ b/frontend/tailwind.config.js@@ -169,7 +169,7 @@ module.exports = {plugins: [require("tailwindcss-animate"),require("@tailwindcss/typography"),- plugin(({ addUtilities }) => {+ plugin(({ addUtilities, addVariant }) => {const newUtilities = {".increase-pointer-area-x": {border: "none",@@ -193,6 +193,7 @@ module.exports = {},};+ addVariant("fullscreen", "&:fullscreen");addUtilities(newUtilities);}),],