From be49d3ed0c78a3b451a16e861df9f4a79a8b2195 Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Wed, 12 Feb 2025 18:42:24 -0800 Subject: [PATCH] basic settings page --- src/App.tsx | 35 +++++---- src/components/settings/KeyboardShortcuts.tsx | 71 +++++++++++++++++++ src/components/settings/Settings.tsx | 29 ++++++++ tailwind.config.js | 11 +++ 4 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 src/components/settings/KeyboardShortcuts.tsx create mode 100644 src/components/settings/Settings.tsx create mode 100644 tailwind.config.js diff --git a/src/App.tsx b/src/App.tsx index 55f0cf9..3534d11 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,24 +1,14 @@ import { useEffect, useState } from "react"; - -// import { invoke } from "@tauri-apps/api/core"; import "./App.css"; - -// import { isRegistered, register } from "@tauri-apps/plugin-global-shortcut"; +import { Settings } from "./components/settings/Settings"; import { checkAccessibilityPermissions, requestAccessibilityPermissions, } from "tauri-plugin-macos-permissions-api"; function App() { - // const [greetMsg, setGreetMsg] = useState(""); - // const [name, setName] = useState(""); const [hasAccessibility, setHasAccessibility] = useState(false); - // async function greet() { - // // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ - // setGreetMsg(await invoke("greet", { name })); - // } - useEffect(() => { checkAccessibilityPermissions().then((hasPermissions) => { if (!hasPermissions) { @@ -32,14 +22,21 @@ function App() { }, []); return ( -
-

handy

- -
- accessibility perns: {hasAccessibility ? "true" : "false"} -
-
+
+ {!hasAccessibility && ( +
+
+
+

+ Accessibility permissions are required for keyboard shortcuts. +

+
+
+
+ )} + +
); } -export default App; +export default App; \ No newline at end of file diff --git a/src/components/settings/KeyboardShortcuts.tsx b/src/components/settings/KeyboardShortcuts.tsx new file mode 100644 index 0000000..e48df55 --- /dev/null +++ b/src/components/settings/KeyboardShortcuts.tsx @@ -0,0 +1,71 @@ +import React from 'react'; + +interface Shortcut { + id: string; + name: string; + description: string; + keys: string[]; +} + +export const KeyboardShortcuts: React.FC = () => { + // These would normally come from the backend configuration + const shortcuts: Shortcut[] = [ + { + id: 'transcribe', + name: 'Transcribe', + description: 'Convert speech to text', + keys: ['⌃', '⌘'], + }, + { + id: 'instruct', + name: 'AI Chat', + description: 'Start a conversation with AI', + keys: ['⇧', '⌥'], + }, + { + id: 'code', + name: 'Generate Code', + description: 'Generate code from voice input', + keys: ['⌃', '⌥', '⌘'], + }, + ]; + + return ( +
+ {shortcuts.map((shortcut) => ( +
+
+

{shortcut.name}

+

{shortcut.description}

+
+
+ {shortcut.keys.map((key, index) => ( + + + {key} + + {index < shortcut.keys.length - 1 && ( + + + )} + + ))} +
+
+ ))} + +
+
+
+

+ Note: Keyboard shortcuts are currently managed by the system. + Custom configuration will be available in a future update. +

+
+
+
+
+ ); +}; \ No newline at end of file diff --git a/src/components/settings/Settings.tsx b/src/components/settings/Settings.tsx new file mode 100644 index 0000000..215fc0d --- /dev/null +++ b/src/components/settings/Settings.tsx @@ -0,0 +1,29 @@ +import React from "react"; +// import { AIConfig } from "./AIConfig"; +import { KeyboardShortcuts } from "./KeyboardShortcuts"; + +export const Settings: React.FC = () => { + return ( +
+
+

Settings

+ + {/* AI Configuration Section */} +
+

+ AI Configuration +

+ {/* */} +
+ + {/* Keyboard Shortcuts Section */} +
+

+ Keyboard Shortcuts +

+ +
+
+
+ ); +}; diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..89a305e --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./index.html", + "./src/**/*.{js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], +} \ No newline at end of file