2023-07-25 10:40:26 -04:00
|
|
|
import { faArrowRight, faXmark } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { ActionButton } from '../../components/ActionButton'
|
2023-10-06 10:00:35 -04:00
|
|
|
import {
|
|
|
|
ONBOARDING_PROJECT_NAME,
|
|
|
|
onboardingPaths,
|
|
|
|
useDismiss,
|
|
|
|
useNextClick,
|
|
|
|
} from '.'
|
2023-09-15 22:37:40 -04:00
|
|
|
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
2023-09-18 16:13:04 -04:00
|
|
|
import { Themes, getSystemTheme } from 'lib/theme'
|
2023-09-15 22:37:40 -04:00
|
|
|
import { bracket } from 'lib/exampleKcl'
|
|
|
|
import {
|
2023-10-17 12:31:14 -04:00
|
|
|
PROJECT_ENTRYPOINT,
|
2023-09-15 22:37:40 -04:00
|
|
|
createNewProject,
|
|
|
|
getNextProjectIndex,
|
|
|
|
getProjectsInDir,
|
|
|
|
interpolateProjectNameWithIndex,
|
|
|
|
} from 'lib/tauriFS'
|
|
|
|
import { isTauri } from 'lib/isTauri'
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
import { paths } from 'Router'
|
|
|
|
import { useEffect } from 'react'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { kclManager } from 'lang/KclSinglton'
|
2023-10-17 12:31:14 -04:00
|
|
|
import { sep } from '@tauri-apps/api/path'
|
2023-07-25 10:40:26 -04:00
|
|
|
|
2023-09-15 22:37:40 -04:00
|
|
|
function OnboardingWithNewFile() {
|
|
|
|
const navigate = useNavigate()
|
2023-07-25 10:40:26 -04:00
|
|
|
const dismiss = useDismiss()
|
2023-09-15 22:37:40 -04:00
|
|
|
const next = useNextClick(onboardingPaths.INDEX)
|
|
|
|
const {
|
|
|
|
settings: {
|
2023-10-06 10:00:35 -04:00
|
|
|
context: { defaultDirectory },
|
2023-09-15 22:37:40 -04:00
|
|
|
},
|
|
|
|
} = useGlobalStateContext()
|
2023-07-25 10:40:26 -04:00
|
|
|
|
2023-09-15 22:37:40 -04:00
|
|
|
async function createAndOpenNewProject() {
|
|
|
|
const projects = await getProjectsInDir(defaultDirectory)
|
2023-10-06 10:00:35 -04:00
|
|
|
const nextIndex = await getNextProjectIndex(
|
|
|
|
ONBOARDING_PROJECT_NAME,
|
|
|
|
projects
|
|
|
|
)
|
|
|
|
const name = interpolateProjectNameWithIndex(
|
|
|
|
ONBOARDING_PROJECT_NAME,
|
|
|
|
nextIndex
|
|
|
|
)
|
2023-11-06 11:49:13 +11:00
|
|
|
const newFile = await createNewProject(
|
|
|
|
defaultDirectory + sep + name,
|
|
|
|
bracket
|
|
|
|
)
|
2023-10-17 12:31:14 -04:00
|
|
|
navigate(
|
|
|
|
`${paths.FILE}/${encodeURIComponent(
|
|
|
|
newFile.path + sep + PROJECT_ENTRYPOINT
|
|
|
|
)}${paths.ONBOARDING.INDEX}`
|
|
|
|
)
|
2023-09-15 22:37:40 -04:00
|
|
|
}
|
2023-07-25 10:40:26 -04:00
|
|
|
return (
|
2023-10-17 12:31:14 -04:00
|
|
|
<div className="fixed inset-0 z-50 grid place-content-center bg-chalkboard-110/50">
|
|
|
|
<div className="max-w-3xl p-8 rounded bg-chalkboard-10 dark:bg-chalkboard-90">
|
2023-09-15 22:37:40 -04:00
|
|
|
{!isTauri() ? (
|
|
|
|
<>
|
|
|
|
<h1 className="text-2xl font-bold text-warn-80 dark:text-warn-10">
|
|
|
|
Replaying onboarding resets your code
|
|
|
|
</h1>
|
|
|
|
<p className="my-4">
|
|
|
|
We see you have some of your own code written in this project.
|
|
|
|
Please save it somewhere else before continuing the onboarding.
|
|
|
|
</p>
|
|
|
|
<div className="flex justify-between mt-6">
|
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
2023-09-19 14:06:56 -04:00
|
|
|
onClick={dismiss}
|
2023-09-15 22:37:40 -04:00
|
|
|
icon={{
|
|
|
|
icon: faXmark,
|
|
|
|
bgClassName: 'bg-destroy-80',
|
|
|
|
iconClassName:
|
|
|
|
'text-destroy-20 group-hover:text-destroy-10 hover:text-destroy-10',
|
|
|
|
}}
|
|
|
|
className="hover:border-destroy-40"
|
|
|
|
>
|
|
|
|
Dismiss
|
|
|
|
</ActionButton>
|
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
|
|
|
onClick={() => {
|
2023-11-06 11:49:13 +11:00
|
|
|
kclManager.setCodeAndExecute(bracket)
|
2023-09-15 22:37:40 -04:00
|
|
|
next()
|
|
|
|
}}
|
|
|
|
icon={{ icon: faArrowRight }}
|
|
|
|
>
|
|
|
|
Overwrite code and continue
|
|
|
|
</ActionButton>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
2023-10-17 12:31:14 -04:00
|
|
|
<h1 className="flex flex-wrap items-center gap-4 text-2xl font-bold">
|
2023-09-15 22:37:40 -04:00
|
|
|
Would you like to create a new project?
|
|
|
|
</h1>
|
|
|
|
<section className="my-12">
|
|
|
|
<p className="my-4">
|
|
|
|
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.
|
|
|
|
</p>
|
|
|
|
</section>
|
|
|
|
<div className="flex justify-between mt-6">
|
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
2023-09-19 14:06:56 -04:00
|
|
|
onClick={dismiss}
|
2023-09-15 22:37:40 -04:00
|
|
|
icon={{
|
|
|
|
icon: faXmark,
|
|
|
|
bgClassName: 'bg-destroy-80',
|
|
|
|
iconClassName:
|
|
|
|
'text-destroy-20 group-hover:text-destroy-10 hover:text-destroy-10',
|
|
|
|
}}
|
|
|
|
className="hover:border-destroy-40"
|
|
|
|
>
|
|
|
|
Dismiss
|
|
|
|
</ActionButton>
|
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
2023-10-17 12:31:14 -04:00
|
|
|
onClick={() => {
|
|
|
|
createAndOpenNewProject()
|
2023-11-06 15:03:21 +11:00
|
|
|
kclManager.setCode(bracket, false)
|
2023-10-17 12:31:14 -04:00
|
|
|
dismiss()
|
|
|
|
}}
|
2023-09-15 22:37:40 -04:00
|
|
|
icon={{ icon: faArrowRight }}
|
|
|
|
>
|
|
|
|
Make a new project
|
|
|
|
</ActionButton>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Introduction() {
|
|
|
|
const {
|
|
|
|
settings: {
|
|
|
|
state: {
|
|
|
|
context: { theme },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} = useGlobalStateContext()
|
2023-09-18 16:13:04 -04:00
|
|
|
const getLogoTheme = () =>
|
|
|
|
theme === Themes.Light ||
|
|
|
|
(theme === Themes.System && getSystemTheme() === Themes.Light)
|
|
|
|
? '-dark'
|
|
|
|
: ''
|
2023-09-15 22:37:40 -04:00
|
|
|
const dismiss = useDismiss()
|
|
|
|
const next = useNextClick(onboardingPaths.CAMERA)
|
2023-10-17 12:31:14 -04:00
|
|
|
const isStarterCode = kclManager.code === '' || kclManager.code === bracket
|
2023-09-15 22:37:40 -04:00
|
|
|
|
|
|
|
useEffect(() => {
|
2023-10-11 13:36:54 +11:00
|
|
|
if (kclManager.code === '') kclManager.setCode(bracket)
|
2023-10-17 12:31:14 -04:00
|
|
|
}, [])
|
2023-09-15 22:37:40 -04:00
|
|
|
|
2023-10-17 12:31:14 -04:00
|
|
|
return isStarterCode ? (
|
|
|
|
<div className="fixed inset-0 z-50 grid place-content-center bg-chalkboard-110/50">
|
|
|
|
<div className="max-w-3xl p-8 rounded bg-chalkboard-10 dark:bg-chalkboard-90">
|
|
|
|
<h1 className="flex flex-wrap items-center gap-4 text-2xl font-bold">
|
2023-09-15 22:37:40 -04:00
|
|
|
<img
|
2023-09-18 16:13:04 -04:00
|
|
|
src={`/kcma-logomark${getLogoTheme()}.svg`}
|
2023-09-15 22:37:40 -04:00
|
|
|
alt="KittyCAD Modeling App"
|
2023-10-17 12:31:14 -04:00
|
|
|
className="h-20 max-w-full"
|
2023-09-15 22:37:40 -04:00
|
|
|
/>
|
2023-10-17 12:31:14 -04:00
|
|
|
<span className="px-3 py-1 text-base rounded-full bg-energy-10 text-energy-80">
|
2023-09-15 22:37:40 -04:00
|
|
|
Alpha
|
|
|
|
</span>
|
2023-07-25 10:40:26 -04:00
|
|
|
</h1>
|
2023-09-15 22:37:40 -04:00
|
|
|
<section className="my-12">
|
|
|
|
<p className="my-4">
|
|
|
|
Welcome to KittyCAD Modeling App! This is a hardware design tool
|
|
|
|
that lets you edit visually, with code, or both. It's powered by 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 a remote GPU as video.
|
|
|
|
</p>
|
|
|
|
<p className="my-4">
|
|
|
|
This is an alpha release, so you will encounter bugs and missing
|
|
|
|
features. You can read our{' '}
|
|
|
|
<a
|
|
|
|
href="https://gist.github.com/jgomez720/5cd53fb7e8e54079f6dc0d2625de5393"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
>
|
|
|
|
expectations for alpha users here
|
|
|
|
</a>
|
|
|
|
. Please give us feedback on your experience! We are trying to
|
|
|
|
release as early as possible to get feedback from users like you.
|
|
|
|
</p>
|
|
|
|
</section>
|
2023-07-25 10:40:26 -04:00
|
|
|
<div className="flex justify-between mt-6">
|
|
|
|
<ActionButton
|
2023-08-15 21:56:24 -04:00
|
|
|
Element="button"
|
2023-09-19 14:06:56 -04:00
|
|
|
onClick={dismiss}
|
2023-07-25 10:40:26 -04:00
|
|
|
icon={{
|
|
|
|
icon: faXmark,
|
|
|
|
bgClassName: 'bg-destroy-80',
|
|
|
|
iconClassName:
|
|
|
|
'text-destroy-20 group-hover:text-destroy-10 hover:text-destroy-10',
|
|
|
|
}}
|
|
|
|
className="hover:border-destroy-40"
|
|
|
|
>
|
|
|
|
Dismiss
|
|
|
|
</ActionButton>
|
2023-08-15 21:56:24 -04:00
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
|
|
|
onClick={next}
|
|
|
|
icon={{ icon: faArrowRight }}
|
|
|
|
>
|
2023-07-25 10:40:26 -04:00
|
|
|
Get Started
|
|
|
|
</ActionButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-15 22:37:40 -04:00
|
|
|
) : (
|
|
|
|
<OnboardingWithNewFile />
|
2023-07-25 10:40:26 -04:00
|
|
|
)
|
|
|
|
}
|