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 { faExclamation, faWifi } from '@fortawesome/free-solid-svg-icons'
|
2023-09-12 14:58:59 -04:00
|
|
|
import { Popover } from '@headlessui/react'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { ActionIcon } from './ActionIcon'
|
|
|
|
|
|
|
|
export const NETWORK_CONTENT = {
|
|
|
|
good: 'Network health is good',
|
|
|
|
bad: 'Network issue',
|
|
|
|
}
|
|
|
|
|
|
|
|
const NETWORK_MESSAGES = {
|
|
|
|
offline: 'You are offline',
|
|
|
|
}
|
|
|
|
|
|
|
|
export const NetworkHealthIndicator = () => {
|
|
|
|
const [networkIssues, setNetworkIssues] = useState<string[]>([])
|
|
|
|
const hasIssues = [...networkIssues.values()].length > 0
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const offlineListener = () =>
|
|
|
|
setNetworkIssues((issues) => {
|
|
|
|
return [
|
|
|
|
...issues.filter((issue) => issue !== NETWORK_MESSAGES.offline),
|
|
|
|
NETWORK_MESSAGES.offline,
|
|
|
|
]
|
|
|
|
})
|
|
|
|
window.addEventListener('offline', offlineListener)
|
|
|
|
|
|
|
|
const onlineListener = () =>
|
|
|
|
setNetworkIssues((issues) => {
|
|
|
|
return [...issues.filter((issue) => issue !== NETWORK_MESSAGES.offline)]
|
|
|
|
})
|
|
|
|
window.addEventListener('online', onlineListener)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.removeEventListener('offline', offlineListener)
|
|
|
|
window.removeEventListener('online', onlineListener)
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Popover className="relative">
|
|
|
|
<Popover.Button
|
|
|
|
className={
|
2023-12-06 14:44:13 -05:00
|
|
|
'p-0 border-none bg-transparent dark:bg-transparent relative ' +
|
2023-09-12 14:58:59 -04:00
|
|
|
(hasIssues
|
|
|
|
? 'focus-visible:outline-destroy-80'
|
|
|
|
: 'focus-visible:outline-succeed-80')
|
|
|
|
}
|
|
|
|
data-testid="network-toggle"
|
|
|
|
>
|
|
|
|
<span className="sr-only">Network Health</span>
|
|
|
|
<ActionIcon
|
|
|
|
icon={faWifi}
|
2023-12-06 14:44:13 -05:00
|
|
|
className="p-1"
|
2023-09-12 14:58:59 -04:00
|
|
|
iconClassName={
|
|
|
|
hasIssues
|
|
|
|
? 'text-destroy-80 dark:text-destroy-30'
|
|
|
|
: 'text-succeed-80 dark:text-succeed-30'
|
|
|
|
}
|
|
|
|
bgClassName={
|
2023-12-06 14:44:13 -05:00
|
|
|
'bg-transparent dark:bg-transparent ' +
|
|
|
|
(hasIssues
|
2023-09-12 14:58:59 -04:00
|
|
|
? 'hover:bg-destroy-10/50 hover:dark:bg-destroy-80/50 rounded'
|
2023-12-06 14:44:13 -05:00
|
|
|
: 'hover:bg-succeed-10/50 hover:dark:bg-succeed-80/50 rounded')
|
2023-09-12 14:58:59 -04:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Popover.Button>
|
|
|
|
<Popover.Panel className="absolute right-0 left-auto top-full mt-1 w-56 flex flex-col gap-1 divide-y divide-chalkboard-20 dark:divide-chalkboard-70 align-stretch py-2 bg-chalkboard-10 dark:bg-chalkboard-90 rounded shadow-lg border border-solid border-chalkboard-20/50 dark:border-chalkboard-80/50 text-sm">
|
|
|
|
{!hasIssues ? (
|
|
|
|
<span
|
|
|
|
className="flex items-center justify-center gap-1 px-4"
|
|
|
|
data-testid="network-good"
|
|
|
|
>
|
|
|
|
<ActionIcon
|
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
|
|
|
icon="checkmark"
|
|
|
|
bgClassName={'bg-succeed-10/50 dark:bg-succeed-80/50 rounded-sm'}
|
2023-09-12 14:58:59 -04:00
|
|
|
iconClassName={'text-succeed-80 dark:text-succeed-30'}
|
|
|
|
/>
|
|
|
|
{NETWORK_CONTENT.good}
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<ul className="divide-y divide-chalkboard-20 dark:divide-chalkboard-80">
|
|
|
|
<span
|
|
|
|
className="font-bold text-xs uppercase text-destroy-60 dark:text-destroy-50 px-4"
|
|
|
|
data-testid="network-bad"
|
|
|
|
>
|
|
|
|
{NETWORK_CONTENT.bad}
|
|
|
|
{networkIssues.length > 1 ? 's' : ''}
|
|
|
|
</span>
|
|
|
|
{networkIssues.map((issue) => (
|
|
|
|
<li
|
|
|
|
key={issue}
|
|
|
|
className="flex items-center gap-1 py-2 my-2 last:mb-0"
|
|
|
|
>
|
|
|
|
<ActionIcon
|
|
|
|
icon={faExclamation}
|
|
|
|
bgClassName={'bg-destroy-10/50 dark:bg-destroy-80/50 rounded'}
|
|
|
|
iconClassName={'text-destroy-80 dark:text-destroy-30'}
|
|
|
|
className="ml-4"
|
|
|
|
/>
|
|
|
|
<p className="flex-1 mr-4">{issue}</p>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
)}
|
|
|
|
</Popover.Panel>
|
|
|
|
</Popover>
|
|
|
|
)
|
|
|
|
}
|