import { OnboardingButtons, useDemoCode, useDismiss, useNextClick } from '.' import { onboardingPaths } from 'routes/Onboarding/paths' import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext' import { Themes, getSystemTheme } from 'lib/theme' import { bracket } from 'lib/exampleKcl' import { createAndOpenNewTutorialProject } from 'lib/desktopFS' import { isDesktop } from 'lib/isDesktop' import { useNavigate, useRouteLoaderData } from 'react-router-dom' import { codeManager, kclManager } from 'lib/singletons' import { APP_NAME } from 'lib/constants' import { useState } from 'react' import { IndexLoaderData } from 'lib/types' import { PATHS } from 'lib/paths' import { useFileContext } from 'hooks/useFileContext' import { useLspContext } from 'components/LspProvider' import { reportRejection } from 'lib/trap' import { toSync } from 'lib/utils' /** * Show either a welcome screen or a warning screen * depending on if the user has code in the editor. */ export default function OnboardingIntroduction() { const [shouldShowWarning, setShouldShowWarning] = useState( codeManager.code !== '' && codeManager.code !== bracket ) return shouldShowWarning ? ( ) : ( ) } interface OnboardingResetWarningProps { setShouldShowWarning: (arg: boolean) => void } function OnboardingResetWarning(props: OnboardingResetWarningProps) { return (
{!isDesktop() ? ( ) : ( )}
) } function OnboardingWarningDesktop(props: OnboardingResetWarningProps) { const navigate = useNavigate() const dismiss = useDismiss() const loaderData = useRouteLoaderData(PATHS.FILE) as IndexLoaderData const { context: fileContext } = useFileContext() const { onProjectClose, onProjectOpen } = useLspContext() async function onAccept() { onProjectClose( loaderData.file || null, fileContext.project.path || null, false ) await createAndOpenNewTutorialProject({ onProjectOpen, navigate }) props.setShouldShowWarning(false) } return ( <>

Would you like to create a new project?

You have some content in this project that we don't want to overwrite. If you would like to create a new project, please click the button below.

) } function OnboardingWarningWeb(props: OnboardingResetWarningProps) { const dismiss = useDismiss() return ( <>

Replaying onboarding resets your code

We see you have some of your own code written in this project. Please save it somewhere else before continuing the onboarding.

{ // We do want to update both the state and editor here. codeManager.updateCodeStateEditor(bracket) await codeManager.writeToFile() await kclManager.executeCode({ zoomToFit: true }) props.setShouldShowWarning(false) }, reportRejection)} nextText="Overwrite code and continue" /> ) } function OnboardingIntroductionInner() { // Reset the code to the bracket code useDemoCode() const { settings: { state: { context: { app: { theme }, }, }, }, } = useSettingsAuthContext() const getLogoTheme = () => theme.current === Themes.Light || (theme.current === Themes.System && getSystemTheme() === Themes.Light) ? '-dark' : '' const dismiss = useDismiss() const next = useNextClick(onboardingPaths.CAMERA) return (

{APP_NAME} Alpha

Welcome to {APP_NAME}! This is a hardware design tool that lets you edit visually, with code, or both. It's powered by the KittyCAD Design API, the first API created for anyone to build hardware design tools. The 3D view is not running on your computer, but is instead being streamed to you from an instance of our Geometry Engine on a remote GPU as video.

This is an alpha release, so you will encounter bugs and missing features. You can read our{' '} expectations for alpha users here , and please give us feedback on your experience{' '} our Discord ! We are trying to release as early as possible to get feedback from users like you.

As you go through the onboarding, we'll be changing and resetting your code occasionally, so that we can reference specific code features. So hold off on writing production KCL code until you're done with the onboarding 😉

) }