From eb70e139fc69f8eb02f951c69b54e584178b549b Mon Sep 17 00:00:00 2001
From: NamH
Date: Tue, 16 Jan 2024 12:37:55 +0700
Subject: [PATCH] chore(ShortcutModal): clean up shortcut modal (#1614)
Signed-off-by: James
Co-authored-by: James
---
web/containers/ShortcutModal/index.tsx | 99 ++++++++++++++++
web/screens/Settings/Advanced/index.tsx | 145 +-----------------------
2 files changed, 103 insertions(+), 141 deletions(-)
create mode 100644 web/containers/ShortcutModal/index.tsx
diff --git a/web/containers/ShortcutModal/index.tsx b/web/containers/ShortcutModal/index.tsx
new file mode 100644
index 000000000..638df02d8
--- /dev/null
+++ b/web/containers/ShortcutModal/index.tsx
@@ -0,0 +1,99 @@
+import React from 'react'
+
+import {
+ Modal,
+ ModalTrigger,
+ Button,
+ ModalContent,
+ ModalHeader,
+ ModalTitle,
+} from '@janhq/uikit'
+
+const availableShortcuts = [
+ {
+ combination: 'E',
+ modifierKeys: [isMac ? '⌘' : 'Ctrl'],
+ description: 'Show list your models',
+ },
+ {
+ combination: 'K',
+ modifierKeys: [isMac ? '⌘' : 'Ctrl'],
+ description: 'Show list navigation pages',
+ },
+ {
+ combination: 'B',
+ modifierKeys: [isMac ? '⌘' : 'Ctrl'],
+ description: 'Toggle collapsible left panel',
+ },
+ {
+ combination: ',',
+ modifierKeys: [isMac ? '⌘' : 'Ctrl'],
+ description: 'Navigate to setting page',
+ },
+ {
+ combination: 'Enter',
+ description: 'Send a message',
+ },
+ {
+ combination: 'Shift + Enter',
+ description: 'Insert new line in input box',
+ },
+ {
+ combination: 'Arrow Up',
+ description: 'Navigate to previous option (within search dialog)',
+ },
+ {
+ combination: 'Arrow Down',
+ description: 'Navigate to next option (within search dialog)',
+ },
+]
+
+const ShortcutModal: React.FC = () => (
+
+
+
+
+
+
+ Keyboard Shortcuts
+
+
+
+
+
Combination
+
+
+
Description
+
+
+ {availableShortcuts.map((shortcut, index) => {
+ return (
+
+
+
+
{`${shortcut.modifierKeys?.[0] ?? ''} ${
+ shortcut.combination
+ }`}
+
+
+
+
{shortcut.description}
+
+
+ )
+ })}
+
+
+
+)
+
+export default ShortcutModal
diff --git a/web/screens/Settings/Advanced/index.tsx b/web/screens/Settings/Advanced/index.tsx
index 9a25b0f35..03b840f0b 100644
--- a/web/screens/Settings/Advanced/index.tsx
+++ b/web/screens/Settings/Advanced/index.tsx
@@ -4,24 +4,16 @@
import { useContext, useEffect, useState } from 'react'
import { fs } from '@janhq/core'
-import {
- Switch,
- Button,
- Modal,
- ModalContent,
- ModalHeader,
- ModalTitle,
- ModalTrigger,
-} from '@janhq/uikit'
+import { Switch, Button } from '@janhq/uikit'
import { atom, useAtom } from 'jotai'
-import ShortCut from '@/containers/Shortcut'
+import ShortcutModal from '@/containers/ShortcutModal'
+import { toaster } from '@/containers/Toast'
import { FeatureToggleContext } from '@/context/FeatureToggle'
import { useSettings } from '@/hooks/useSettings'
-import { toaster } from '@/containers/Toast'
const serverEnabledAtom = atom(false)
@@ -173,136 +165,7 @@ const Advanced = () => {
Shortcuts that you might find useful in Jan app.
-
-
-
-
-
-
- Keyboard Shortcuts
-
-
-
-
-
-
-
-
Show list your models
-
-
-
-
-
-
-
-
Show list navigation pages
-
-
-
-
-
-
-
-
Toggle collapsible left panel
-
-
-
-
-
-
-
-
Navigate to setting page
-
-
-
-
-
-
-
-
-
Insert new line in input box
-
-
-
-
-
-
-
-
Navigate to previous option (within search dialog)
-
-
-
-
-
-
-
-
Navigate to next option (within search dialog)
-
-
-
-
-
-
+
)