* Remove unnecessary console.log
* Create a global appMachine
* Strip authMachine of side-effects
* Replace react-bound authMachine use with XState actor use
* Fix import goof
* Register auth commands directly!
* Don't provide anything to settingsMachine from React
* Remove unecessary async
* Make it possible to load project settings via a sent event, without React
* Make settingsMachine ready to be an actor
* Remove settingsLoader use
* Replace all useSettingsAuthContext use with direct actor use
* Add logic to clear project settings, fmt
* fmt
* Clear and load project settings from routeLoaders, but using actor
* Remove useRefreshSettings
* Restore use of useToken() that wasn't working for some reason
* Migrate useFileSystemWatcher use to RouteProvider
* Surface wasm_bindgen unavailable error to console
* Remove unnecessary use of Jest settings wrappers
* Replace dynamic import with actor.getSnapshot
* Migrate system theme and theme color watching from useEffects to actors/actions
* Migrate cursor color effect
* Remove unused code that is now in RouteProvider
* Migrate route commands registration further down for now, out of SettingsAuthProvider
* Migrate settings command registration out of SettingsAuthProvider.tsx
* Delete SettingsAuthProvider.tsx!
* Remove unused settingsLoader!
* fmt and remove comments
* Use actor for routeLoader
* Fix project read error due to uninitialized WASM
* Fix user settings load error due to uninitialized WASM
* Move settingsActor into appActor as a spawned child
* Trying to fix unit tests
* Remove unused imports and demo window attachments
* fmt
* Fix testing issues caused by circular dependency
* Add `setThemeColor` to a few actions list it was missing from
* fmt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Fix "Execute AST" action in browser, where currentProject is `undefined`
* Update commands list when currentProject changes
* Fix `clearProjectSettings`, which was passing along non-settings context
* Fix onboarding test that actually needed the onboarding initially dismissed
* Add scrollIntoView to make this test more reliable
* @lf94's feedback I missed
I got distracted by a million other things last week
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)"
This reverts commit 129226c6ef
.
* fmt
* revert bad snapshot
* Fix up camera movement test locator
* Fix test that was flipping the user settings without waiting
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { Switch } from '@headlessui/react'
|
|
import { settingsActor, useSettings } from 'machines/appMachine'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
export function CameraProjectionToggle() {
|
|
const settings = useSettings()
|
|
const isCameraProjectionPerspective =
|
|
settings.modeling.cameraProjection.current === 'perspective'
|
|
const [checked, setChecked] = useState(isCameraProjectionPerspective)
|
|
|
|
useEffect(() => {
|
|
setChecked(settings.modeling.cameraProjection.current === 'perspective')
|
|
}, [settings.modeling.cameraProjection.current])
|
|
|
|
return (
|
|
<Switch
|
|
checked={checked}
|
|
onChange={(newValue) => {
|
|
settingsActor.send({
|
|
type: 'set.modeling.cameraProjection',
|
|
data: {
|
|
level: 'user',
|
|
value: newValue ? 'perspective' : 'orthographic',
|
|
},
|
|
})
|
|
}}
|
|
className={`pointer-events-auto p-0 text-xs text-chalkboard-60 dark:text-chalkboard-40 bg-chalkboard-10/70 hover:bg-chalkboard-10 dark:bg-chalkboard-100/80 dark:hover:bg-chalkboard-100 backdrop-blur-sm
|
|
border border-primary/10 hover:border-primary/50 focus-visible:border-primary/50 rounded-full`}
|
|
>
|
|
<span className="sr-only">Camera projection: </span>
|
|
<div className="flex items-center gap-2">
|
|
<span
|
|
aria-hidden={checked}
|
|
className={
|
|
'border border-solid m-[-1px] rounded-full px-2 py-1 ' +
|
|
(!checked
|
|
? 'text-primary border-primary -mr-2'
|
|
: 'border-transparent')
|
|
}
|
|
>
|
|
Orthographic
|
|
</span>
|
|
<span
|
|
aria-hidden={checked}
|
|
className={
|
|
'border border-solid m-[-1px] rounded-full px-2 py-1 ' +
|
|
(checked
|
|
? 'text-primary border-primary -ml-2'
|
|
: 'border-transparent')
|
|
}
|
|
>
|
|
Perspective
|
|
</span>
|
|
</div>
|
|
</Switch>
|
|
)
|
|
}
|