import { WebApplication } from '@/Application/Application' import { FunctionComponent, MouseEventHandler, useCallback, useMemo } from 'react' import Switch from '@/Components/Switch/Switch' import { isMobileScreen } from '@/Utils' import { TOGGLE_FOCUS_MODE_COMMAND } from '@standardnotes/ui-services' import { KeyboardShortcutIndicator } from '../KeyboardShortcutIndicator/KeyboardShortcutIndicator' import MenuItem from '../Menu/MenuItem' type Props = { application: WebApplication onToggle: (value: boolean) => void onClose: () => void isEnabled: boolean } const FocusModeSwitch: FunctionComponent = ({ application, onToggle, onClose, isEnabled }) => { const toggle: MouseEventHandler = useCallback( (e) => { e.preventDefault() onToggle(!isEnabled) onClose() }, [onToggle, isEnabled, onClose], ) const shortcut = useMemo( () => application.keyboardService.keyboardShortcutForCommand(TOGGLE_FOCUS_MODE_COMMAND), [application], ) const isMobile = application.isNativeMobileWeb() || isMobileScreen() if (isMobile) { return null } return (
Focus Mode
{shortcut && }
) } export default FocusModeSwitch