mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-22 16:24:11 +01:00
Share Yaak's request and response panes (#815)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad0533901
commit
08a98d5f82
85 files changed
+5567
-2872
No files matched your search
@@ -21,6 +21,8 @@ export interface HotkeyContextValue {
|
||||
os: string;
|
||||
/** The key combos bound to an action, like `["Meta+Shift+s"]`, or null when it has none */
|
||||
bindingFor: (action: HotkeyAction) => string[] | null;
|
||||
/** What an action does, in words, for lists of shortcuts. Falls back to the action's name */
|
||||
labelFor?: (action: HotkeyAction) => string;
|
||||
/** Bind a callback to an action's keys, returning the unbind */
|
||||
register: (
|
||||
action: HotkeyAction,
|
||||
@@ -49,6 +51,11 @@ export function useHotKey(
|
||||
}, [action, callback, options, register]);
|
||||
}
|
||||
|
||||
export function useHotkeyLabel(action: HotkeyAction): string {
|
||||
const { labelFor } = useContext(HotkeyContext);
|
||||
return labelFor?.(action) ?? action;
|
||||
}
|
||||
|
||||
export function useFormattedHotkey(action: HotkeyAction | null): string[] | null {
|
||||
const { os, bindingFor } = useContext(HotkeyContext);
|
||||
const trigger = action == null ? null : (bindingFor(action)?.[0] ?? null);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
export function useToggle(initialValue = false) {
|
||||
const [value, setValue] = useState<boolean>(initialValue);
|
||||
const toggle = useCallback(() => setValue((v) => !v), []);
|
||||
return [value, toggle, setValue] as const;
|
||||
}
|
||||
Reference in new issue
Block a user