diff --git a/app/src/lib/editor/engine/canvas/index.ts b/app/src/lib/editor/engine/canvas/index.ts index da9a948f9..89078086a 100644 --- a/app/src/lib/editor/engine/canvas/index.ts +++ b/app/src/lib/editor/engine/canvas/index.ts @@ -18,7 +18,10 @@ export class CanvasManager { constructor(private projects: ProjectsManager) { makeAutoObservable(this); + this.listenToProjectChange(); + } + listenToProjectChange() { reaction( () => this.projects.project, (project) => { diff --git a/app/src/routes/projects/ProjectsTab/Create/New/SelectFolder.tsx b/app/src/routes/projects/ProjectsTab/Create/New/SelectFolder.tsx index a26cf0768..626cc621a 100644 --- a/app/src/routes/projects/ProjectsTab/Create/New/SelectFolder.tsx +++ b/app/src/routes/projects/ProjectsTab/Create/New/SelectFolder.tsx @@ -24,17 +24,35 @@ export const NewSelectFolder = ({ if (path == null) { return; } + + const pathWithProject = `${path}/${nameToFolderName(projectData.name || 'new-project')}`; + setProjectData({ + ...projectData, + folderPath: pathWithProject, + }); + } + + function nameToFolderName(name: string): string { + return name + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') // Replace non-alphanumeric characters with hyphens + .replace(/^-+|-+$/g, '') // Remove leading and trailing hyphens + .replace(/^(\d)/, '_$1'); // Prepend underscore if the name starts with a digit + } + + function goBack() { setProjectData({ ...projectData, - folderPath: path, + folderPath: undefined, }); + prevStep(); } return ( {'Select your project folder'} - {'This is where we’ll reference your App'} + {"We'll create a folder with your new app here"} {projectData.folderPath ? ( @@ -70,7 +88,7 @@ export const NewSelectFolder = ({

{`${currentStep + 1} of ${totalSteps}`}

-
@@ -119,7 +135,7 @@ const EmblaCarousel: React.FC = ({ slides, onSlideChange }) disabled={!nextBtnEnabled} >