From 5f0c75cb70053400dbe62eb62eb2981dc313140b Mon Sep 17 00:00:00 2001 From: asrar Date: Mon, 2 Feb 2026 22:51:33 +0100 Subject: [PATCH 1/4] ui: Refactor ui --- img/chevron_down.svg | 2 +- src/Breadcrumbs.tsx | 124 ++++++++++++++++++++++++----------- src/Card.tsx | 14 +--- src/Home.tsx | 7 +- src/Menu.tsx | 2 + src/ModelHome.tsx | 4 +- src/NotebookCellRenderer.tsx | 2 +- src/PreviewResult.tsx | 2 +- src/QueryResult.tsx | 2 +- src/RenderedResult.tsx | 4 +- 10 files changed, 101 insertions(+), 62 deletions(-) diff --git a/img/chevron_down.svg b/img/chevron_down.svg index a26bd4c..76fc89b 100644 --- a/img/chevron_down.svg +++ b/img/chevron_down.svg @@ -2,6 +2,6 @@ cahevron_down - + \ No newline at end of file diff --git a/src/Breadcrumbs.tsx b/src/Breadcrumbs.tsx index 3be44c4..1d3923d 100644 --- a/src/Breadcrumbs.tsx +++ b/src/Breadcrumbs.tsx @@ -9,6 +9,7 @@ import { useRuntime } from "./contexts"; import MalloyCodeBlock from "./MalloyCodeBlock"; import { type JSX } from "react/jsx-runtime"; import ArrowLeftIcon from "../img/arrow-left.svg?react"; +import FaviconLogo from "../img/favicon-logo.svg?react"; import Menu from "./Menu"; export default Breadcrumbs; @@ -42,6 +43,9 @@ function Breadcrumbs({ models, notebooks }: BreadcrumbsProps): JSX.Element { return ( + + + - - Home - {isModelPage && modelName && ( - <> - / - ({ - name, - to: `/model/${encodeURIComponent(name)}`, - active: name === modelName, - }))} - isCurrent={!isExplorerPage && !isPreviewPage && !isQueryPage} - /> - > + ({ + name, + to: `/model/${encodeURIComponent(name)}`, + active: name === modelName, + }))} + isCurrent={!isExplorerPage && !isPreviewPage && !isQueryPage} + /> )} {isExplorerPage && sourceName && modelName && ( - + + )} + + {isExplorerPage && modelName && sourceName && ( + )} {isExplorerPage && queryParam && ( @@ -85,11 +95,20 @@ function Breadcrumbs({ models, notebooks }: BreadcrumbsProps): JSX.Element { > )} - {isPreviewPage && sourceName && ( - <> - / - {sourceName} - > + {isPreviewPage && sourceName && modelName && ( + + )} + + {isPreviewPage && sourceName && modelName && ( + )} {isQueryPage && queryName && modelName && ( @@ -97,18 +116,15 @@ function Breadcrumbs({ models, notebooks }: BreadcrumbsProps): JSX.Element { )} {isNotebookPage && notebookName && ( - <> - / - ({ - name, - to: `/notebook/${encodeURIComponent(name)}`, - active: name === notebookName, - }))} - isCurrent - /> - > + ({ + name, + to: `/notebook/${encodeURIComponent(name)}`, + active: name === notebookName, + }))} + isCurrent + /> )} ); @@ -155,9 +171,11 @@ function BreadcrumbDropdown({ function SourceBreadcrumb({ modelName, sourceName, + pageType, }: { modelName: string; sourceName: string; + pageType: "explorer" | "preview"; }): JSX.Element { const { model } = useRuntime(); const sources = model.exportedExplores; @@ -169,9 +187,41 @@ function SourceBreadcrumb({ label={sourceName} items={sources.map((explore) => ({ name: explore.name, - to: `/model/${modelName}/explorer/${explore.name}`, + to: `/model/${modelName}/${pageType}/${explore.name}`, active: explore.name === sourceName, }))} + isCurrent={pageType === "explorer"} + /> + > + ); +} + +function ViewTypeBreadcrumb({ + modelName, + sourceName, + currentView, +}: { + modelName: string; + sourceName: string; + currentView: "preview" | "explorer"; +}): JSX.Element { + return ( + <> + / + > @@ -192,9 +242,9 @@ function QueryBreadcrumb({ <> / ({ - name: query.name, + name: `Query ${query.name}`, to: `/model/${modelName}/query/${query.name}`, active: query.name === queryName, }))} diff --git a/src/Card.tsx b/src/Card.tsx index e8a97cc..7d38a1e 100644 --- a/src/Card.tsx +++ b/src/Card.tsx @@ -1,6 +1,5 @@ import { Link } from "react-router"; import type { JSX } from "react/jsx-runtime"; -import ArrowRightIcon from "../img/arrow-right.svg?react"; export default Card; export type { CardProps }; @@ -9,26 +8,15 @@ type CardProps = { to: string; icon: JSX.Element; title: string; - description?: string; className?: string; }; -function Card({ - to, - icon, - title, - description, - className = "", -}: CardProps): JSX.Element { +function Card({ to, icon, title, className = "" }: CardProps): JSX.Element { return ( {icon} {title} - {description && {description}} - - - ); diff --git a/src/Home.tsx b/src/Home.tsx index 62c461e..79533c9 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -32,9 +32,10 @@ function Home({ models, notebooks }: HomeProps): JSX.Element { Malloy models and notebooks
{description}
Named Query
Malloy Data Model