From eb3e92ffd8ecbbaafc4703d97146c7beee7339b5 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Albo Date: Mon, 6 Oct 2025 20:59:51 +0200 Subject: [PATCH] update: make dialogs content change depending on scenario --- webapp/app.ironcalc.com/frontend/src/App.tsx | 7 ++ .../WelcomeDialog/WelcomeDialog.tsx | 95 +++++++++++++------ 2 files changed, 71 insertions(+), 31 deletions(-) diff --git a/webapp/app.ironcalc.com/frontend/src/App.tsx b/webapp/app.ironcalc.com/frontend/src/App.tsx index eebc085..279c728 100644 --- a/webapp/app.ironcalc.com/frontend/src/App.tsx +++ b/webapp/app.ironcalc.com/frontend/src/App.tsx @@ -24,6 +24,7 @@ import { IronCalc, IronCalcIcon, Model, init } from "@ironcalc/workbook"; function App() { const [model, setModel] = useState(null); const [showWelcomeDialog, setShowWelcomeDialog] = useState(false); + const [isTemplateOnlyDialog, setIsTemplateOnlyDialog] = useState(false); useEffect(() => { async function start() { @@ -58,6 +59,7 @@ function App() { const newModel = loadModelFromStorageOrCreate(); if (!newModel) { setShowWelcomeDialog(true); + setIsTemplateOnlyDialog(false); // Full dialog for first-time usage const createdModel = new Model("template", "en", "UTC"); setModel(createdModel); } else { @@ -107,6 +109,7 @@ function App() { }} newModelFromTemplate={() => { setShowWelcomeDialog(true); + setIsTemplateOnlyDialog(true); // Template-only dialog for "New from template" }} setModel={(uuid: string) => { const newModel = selectModelFromStorage(uuid); @@ -130,6 +133,7 @@ function App() { setModel(createdModel); } setShowWelcomeDialog(false); + setIsTemplateOnlyDialog(false); }} onSelectTemplate={async (templateId) => { switch (templateId) { @@ -147,7 +151,10 @@ function App() { } } setShowWelcomeDialog(false); + setIsTemplateOnlyDialog(false); }} + showHeader={!isTemplateOnlyDialog} + showNewSection={!isTemplateOnlyDialog} /> )} diff --git a/webapp/app.ironcalc.com/frontend/src/components/WelcomeDialog/WelcomeDialog.tsx b/webapp/app.ironcalc.com/frontend/src/components/WelcomeDialog/WelcomeDialog.tsx index 31c39fe..66e3d0e 100644 --- a/webapp/app.ironcalc.com/frontend/src/components/WelcomeDialog/WelcomeDialog.tsx +++ b/webapp/app.ironcalc.com/frontend/src/components/WelcomeDialog/WelcomeDialog.tsx @@ -7,8 +7,12 @@ import IronCalcIcon from "./ironcalc_icon_white.svg"; function WelcomeDialog(properties: { onClose: () => void; onSelectTemplate: (templateId: string) => void; + showHeader?: boolean; + showNewSection?: boolean; }) { - const [selectedTemplate, setSelectedTemplate] = useState("blank"); + const [selectedTemplate, setSelectedTemplate] = useState( + properties.showNewSection ? "blank" : "mortgage_calculator", + ); const handleClose = () => { properties.onClose(); @@ -20,37 +24,56 @@ function WelcomeDialog(properties: { return ( {}}> - - - - - - Welcome to IronCalc - - Start with a blank workbook or a ready-made template. - - - event.key === "Enter" && properties.onClose()} - > - - - + {properties.showHeader !== false ? ( + + + + + + Welcome to IronCalc + + Start with a blank workbook or a ready-made template. + + + event.key === "Enter" && properties.onClose()} + > + + + + ) : ( + + Choose a template + event.key === "Enter" && properties.onClose()} + > + + + + )} - New - - } - iconColor="#F2994A" - active={selectedTemplate === "blank"} - onClick={() => handleTemplateSelect("blank")} - /> - + {properties.showNewSection !== false && ( + <> + New + + } + iconColor="#F2994A" + active={selectedTemplate === "blank"} + onClick={() => handleTemplateSelect("blank")} + /> + + + )} Templates