Skip to content

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.

fix: fix top padding and add screenshots for max-width (#348)

Myles Scolnick6755faa5d4dc
diff --git a/frontend/e2e-tests/layout-grid.spec.ts b/frontend/e2e-tests/layout-grid.spec.ts
index c9a5cd89e7..c8d9ba1981 100644
--- a/frontend/e2e-tests/layout-grid.spec.ts
+++ b/frontend/e2e-tests/layout-grid.spec.ts
@@ -4,6 +4,7 @@ import { getAppUrl } from "../playwright.config";
import { takeScreenshot } from "./helper";
const runUrl = getAppUrl("layout_grid.py//run");
+const runMaxWidthUrl = getAppUrl("layout_grid_max_width.py//run");
const editUrl = getAppUrl("layout_grid.py//edit");
test("can run Grid layout", async ({ page }) => {
@@ -29,6 +30,17 @@ test("can run Grid layout", async ({ page }) => {
await takeScreenshot(page, __filename);
});
+test("can run Grid layout with max-width", async ({ page }) => {
+ await page.goto(runMaxWidthUrl);
+ // wait 500ms to render
+ await page.waitForTimeout(500);
+
+ // Verify markdown "Grid Layout"
+ await expect(page.getByText("Grid Layout")).toBeVisible();
+
+ await takeScreenshot(page, __filename);
+});
+
test("can edit Grid layout", async ({ page }) => {
await page.goto(editUrl);
diff --git a/frontend/e2e-tests/py/layout_grid_max_width.py b/frontend/e2e-tests/py/layout_grid_max_width.py
new file mode 100644
index 0000000000..c5c4fabe16
--- /dev/null
+++ b/frontend/e2e-tests/py/layout_grid_max_width.py
@@ -0,0 +1,45 @@
+import marimo
+
+__generated_with = "0.1.50"
+app = marimo.App(layout_file="layouts/layout_grid_max_width.grid.json")
+
+
+def __(mo):
+ mo.md("# Grid Layout")
+ return
+
+
+def __(mo, search):
+ mo.md(f"Searching {search.value}")
+ return
+
+
+def __(mo):
+ search = mo.ui.text(label="Search")
+ search
+ return search,
+
+
+def __(mo):
+ mo.md("text 1")
+ return
+
+
+def __(mo):
+ mo.md("text 2")
+ return
+
+
+def __():
+ import marimo as mo
+ return mo,
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/frontend/e2e-tests/py/layouts/layout_grid_max_width.grid.json b/frontend/e2e-tests/py/layouts/layout_grid_max_width.grid.json
new file mode 100644
index 0000000000..2b8243aabc
--- /dev/null
+++ b/frontend/e2e-tests/py/layouts/layout_grid_max_width.grid.json
@@ -0,0 +1,29 @@
+{
+ "type": "grid",
+ "data": {
+ "columns": 12,
+ "rowHeight": 40,
+ "maxWidth": 800,
+ "bordered": true,
+ "cells": [
+ {
+ "position": [0, 0, 5, 2]
+ },
+ {
+ "position": [0, 2, 4, 2]
+ },
+ {
+ "position": [5, 0, 5, 2]
+ },
+ {
+ "position": [3, 4, 3, 2]
+ },
+ {
+ "position": [0, 4, 3, 2]
+ },
+ {
+ "position": null
+ }
+ ]
+ }
+}
diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts
index f96775d530..608cfb2bd4 100644
--- a/frontend/playwright.config.ts
+++ b/frontend/playwright.config.ts
@@ -33,6 +33,7 @@ const appToOptions = {
"bugs.py": { port: port(), command: "edit" },
"layout_grid.py//edit": { port: port(), command: "edit" },
"layout_grid.py//run": { port: port(), command: "run" },
+ "layout_grid_max_width.py//run": { port: port(), command: "run" },
"output.py//run": { port: port(), command: "run" },
} satisfies Record<string, ServerOptions>;
diff --git a/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx b/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx
index 8ebf3b450f..2f30a8f31d 100644
--- a/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx
+++ b/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx
@@ -153,7 +153,7 @@ export const GridLayoutRenderer: React.FC<Props> = ({
layout.bordered &&
"border-t border-x rounded-t shadow-sm overflow-hidden",
// Add additional padding if bordered when reading
- layout.bordered && isReading && "mt-4 w-[calc(100%-2rem)]",
+ layout.bordered && isReading && "pt-4 w-[calc(100%-2rem)]",
!layout.maxWidth && "min-w-[800px]"
)}
margin={MARGIN}
@@ -266,7 +266,7 @@ export const GridLayoutRenderer: React.FC<Props> = ({
isLocked={isLocked}
setIsLocked={setIsLocked}
/>
- <div className={cn("relative flex gap-2 px-2 z-10")}>
+ <div className={cn("relative flex gap-2 px-2 z-10 flex-1")}>
<div
className={cn(
"flex-grow overflow-auto transparent-when-disconnected"
diff --git a/frontend/src/core/App.tsx b/frontend/src/core/App.tsx
index 4ac69404c2..ad704740ed 100644
--- a/frontend/src/core/App.tsx
+++ b/frontend/src/core/App.tsx
@@ -320,7 +320,8 @@ export const App: React.FC<AppProps> = ({ userConfig, appConfig }) => {
>
<div
className={cn(
- (isEditing || isPresenting) && "pt-4 sm:pt-12 pb-2 mb-4"
+ (isEditing || isPresenting) && "pt-4 sm:pt-12 pb-2 mb-4",
+ isReading && "sm:pt-8"
)}
>
{isEditing && (