From 91c9d4a4a26cb4f3a1a6e3b8ee5f7367c3ec5ad8 Mon Sep 17 00:00:00 2001 From: Jake <134332787+justjxke@users.noreply.github.com> Date: Tue, 9 Dec 2025 16:56:38 +0000 Subject: [PATCH] fix/commandPalette (#547) * CMD on MacOS fix * misc improvements --- src/equicordplugins/commandPalette/index.tsx | 58 +++++++------- .../commandPalette/settingsPanel.tsx | 80 +++++++++---------- src/equicordplugins/commandPalette/style.css | 60 ++++++-------- 3 files changed, 92 insertions(+), 106 deletions(-) diff --git a/src/equicordplugins/commandPalette/index.tsx b/src/equicordplugins/commandPalette/index.tsx index 7704d7913..d3efb6577 100644 --- a/src/equicordplugins/commandPalette/index.tsx +++ b/src/equicordplugins/commandPalette/index.tsx @@ -5,10 +5,11 @@ */ import { definePluginSettings } from "@api/Settings"; -import { classNameFactory } from "@api/Styles"; +import { BaseText } from "@components/BaseText"; +import { Button } from "@components/Button"; import { EquicordDevs, IS_MAC } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, Text, useEffect, useRef, useState } from "@webpack/common"; +import { useEffect, useState } from "@webpack/common"; import { cleanupCommandPaletteRuntime, registerBuiltInCommands, wrapChatBarChildren } from "./registry"; import { CommandPaletteSettingsPanel } from "./settingsPanel"; @@ -16,7 +17,6 @@ import { openCommandPalette } from "./ui"; const DEFAULT_KEYS = IS_MAC ? ["Meta", "Shift", "P"] : ["Control", "Shift", "P"]; -const cl = classNameFactory("vc-cp-"); const isRecordingGlobal = false; let openScheduled = false; @@ -37,7 +37,6 @@ function formatKeybind(keybind: string | string[]): string { function KeybindRecorder() { const [isListening, setIsListening] = useState(false); const [error, setError] = useState(null); - const buttonRef = useRef(null); const currentKeybind = settings.use(["hotkey"]).hotkey; useEffect(() => { @@ -52,11 +51,11 @@ function KeybindRecorder() { } const keys: string[] = []; - if (IS_MAC && event.ctrlKey) { - if (event.ctrlKey) keys.push("CONTROL"); - if (event.metaKey) keys.push("CTRL"); - } else if (event.ctrlKey) { - keys.push("CTRL"); + if (event.metaKey) { + keys.push("META"); + } + if (event.ctrlKey) { + keys.push(IS_MAC ? "CONTROL" : "CTRL"); } if (event.shiftKey) keys.push("SHIFT"); if (event.altKey) keys.push("ALT"); @@ -79,8 +78,6 @@ function KeybindRecorder() { document.addEventListener("keydown", handleKeyDown, true); window.addEventListener("blur", handleBlur); - buttonRef.current?.focus(); - return () => { document.removeEventListener("keydown", handleKeyDown, true); window.removeEventListener("blur", handleBlur); @@ -93,31 +90,34 @@ function KeybindRecorder() { }; return ( -
-
- Command Palette Hotkey - +
+
+ Command Palette Hotkey + Hotkey used to open the command palette - + {error && ( - + {error} - + )}
-
- - +
diff --git a/src/equicordplugins/commandPalette/settingsPanel.tsx b/src/equicordplugins/commandPalette/settingsPanel.tsx index f419249f3..38f74437e 100644 --- a/src/equicordplugins/commandPalette/settingsPanel.tsx +++ b/src/equicordplugins/commandPalette/settingsPanel.tsx @@ -4,8 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { Button, TextButton } from "@components/Button"; +import { Heading } from "@components/Heading"; +import { Paragraph } from "@components/Paragraph"; import { Switch } from "@components/Switch"; -import { Button, Forms, React, Select, TextInput } from "@webpack/common"; +import { React, Select, TextInput } from "@webpack/common"; import { openCommandPicker } from "./CommandPicker"; import { @@ -169,7 +172,7 @@ function renderActionFields(command: CustomCommandDefinition, onChange: (action: onChange={value => onChange({ type: "command", commandId: value })} />
); @@ -248,7 +251,7 @@ function renderActionFields(command: CustomCommandDefinition, onChange: (action: onChange={value => onChange({ type: "macro", steps: parseListInput(value) })} /> + ))}
)} {invalidSteps.length > 0 && ( - + Unknown command IDs: {invalidSteps.join(", ")} - + )} ); @@ -350,11 +352,11 @@ export function CommandPaletteSettingsPanel() { return (
- Custom Commands - + Custom Commands + {/* Hank, don't abbreviate cyberpunk hank */} 1) Name the command · 2) Add optional description/keywords/tags/category · 3) Choose an action and fill its details (IDs should match existing palette commands for aliases and macros). - +
{commands.map(command => { const manualAdvanced = advancedOpen[command.id]; @@ -370,14 +372,15 @@ export function CommandPaletteSettingsPanel() { return (
- {command.label || "Untitled Command"} - +
{!isCollapsed && ( @@ -416,20 +419,19 @@ export function CommandPaletteSettingsPanel() { serialize={option => option.value} />
- + {ACTION_HELP_TEXT[command.action.type]} - +
{renderActionFields(command, action => handleUpdate(command.id, prev => duplicateWithUpdates(prev, { action })))} - + {showAdvanced && (
@@ -454,9 +456,9 @@ export function CommandPaletteSettingsPanel() { /> {tagMeta.length > 0 && (
- + Suggestions - +
{tagMeta .filter(meta => !(command.tags ?? []).some(tag => normalizeTag(tag) === meta.id)) @@ -464,8 +466,8 @@ export function CommandPaletteSettingsPanel() { .map(meta => (
)} @@ -509,8 +511,8 @@ export function CommandPaletteSettingsPanel() { )}
-
diff --git a/src/equicordplugins/commandPalette/style.css b/src/equicordplugins/commandPalette/style.css index f69647887..2b297803f 100644 --- a/src/equicordplugins/commandPalette/style.css +++ b/src/equicordplugins/commandPalette/style.css @@ -682,37 +682,32 @@ } /* Keybind recorder styles */ -.vc-cp-keybind-input { +.vc-command-palette-keybind-input { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; - padding: 12px; - background-color: var(--background-secondary-alt); + padding: 12px 0; border-radius: 8px; transition: background-color 0.2s ease; } -.vc-cp-keybind-input:hover { - background-color: var(--background-secondary-alt); -} - -.vc-cp-keybind-info { +.vc-command-palette-keybind-info { display: flex; flex-direction: column; gap: 4px; flex: 1; } -.vc-cp-keybind-controls { +.vc-command-palette-keybind-controls { display: flex; flex-direction: row; align-items: center; gap: 8px; } -.vc-cp-keybind-button { +.vc-command-palette-keybind-button { padding: 8px 16px; background-color: var(--background-base-low); border: 2px solid var(--input-border); @@ -728,55 +723,48 @@ box-shadow: 0 0 0 1px var(--background-modifier-accent); } -.vc-cp-keybind-button:hover:not(:disabled) { +.vc-command-palette-keybind-button:hover:not(:disabled) { background-color: var(--background-modifier-hover); border-color: var(--brand-experiment); transform: translateY(-1px); box-shadow: 0 2px 8px rgb(0 0 0 / 20%); } -.vc-cp-keybind-button:active:not(:disabled) { +.vc-command-palette-keybind-button.listening:hover:not(:disabled) { + background: linear-gradient(135deg, var(--brand-experiment) 0%, var(--brand-experiment-560) 100%); + border-color: var(--status-danger, #f04747); + box-shadow: none; + transform: translateY(-1px); +} + +.vc-command-palette-keybind-button:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 4px rgb(0 0 0 / 20%); } -.vc-cp-keybind-button:disabled { +.vc-command-palette-keybind-button:disabled { opacity: 0.5; cursor: not-allowed; } -.vc-cp-keybind-button.listening { +.vc-command-palette-keybind-button.listening { background: linear-gradient(135deg, var(--brand-experiment) 0%, var(--brand-experiment-560) 100%); color: var(--white); - border-color: var(--brand-experiment); - animation: vc-cp-keybind-pulse 1.5s ease-in-out infinite; - box-shadow: 0 0 12px var(--brand-experiment); + border-color: var(--status-danger, #f04747); + animation: none; + transform: translateY(-1px); + box-shadow: 0 2px 8px rgb(var(--status-danger-rgb, 240 71 71) / 60%); } -@keyframes vc-cp-keybind-pulse { - - /* stylelint-disable-next-line rule-empty-line-before */ - 0%, - 100% { - opacity: 1; - transform: scale(1); - } - - 50% { - opacity: 0.85; - transform: scale(1.02); - } -} - -.vc-cp-keybind-conflict { +.vc-command-palette-keybind-conflict { color: var(--text-feedback-critical); font-size: 12px; font-weight: 500; margin-top: 2px; - animation: vc-cp-keybind-shake 0.3s ease; + animation: vc-command-palette-keybind-shake 0.3s ease; } -@keyframes vc-cp-keybind-shake { +@keyframes vc-command-palette-keybind-shake { /* stylelint-disable-next-line rule-empty-line-before */ 0%, @@ -795,4 +783,4 @@ /* stylelint-enable no-descending-specificity */ -/* fuck you css */ \ No newline at end of file +/* fuck you css */