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.

improvement: Add cell buttons at bottom (#1402)

Myles Scolnick92eddf7c72dc
diff --git a/frontend/src/components/editor/renderers/CellArray.tsx b/frontend/src/components/editor/renderers/CellArray.tsx
index 7c8ef8e704..ef59f92b2c 100644
--- a/frontend/src/components/editor/renderers/CellArray.tsx
+++ b/frontend/src/components/editor/renderers/CellArray.tsx
@@ -2,16 +2,16 @@
import { useEffect } from "react";
import { Cell } from "@/components/editor/Cell";
import {
- ConnectionStatus,
+ type ConnectionStatus,
WebSocketState,
} from "../../../core/websocket/types";
import {
- NotebookState,
+ type NotebookState,
flattenNotebookCells,
useCellActions,
} from "../../../core/cells/cells";
-import { AppConfig, UserConfig } from "../../../core/config/config-schema";
-import { AppMode } from "../../../core/mode";
+import type { AppConfig, UserConfig } from "../../../core/config/config-schema";
+import type { AppMode } from "../../../core/mode";
import { useHotkey } from "../../../hooks/useHotkey";
import { formatAll } from "../../../core/codemirror/format";
import { useTheme } from "../../../theme/useTheme";
@@ -22,6 +22,12 @@ import { Functions } from "@/utils/functions";
import { NotebookBanner } from "../notebook-banner";
import { PackageAlert } from "@/components/editor/package-alert";
import { useDeleteCellCallback } from "../cell/useDeleteCell";
+import { cn } from "@/utils/cn";
+import { Button } from "@/components/ui/button";
+import { SquareCodeIcon, SquareMIcon } from "lucide-react";
+import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
+import { autoInstantiateAtom } from "@/core/config/config";
+import { useAtomValue } from "jotai";
interface CellArrayProps {
notebook: NotebookState;
@@ -136,6 +142,50 @@ export const CellArray: React.FC<CellArrayProps> = ({
name={cell.name}
/>
))}
+ <AddCellButtons />
</VerticalLayoutWrapper>
);
};
+
+const AddCellButtons: React.FC = () => {
+ const { createNewCell } = useCellActions();
+ const autoInstantiate = useAtomValue(autoInstantiateAtom);
+
+ const buttonClass = cn(
+ "px-16 mb-0 rounded-none",
+ "hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs",
+ );
+
+ return (
+ <div className="flex justify-center mt-4 pt-6 pb-32 group gap-4">
+ <div className="shadow-smSolid border border-border rounded opacity-0 transition-all duration-200 group-hover:opacity-100 overflow-hidden divide-x divide-border">
+ <Button
+ className={buttonClass}
+ variant="text"
+ size="sm"
+ onClick={() => createNewCell({ cellId: "__end__", before: false })}
+ >
+ <SquareCodeIcon className="mr-2 size-4" />
+ Code
+ </Button>
+ <Button
+ className={buttonClass}
+ variant="text"
+ size="sm"
+ onClick={() => {
+ maybeAddMarimoImport(autoInstantiate, createNewCell);
+
+ createNewCell({
+ cellId: "__end__",
+ before: false,
+ code: 'mo.md(rf"""\n""")',
+ });
+ }}
+ >
+ <SquareMIcon className="mr-2 size-4" />
+ Markdown
+ </Button>
+ </div>
+ </div>
+ );
+};