Initial keyboard shortcuts configuration implementation #496

Merged
franknoirot merged 11 commits from keyboard-shortcuts into main 2021-09-10 00:12:59 +02:00
2 changed files with 2 additions and 14 deletions
Showing only changes of commit c95bfc400b - Show all commits

View File

@@ -2,11 +2,9 @@ import { Menu } from '@headlessui/react'
import { useHotkeys } from 'react-hotkeys-hook';
export function DropdownItem({ config, state, thunkDispatch }) {
console.log({ name: config.label, shortcut: config.shortcut, callback: handleClick})
useHotkeys(config.shortcut, handleClick)
function handleClick(e) {
console.log(e, config)
e.preventDefault()
config.callback(e, {state, thunkDispatch})
}
@@ -14,11 +12,11 @@ export function DropdownItem({ config, state, thunkDispatch }) {
<Menu.Item>
{({ active }) => (
<button
className={`${active && 'bg-gray-600'} px-2 py-1 text-left`}
className={`${active && 'bg-gray-600'} px-2 py-1 flex justify-between`}
onClick={handleClick}
>
{config.label}
{config.shortcutLabel && <span className="text-gray-400 pl-4">{ config.shortcutLabel }</span> }
{config.shortcutLabel && <span className="text-gray-400 pl-6 text-right">{ config.shortcutLabel }</span> }
</button>
)}
</Menu.Item>

View File

@@ -49,16 +49,6 @@ const fileMenuConfig = {
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
config.callback = handleStlDownload
return <DropdownItem {...props} />
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
}
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
},
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
{
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
label: 'Cook Donut',
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
shortcut: 'ctrl+d, command+d',
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
shortcutLabel: cmdOrCtrl() + ' D',
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
component: (props) => {
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
const { config } = props
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
config.callback = () => alert('Donut is cooked!')
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
return <DropdownItem {...props} />
}
}
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:35:59 +02:00 (Migrated from github.com)
Review

if you make this:

const fileMenuConfig: EditorMenuConfig = {

Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since component doesn't exist on EditorMenuItemConfig.

if you make this: ```suggestion const fileMenuConfig: EditorMenuConfig = { ``` Thdn the linter (assuming you've got ts setup with your editor) should tell you if your obeying your own types for this menu, and I think you're not since `component` doesn't exist on `EditorMenuItemConfig`.
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
Irev-Dev commented 2021-09-08 10:38:23 +02:00 (Migrated from github.com)
Review

I think callback is not needed now and component is?

I think callback is not needed now and component is?
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!
franknoirot commented 2021-09-08 16:00:31 +02:00 (Migrated from github.com)
Review

Yup it yelled at me now!

Yup it yelled at me now!