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
feat(slides): add deck-level content alignment control (#10176)
Shahmir Varqha101ee417d609
diff --git a/frontend/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts b/frontend/src/components/editor/renderers/slides-layout/__tests__/plugin.test.tsindex bc0aab9182..0ce0f79955 100644--- a/frontend/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts+++ b/frontend/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts@@ -42,6 +42,23 @@ describe("SlidesLayoutPlugin validator", () => {}).success,).toBe(false);});++ it("accepts each valid deck vertical alignment", () => {+ for (const verticalAlign of ["top", "center", "bottom"]) {+ expect(+ SlidesLayoutPlugin.validator.safeParse({ deck: { verticalAlign } })+ .success,+ ).toBe(true);+ }+ });++ it("rejects an unknown deck vertical alignment", () => {+ expect(+ SlidesLayoutPlugin.validator.safeParse({+ deck: { verticalAlign: "middle" },+ }).success,+ ).toBe(false);+ });});describe("SlidesLayoutPlugin deserializeLayout", () => {@@ -268,6 +285,18 @@ const BACKWARDS_COMPAT_SNAPSHOTS: BackwardsCompatCase[] = [],},},+ {+ // `verticalAlign` was added to DeckConfig.+ label: "deck.verticalAlign round-trips through validate + (de)serialize",+ input: {+ cells: [{}],+ deck: { transition: "fade", verticalAlign: "top" },+ },+ expected: {+ deck: { transition: "fade", verticalAlign: "top" },+ cellIds: ["a"],+ },+ },];describe("SlidesLayoutPlugin backwards compatibility", () => {diff --git a/frontend/src/components/editor/renderers/slides-layout/types.ts b/frontend/src/components/editor/renderers/slides-layout/types.tsindex 3f395fa9bb..f4841380d7 100644--- a/frontend/src/components/editor/renderers/slides-layout/types.ts+++ b/frontend/src/components/editor/renderers/slides-layout/types.ts@@ -23,8 +23,12 @@ const DeckTransitionSchema = z.enum([]);export type DeckTransition = z.infer<typeof DeckTransitionSchema>;+const DeckVerticalAlignSchema = z.enum(["top", "center", "bottom"]);+export type DeckVerticalAlign = z.infer<typeof DeckVerticalAlignSchema>;+const DeckConfigSchema = z.looseObject({transition: DeckTransitionSchema.optional(),+ verticalAlign: DeckVerticalAlignSchema.optional(),});export type DeckConfig = z.infer<typeof DeckConfigSchema>;diff --git a/frontend/src/components/slides/reveal-component.tsx b/frontend/src/components/slides/reveal-component.tsxindex 8c01205644..7c7e1a3d3c 100644--- a/frontend/src/components/slides/reveal-component.tsx+++ b/frontend/src/components/slides/reveal-component.tsx@@ -1,6 +1,7 @@/* Copyright 2026 Marimo. All rights reserved. */import {+ type CSSProperties,startTransition,useEffect,useMemo,@@ -26,6 +27,7 @@ import { Logger } from "@/utils/Logger";import "./slides.css";import "./reveal-slides.css";import type {+ DeckVerticalAlign,SlideConfig,SlidesLayout,SlideType,@@ -39,6 +41,7 @@ import {type ComposedSubslide,} from "./compose-slides";import {+ DEFAULT_DECK_VERTICAL_ALIGN,DEFAULT_DECK_TRANSITION,DEFAULT_SLIDE_TYPE,SlideSidebar,@@ -292,16 +295,38 @@ export function useParkedPreview(options: {};}+/**+ * Margin style that positions a slide's content vertically within the+ * full-height slide. The content is a flex item, so the vertical margins decide+ * where the free space lands: `auto` on both sides centers it, while pinning one+ * side to `0` pushes content to the top or bottom. The horizontal `20px` keeps+ * content off the slide edges regardless of alignment.+ */+function resolveSlideContentStyle(+ verticalAlign: DeckVerticalAlign | undefined,+): CSSProperties {+ switch (verticalAlign ?? DEFAULT_DECK_VERTICAL_ALIGN) {+ case "top":+ return { margin: "0 20px auto" };+ case "bottom":+ return { margin: "auto 20px 0" };+ default:+ return { margin: "auto 20px" };+ }+}+const SubslideView = ({subslide,resolveShowCode,isEditable,slideConfigs,+ contentStyle,}: {subslide: ComposedSubslide<RuntimeCell>;resolveShowCode: (cellId: CellId) => boolean;isEditable: boolean;slideConfigs: ReadonlyMap<CellId, SlideConfig>;+ contentStyle: CSSProperties;}) => {const { slideLevel, cumulativeByBlock } = buildSubslideNotes(subslide,@@ -321,9 +346,7 @@ const SubslideView = ({? "mo-slide-content flex flex-col gap-3": "mo-slide-content"}- style={{- margin: "auto 20px",- }}+ style={contentStyle}>{subslide.blocks.map((block, i) => {const rendered = block.cells.map((cell) => {@@ -514,6 +537,10 @@ const RevealSlidesComponent = ({);const deckTransition = layout.deck?.transition ?? DEFAULT_DECK_TRANSITION;+ const slideContentStyle = resolveSlideContentStyle(+ layout.deck?.verticalAlign,+ );+// Reveal's Notes plugin iframes the deck for the current/upcoming-slide// previews. We load the same URL but as a read-only kiosk client with the// app chrome hidden, which `<SlidesLayoutRenderer>` interprets the same as@@ -704,6 +731,7 @@ const RevealSlidesComponent = ({resolveShowCode={resolveShowCode}isEditable={isEditable}slideConfigs={layout.cells}+ contentStyle={slideContentStyle}/>);}@@ -717,6 +745,7 @@ const RevealSlidesComponent = ({resolveShowCode={resolveShowCode}isEditable={isEditable}slideConfigs={layout.cells}+ contentStyle={slideContentStyle}/>);})}@@ -743,7 +772,7 @@ const RevealSlidesComponent = ({? "mo-slide-content flex flex-col gap-3": "mo-slide-content"}- style={{ margin: "auto 20px" }}+ style={slideContentStyle}><ParkedPreviewContentcell={parkedPreviewCell}diff --git a/frontend/src/components/slides/slide-form.tsx b/frontend/src/components/slides/slide-form.tsxindex 34ff8dca1a..762c3da2a7 100644--- a/frontend/src/components/slides/slide-form.tsx+++ b/frontend/src/components/slides/slide-form.tsx@@ -23,6 +23,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import type { CellId } from "@/core/cells/ids";import { cn } from "@/utils/cn";import type {+ DeckVerticalAlign,DeckTransition,SlidesLayout,SlideType,@@ -37,6 +38,7 @@ import { jotaiJsonStorage } from "@/utils/storage/jotai";export const DEFAULT_SLIDE_TYPE: SlideType = "slide";export const DEFAULT_DECK_TRANSITION: DeckTransition = "slide";+export const DEFAULT_DECK_VERTICAL_ALIGN: DeckVerticalAlign = "center";const COLLAPSED_CONFIG_WIDTH = 36;const slideConfigOpenAtom = atomWithStorage<boolean>("marimo:slides:config-open",@@ -118,6 +120,30 @@ const DECK_TRANSITION_OPTIONS: DeckTransitionOption[] = [{ value: "zoom", label: "Zoom", description: "Zoom into the next slide." },];+interface DeckVerticalAlignOption {+ value: DeckVerticalAlign;+ label: string;+ description: string;+}++const DECK_VERTICAL_ALIGN_OPTIONS: DeckVerticalAlignOption[] = [+ {+ value: "center",+ label: "Center",+ description: "Vertically center each slide's content.",+ },+ {+ value: "top",+ label: "Top",+ description: "Align content to the top, like the cell view.",+ },+ {+ value: "bottom",+ label: "Bottom",+ description: "Align content to the bottom of each slide.",+ },+];+const SlidesForm = ({layout,setLayout,@@ -300,6 +326,12 @@ const DeckConfigForm = ({(opt) => opt.value === currentTransition,)?.description;+ const currentVerticalAlign: DeckVerticalAlign =+ layout.deck?.verticalAlign ?? DEFAULT_DECK_VERTICAL_ALIGN;+ const activeVerticalAlignDescription = DECK_VERTICAL_ALIGN_OPTIONS.find(+ (opt) => opt.value === currentVerticalAlign,+ )?.description;+const handleTransitionChange = (value: DeckTransition) => {setLayout({...layout,@@ -307,6 +339,13 @@ const DeckConfigForm = ({});};+ const handleVerticalAlignChange = (value: DeckVerticalAlign) => {+ setLayout({+ ...layout,+ deck: { ...layout.deck, verticalAlign: value },+ });+ };+return (<div className="flex flex-col gap-3"><div className="flex flex-col gap-1.5">@@ -337,6 +376,39 @@ const DeckConfigForm = ({<p className="text-xs text-foreground/70">{activeDescription}</p>)}</div>+ <div className="flex flex-col gap-1.5">+ <label+ htmlFor="deck-vertical-align"+ className="font-semibold text-sm text-foreground"+ >+ Vertical alignment+ </label>+ <Select+ value={currentVerticalAlign}+ onValueChange={(value) =>+ handleVerticalAlignChange(value as DeckVerticalAlign)+ }+ >+ <SelectTrigger+ id="deck-vertical-align"+ aria-label="Vertical alignment"+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {DECK_VERTICAL_ALIGN_OPTIONS.map(({ value, label }) => (+ <SelectItem key={value} value={value}>+ {label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ {activeVerticalAlignDescription && (+ <p className="text-xs text-foreground/70">+ {activeVerticalAlignDescription}+ </p>+ )}+ </div></div>);};