overleaf/services/web/frontend/js/features/editor-left-menu/components/help-show-hotkeys.tsx
Alf Eaton 9875e55a27 Remove Ace (#14299)
GitOrigin-RevId: ec8788fdbc8aea73ca33ec2810f4e588fe9476b5
2023-11-29 09:04:08 +00:00

38 lines
1.1 KiB
TypeScript

import { useState, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import * as eventTracking from '../../../infrastructure/event-tracking'
import { useProjectContext } from '../../../shared/context/project-context'
import HotkeysModal from '../../hotkeys-modal/components/hotkeys-modal'
import LeftMenuButton from './left-menu-button'
export default function HelpShowHotkeys() {
const [showModal, setShowModal] = useState(false)
const { t } = useTranslation()
const { features } = useProjectContext()
const isMac = /Mac/.test(window.navigator?.platform)
const showModalWithAnalytics = useCallback(() => {
eventTracking.sendMB('left-menu-hotkeys')
setShowModal(true)
}, [])
return (
<>
<LeftMenuButton
onClick={showModalWithAnalytics}
icon={{
type: 'keyboard-o',
fw: true,
}}
>
{t('show_hotkeys')}
</LeftMenuButton>
<HotkeysModal
show={showModal}
handleHide={() => setShowModal(false)}
isMac={isMac}
trackChangesVisible={features?.trackChangesVisible}
/>
</>
)
}