2023-07-13 07:22:08 -04:00
|
|
|
import { Toolbar } from '../Toolbar'
|
2023-07-27 18:59:40 -04:00
|
|
|
import UserSidebarMenu from './UserSidebarMenu'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { type IndexLoaderData } from 'lib/types'
|
2023-08-18 10:27:01 -04:00
|
|
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
2024-03-11 20:26:13 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2023-08-31 09:47:59 -04:00
|
|
|
import styles from './AppHeader.module.css'
|
2023-09-12 14:58:59 -04:00
|
|
|
import { NetworkHealthIndicator } from './NetworkHealthIndicator'
|
2023-12-06 14:44:13 -05:00
|
|
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
|
|
|
import { ActionButton } from './ActionButton'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
import usePlatform from 'hooks/usePlatform'
|
2023-07-13 07:22:08 -04:00
|
|
|
|
|
|
|
interface AppHeaderProps extends React.PropsWithChildren {
|
|
|
|
showToolbar?: boolean
|
2023-10-16 13:28:41 -04:00
|
|
|
project?: Omit<IndexLoaderData, 'code'>
|
2023-08-06 21:29:26 -04:00
|
|
|
className?: string
|
2023-08-18 10:27:01 -04:00
|
|
|
enableMenu?: boolean
|
2023-07-13 07:22:08 -04:00
|
|
|
}
|
|
|
|
|
2023-08-06 21:29:26 -04:00
|
|
|
export const AppHeader = ({
|
|
|
|
showToolbar = true,
|
2023-08-18 10:27:01 -04:00
|
|
|
project,
|
2023-08-06 21:29:26 -04:00
|
|
|
children,
|
|
|
|
className = '',
|
2023-08-18 10:27:01 -04:00
|
|
|
enableMenu = false,
|
2023-08-06 21:29:26 -04:00
|
|
|
}: AppHeaderProps) => {
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
const platform = usePlatform()
|
|
|
|
const { commandBarSend } = useCommandsContext()
|
2024-03-11 20:26:13 -04:00
|
|
|
const { auth } = useSettingsAuthContext()
|
2023-10-11 13:36:54 +11:00
|
|
|
const user = auth?.context?.user
|
2023-07-27 18:59:40 -04:00
|
|
|
|
2023-07-13 07:22:08 -04:00
|
|
|
return (
|
2023-08-06 21:29:26 -04:00
|
|
|
<header
|
|
|
|
className={
|
2023-12-06 14:44:13 -05:00
|
|
|
'w-full grid ' +
|
2023-08-31 09:47:59 -04:00
|
|
|
styles.header +
|
2023-12-18 06:15:26 -05:00
|
|
|
' overlaid-panes sticky top-0 z-20 py-1 px-2 bg-chalkboard-10/70 dark:bg-chalkboard-100/50 border-b dark:border-b-2 border-chalkboard-30 dark:border-chalkboard-90 items-center ' +
|
2023-08-06 21:29:26 -04:00
|
|
|
className
|
|
|
|
}
|
|
|
|
>
|
2023-10-17 12:31:14 -04:00
|
|
|
<ProjectSidebarMenu
|
|
|
|
renderAsLink={!enableMenu}
|
|
|
|
project={project?.project}
|
|
|
|
file={project?.file}
|
|
|
|
/>
|
2023-07-13 07:22:08 -04:00
|
|
|
{/* Toolbar if the context deems it */}
|
2023-12-06 14:44:13 -05:00
|
|
|
<div className="flex-grow flex justify-center max-w-lg md:max-w-xl lg:max-w-2xl xl:max-w-4xl 2xl:max-w-5xl">
|
|
|
|
{showToolbar ? (
|
2023-07-13 07:22:08 -04:00
|
|
|
<Toolbar />
|
2023-12-06 14:44:13 -05:00
|
|
|
) : (
|
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
onClick={() => commandBarSend({ type: 'Open' })}
|
2023-12-06 14:44:13 -05:00
|
|
|
className="text-sm self-center flex items-center w-fit gap-3"
|
|
|
|
>
|
|
|
|
Command Palette{' '}
|
|
|
|
<kbd className="bg-energy-10/50 dark:bg-chalkboard-100 dark:text-energy-10 inline-block px-1 py-0.5 border-energy-10 dark:border-chalkboard-90">
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
{platform === 'darwin' ? '⌘K' : 'Ctrl+/'}
|
2023-12-06 14:44:13 -05:00
|
|
|
</kbd>
|
|
|
|
</ActionButton>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-1 ml-auto">
|
|
|
|
{/* If there are children, show them, otherwise show User menu */}
|
|
|
|
{children || (
|
|
|
|
<>
|
|
|
|
<NetworkHealthIndicator />
|
|
|
|
<UserSidebarMenu user={user} />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-07-13 07:22:08 -04:00
|
|
|
</header>
|
|
|
|
)
|
|
|
|
}
|