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 { useCommandsContext } from 'hooks/useCommandsContext'
|
|
|
|
import CommandBarHeader from './CommandBarHeader'
|
|
|
|
import { useHotkeys } from 'react-hotkeys-hook'
|
|
|
|
|
|
|
|
function CommandBarReview({ stepBack }: { stepBack: () => void }) {
|
|
|
|
const { commandBarState, commandBarSend } = useCommandsContext()
|
|
|
|
const {
|
|
|
|
context: { argumentsToSubmit, selectedCommand },
|
|
|
|
} = commandBarState
|
|
|
|
|
|
|
|
useHotkeys('backspace', stepBack, {
|
|
|
|
enableOnFormTags: true,
|
|
|
|
enableOnContentEditable: true,
|
|
|
|
})
|
|
|
|
|
|
|
|
useHotkeys(
|
2024-02-23 11:24:22 -05:00
|
|
|
[
|
|
|
|
'alt+1',
|
|
|
|
'alt+2',
|
|
|
|
'alt+3',
|
|
|
|
'alt+4',
|
|
|
|
'alt+5',
|
|
|
|
'alt+6',
|
|
|
|
'alt+7',
|
|
|
|
'alt+8',
|
|
|
|
'alt+9',
|
|
|
|
'alt+0',
|
|
|
|
],
|
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
|
|
|
(_, b) => {
|
|
|
|
if (b.keys && !Number.isNaN(parseInt(b.keys[0], 10))) {
|
|
|
|
if (!selectedCommand?.args) return
|
|
|
|
const argName = Object.keys(selectedCommand.args)[
|
|
|
|
parseInt(b.keys[0], 10) - 1
|
|
|
|
]
|
|
|
|
const arg = selectedCommand?.args[argName]
|
|
|
|
commandBarSend({
|
|
|
|
type: 'Edit argument',
|
|
|
|
data: { arg: { ...arg, name: argName } },
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ keyup: true, enableOnFormTags: true, enableOnContentEditable: true },
|
|
|
|
[argumentsToSubmit, selectedCommand]
|
|
|
|
)
|
|
|
|
|
|
|
|
Object.keys(argumentsToSubmit).forEach((key, i) => {
|
|
|
|
const arg = selectedCommand?.args ? selectedCommand?.args[key] : undefined
|
|
|
|
if (!arg) return
|
|
|
|
})
|
|
|
|
|
2024-03-04 16:06:43 -05:00
|
|
|
function submitCommand(e: React.FormEvent<HTMLFormElement>) {
|
|
|
|
e.preventDefault()
|
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
|
|
|
commandBarSend({
|
|
|
|
type: 'Submit command',
|
2024-09-09 19:59:36 +03:00
|
|
|
output: argumentsToSubmit,
|
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
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CommandBarHeader>
|
|
|
|
<p className="px-4">Confirm {selectedCommand?.name}</p>
|
|
|
|
<form
|
|
|
|
id="review-form"
|
|
|
|
className="absolute opacity-0 inset-0 pointer-events-none"
|
|
|
|
onSubmit={submitCommand}
|
|
|
|
>
|
|
|
|
{Object.entries(argumentsToSubmit).map(([key, value], i) => {
|
|
|
|
const arg = selectedCommand?.args
|
|
|
|
? selectedCommand?.args[key]
|
|
|
|
: undefined
|
|
|
|
if (!arg) return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<input
|
|
|
|
id={key}
|
|
|
|
name={key}
|
|
|
|
key={key}
|
|
|
|
type="text"
|
|
|
|
defaultValue={
|
|
|
|
typeof value === 'object'
|
|
|
|
? JSON.stringify(value)
|
|
|
|
: (value as string)
|
|
|
|
}
|
|
|
|
hidden
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</form>
|
|
|
|
</CommandBarHeader>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default CommandBarReview
|