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: add helpful resources to the home page and dropdown (#3929)
Myles Scolnicka60e0ccca098
diff --git a/frontend/src/components/app-config/user-config-form.tsx b/frontend/src/components/app-config/user-config-form.tsxindex 267e052637..bc44a7174a 100644--- a/frontend/src/components/app-config/user-config-form.tsx+++ b/frontend/src/components/app-config/user-config-form.tsx@@ -48,6 +48,7 @@ import { KNOWN_AI_MODELS } from "./constants";import { Textarea } from "../ui/textarea";import { get } from "lodash-es";import { Tooltip } from "../ui/tooltip";+import { getMarimoVersion } from "@/core/dom/marimo-tag";const formItemClasses = "flex flex-row items-center space-x-1 space-y-0";@@ -1168,6 +1169,11 @@ export const UserConfigForm: React.FC = () => {</div></TabsTrigger>))}++ <div className="p-2 text-xs text-muted-foreground self-start">+ <span>Version: {getMarimoVersion()}</span>+ </div>+<div className="flex-1" />{!isWasm() && configMessage}</TabsList>diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsxindex 0459871662..0d5cb9b2d6 100644--- a/frontend/src/components/editor/actions/useNotebookActions.tsx+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx@@ -32,6 +32,11 @@ import {FastForwardIcon,DatabaseIcon,EyeOffIcon,+ ExternalLinkIcon,+ FileTextIcon,+ GithubIcon,+ MessagesSquareIcon,+ YoutubeIcon,} from "lucide-react";import { commandPaletteAtom } from "../controls/command-palette";import {@@ -75,6 +80,7 @@ import { useRunAllCells } from "../cell/useRunCells";import { settingDialogAtom } from "@/components/app-config/state";import { AddDatabaseDialogContent } from "../database/add-database-form";import { useHideAllMarkdownCode } from "./useHideAllMarkdownCode";+import { Constants } from "@/core/constants";const NOOP_HANDLER = (event?: Event) => {event?.preventDefault();@@ -419,10 +425,53 @@ export function useNotebookActions() {icon: <BookMarkedIcon size={14} strokeWidth={1.5} />,label: "Open documentation",handle: () => {- window.open("https://docs.marimo.io", "_blank");+ window.open(Constants.docsPage, "_blank");},},+ {+ icon: <ExternalLinkIcon size={14} strokeWidth={1.5} />,+ label: "Resources",+ handle: NOOP_HANDLER,+ dropdown: [+ {+ icon: <BookMarkedIcon size={14} strokeWidth={1.5} />,+ label: "Documentation",+ handle: () => {+ window.open(Constants.docsPage, "_blank");+ },+ },+ {+ icon: <GithubIcon size={14} strokeWidth={1.5} />,+ label: "GitHub",+ handle: () => {+ window.open(Constants.githubPage, "_blank");+ },+ },+ {+ icon: <MessagesSquareIcon size={14} strokeWidth={1.5} />,+ label: "Discord Community",+ handle: () => {+ window.open(Constants.discordLink, "_blank");+ },+ },+ {+ icon: <YoutubeIcon size={14} strokeWidth={1.5} />,+ label: "YouTube",+ handle: () => {+ window.open(Constants.youtube, "_blank");+ },+ },+ {+ icon: <FileTextIcon size={14} strokeWidth={1.5} />,+ label: "Changelog",+ handle: () => {+ window.open(Constants.releasesPage, "_blank");+ },+ },+ ],+ },+{divider: true,icon: <Home size={14} strokeWidth={1.5} />,diff --git a/frontend/src/components/home/components.tsx b/frontend/src/components/home/components.tsxnew file mode 100644index 0000000000..cd325a5604--- /dev/null+++ b/frontend/src/components/home/components.tsx@@ -0,0 +1,188 @@+/* Copyright 2024 Marimo. All rights reserved. */+import { openTutorial } from "@/core/network/requests";+import type React from "react";+import {+ ActivityIcon,+ BarChart2Icon,+ BookOpenIcon,+ DatabaseIcon,+ FileIcon,+ FileTextIcon,+ GraduationCapIcon,+ GridIcon,+ LayoutIcon,+ OrbitIcon,+ GithubIcon,+ LinkIcon,+ BookMarkedIcon,+ MessagesSquareIcon,+ YoutubeIcon,+} from "lucide-react";+import { Button } from "@/components/ui/button";+import type { TutorialId } from "@/core/network/types";+import { MarkdownIcon } from "@/components/editor/cell/code/icons";+import { asURL } from "@/utils/url";+import {+ DropdownMenu,+ DropdownMenuTrigger,+ DropdownMenuContent,+ DropdownMenuItem,+} from "@/components/ui/dropdown-menu";+import { Objects } from "@/utils/objects";+import { CaretDownIcon } from "@radix-ui/react-icons";+import { Constants } from "@/core/constants";++const TUTORIALS: Record<+ TutorialId,+ [string, React.FC<React.SVGProps<SVGSVGElement>>, string]+> = {+ intro: ["Introduction", BookOpenIcon, "Get started with marimo basics"],+ dataflow: [+ "Dataflow",+ ActivityIcon,+ "Learn how cells interact with each other",+ ],+ ui: ["UI Elements", LayoutIcon, "Create interactive UI components"],+ markdown: [+ "Markdown",+ FileTextIcon,+ "Format text with parameterized markdown",+ ],+ plots: ["Plots", BarChart2Icon, "Create interactive visualizations"],+ sql: ["SQL", DatabaseIcon, "Query databases directly in marimo"],+ layout: ["Layout", GridIcon, "Customize the layout of your cells' output"],+ fileformat: [+ "File format",+ FileIcon,+ "Understand marimo's pure-Python file format",+ ],+ "for-jupyter-users": [+ "For Jupyter users",+ OrbitIcon,+ "Transiting from Jupyter to marimo",+ ],+ "markdown-format": [+ "Markdown format",+ MarkdownIcon,+ "Using marimo to edit markdown files",+ ],+};++export const OpenTutorialDropDown: React.FC = () => {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild={true}>+ <Button data-testid="open-tutorial-button" size="xs" variant="outline">+ <GraduationCapIcon className="w-4 h-4 mr-2" />+ Tutorials+ <CaretDownIcon className="w-3 h-3 ml-1" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent side="bottom" align="end" className="no-print">+ {Objects.entries(TUTORIALS).map(+ ([tutorialId, [label, Icon, description]]) => (+ <DropdownMenuItem+ key={tutorialId}+ onSelect={async () => {+ const file = await openTutorial({ tutorialId });+ if (!file) {+ return;+ }+ window.open(asURL(`?file=${file.path}`).toString(), "_blank");+ }}+ >+ <Icon+ strokeWidth={1.5}+ className="w-4 h-4 mr-3 self-start mt-1.5 text-muted-foreground"+ />+ <div className="flex items-center">+ <div className="flex flex-col">+ <span>{label}</span>+ <span className="text-xs text-muted-foreground pr-1">+ {description}+ </span>+ </div>+ </div>+ </DropdownMenuItem>+ ),+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ );+};++const RESOURCES = [+ {+ title: "Documentation",+ description: "Official marimo documentation and API reference",+ icon: BookMarkedIcon,+ url: Constants.docsPage,+ },+ {+ title: "GitHub",+ description: "View source code, report issues, or contribute",+ icon: GithubIcon,+ url: Constants.githubPage,+ },+ {+ title: "Community",+ description: "Join the marimo Discord community",+ icon: MessagesSquareIcon,+ url: Constants.discordLink,+ },+ {+ title: "YouTube",+ description: "Watch tutorials and demos",+ icon: YoutubeIcon,+ url: Constants.youtube,+ },+ {+ title: "Changelog",+ description: "See what's new in marimo",+ icon: FileTextIcon,+ url: Constants.releasesPage,+ },+];++export const ResourceLinks: React.FC = () => {+ return (+ <div className="flex flex-col gap-2">+ <Header Icon={LinkIcon}>Resources</Header>+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">+ {RESOURCES.map((resource) => (+ <a+ key={resource.title}+ href={resource.url}+ target="_blank"+ rel="noreferrer"+ className="flex items-start gap-3 py-3 px-3 rounded-lg border hover:bg-accent/20 transition-colors shadow-xs"+ >+ <resource.icon className="w-5 h-5 mt-1.5 text-primary" />+ <div>+ <h3 className="font-medium">{resource.title}</h3>+ <p className="text-sm text-muted-foreground">+ {resource.description}+ </p>+ </div>+ </a>+ ))}+ </div>+ </div>+ );+};++export const Header: React.FC<{+ Icon: React.FC<React.SVGProps<SVGSVGElement>>;+ control?: React.ReactNode;+ children: React.ReactNode;+}> = ({ Icon, control, children }) => {+ return (+ <div className="flex items-center justify-between gap-2">+ <h2 className="flex items-center gap-2 text-xl font-semibold text-muted-foreground select-none">+ <Icon className="h-5 w-5" />+ {children}+ </h2>+ {control}+ </div>+ );+};diff --git a/frontend/src/components/pages/home-page.tsx b/frontend/src/components/pages/home-page.tsxindex 134275e698..3bfeb883a3 100644--- a/frontend/src/components/pages/home-page.tsx+++ b/frontend/src/components/pages/home-page.tsx@@ -4,29 +4,18 @@ import {getRecentFiles,getRunningNotebooks,shutdownSession,- openTutorial,} from "@/core/network/requests";import { combineAsyncData, useAsyncData } from "@/hooks/useAsyncData";import type React from "react";import { Suspense, useContext, useEffect, useRef, useState } from "react";import { Spinner } from "../icons/spinner";import {- ActivityIcon,- BarChart2Icon,- BookOpenIcon,BookTextIcon,ChevronDownIcon,ChevronRightIcon,ChevronsDownUpIcon,ClockIcon,- DatabaseIcon,ExternalLinkIcon,- FileIcon,- FileTextIcon,- GraduationCapIcon,- GridIcon,- LayoutIcon,- OrbitIcon,PlayCircleIcon,PowerOffIcon,RefreshCcwIcon,@@ -45,7 +34,7 @@ import { assertExists } from "@/utils/assertExists";import { Button } from "@/components/ui/button";import { Tooltip } from "@/components/ui/tooltip";import { toast } from "@/components/ui/use-toast";-import type { FileInfo, MarimoFile, TutorialId } from "@/core/network/types";+import type { FileInfo, MarimoFile } from "@/core/network/types";import { ConfigButton } from "../app-config/app-config-button";import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";@@ -74,18 +63,15 @@ import {import { Maps } from "@/utils/maps";import { Input } from "../ui/input";import { Paths } from "@/utils/paths";-import {- DropdownMenu,- DropdownMenuTrigger,- DropdownMenuContent,- DropdownMenuItem,-} from "@/components/ui/dropdown-menu";-import { Objects } from "@/utils/objects";-import { CaretDownIcon } from "@radix-ui/react-icons";import { ErrorBoundary } from "../editor/boundary/ErrorBoundary";import { Banner } from "@/plugins/impl/common/error-banner";import { prettyError } from "@/utils/errors";import { newNotebookURL } from "@/utils/urls";+import {+ Header,+ OpenTutorialDropDown,+ ResourceLinks,+} from "../home/components";function tabTarget(path: string) {// Consistent tab target so we open in the same tab when clicking on the same notebook@@ -131,16 +117,17 @@ const HomePage: React.FC = () => {setRunningNotebooks: runningResponse.setData,}}>- <div className="absolute top-3 right-5 flex gap-2 z-50">+ <div className="absolute top-3 right-5 flex gap-3 z-50"><OpenTutorialDropDown /><ConfigButton showAppConfig={false} /><ShutdownButtondescription={`This will shutdown the notebook server and terminate all running notebooks (${running.size}). You'll lose all data that's in memory.`}/></div>- <div className="flex flex-col gap-6 max-w-5xl container pt-5 pb-20 z-10">- <img src="logo.png" alt="marimo logo" className="w-64 mb-4" />+ <div className="flex flex-col gap-6 max-w-6xl container pt-5 pb-20 z-10">+ <img src="logo.png" alt="marimo logo" className="w-48 mb-2" /><CreateNewNotebook />+ <ResourceLinks /><NotebookListheader={<Header Icon={PlayCircleIcon}>Running notebooks</Header>}files={[...running.values()]}@@ -229,7 +216,7 @@ const CollapseAllButton: React.FC = () => {<Buttonvariant="text"size="sm"- className="h-fit"+ className="h-fit hidden sm:flex"onClick={() => {setOpenState({});}}@@ -396,22 +383,6 @@ const NotebookList: React.FC<{);};-const Header: React.FC<{- Icon: React.FC<React.SVGProps<SVGSVGElement>>;- control?: React.ReactNode;- children: React.ReactNode;-}> = ({ Icon, control, children }) => {- return (- <div className="flex items-center justify-between gap-2">- <h2 className="flex items-center gap-2 text-xl font-semibold text-muted-foreground select-none">- <Icon className="h-5 w-5" />- {children}- </h2>- {control}- </div>- );-};-const MarimoFileComponent = ({file,}: {@@ -529,7 +500,7 @@ const CreateNewNotebook: React.FC = () => {return (<aclassName="relative rounded-lg p-6 group- text-primary hover:bg-[var(--blue-2)] shadow-mdSolid shadow-accent border+ text-primary hover:bg-[var(--blue-2)] shadow-mdSolid shadow-accent border bg-[var(--blue-1)]transition-all duration-300 cursor-pointer"href={url}@@ -544,51 +515,4 @@ const CreateNewNotebook: React.FC = () => {);};-const TUTORIALS: Record<- TutorialId,- [string, React.FC<React.SVGProps<SVGSVGElement>>]-> = {- intro: ["Introduction", BookOpenIcon],- dataflow: ["Dataflow", ActivityIcon],- ui: ["UI Elements", LayoutIcon],- markdown: ["Markdown", FileTextIcon],- plots: ["Plots", BarChart2Icon],- sql: ["SQL", DatabaseIcon],- layout: ["Layout", GridIcon],- fileformat: ["File format", FileIcon],- "for-jupyter-users": ["For Jupyter users", OrbitIcon],- "markdown-format": ["Markdown format", MarkdownIcon],-};--const OpenTutorialDropDown: React.FC = () => {- return (- <DropdownMenu>- <DropdownMenuTrigger asChild={true}>- <Button data-testid="open-tutorial-button" size="xs" variant="outline">- <GraduationCapIcon className="w-4 h-4 mr-2" />- Tutorials- <CaretDownIcon className="w-3 h-3 ml-1" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent side="bottom" className="no-print">- {Objects.entries(TUTORIALS).map(([tutorialId, [label, Icon]]) => (- <DropdownMenuItem- key={tutorialId}- onSelect={async () => {- const file = await openTutorial({ tutorialId });- if (!file) {- return;- }- window.open(asURL(`?file=${file.path}`).toString(), "_blank");- }}- >- <Icon strokeWidth={1.5} className="w-4 h-4 mr-2" />- {label}- </DropdownMenuItem>- ))}- </DropdownMenuContent>- </DropdownMenu>- );-};-export default HomePage;diff --git a/frontend/src/core/constants.ts b/frontend/src/core/constants.tsindex 76b730b7f3..63984ee99b 100644--- a/frontend/src/core/constants.ts+++ b/frontend/src/core/constants.ts@@ -1,9 +1,12 @@/* Copyright 2024 Marimo. All rights reserved. */export const Constants = {githubPage: "https://github.com/marimo-team/marimo",+ releasesPage: "https://github.com/marimo-team/marimo/releases",issuesPage: "https://github.com/marimo-team/marimo/issues",feedbackForm: "https://marimo.io/feedback",discordLink: "https://marimo.io/discord?ref=notebook",+ docsPage: "https://docs.marimo.io",+ youtube: "https://www.youtube.com/@marimo-team",};export const KnownQueryParams = {