refactor(shortcuts): simplify chord display and clean up capture UI

This commit is contained in:
Mohamed Boudra
2026-03-22 17:44:49 +07:00
parent 57f8c7615c
commit cc80d05e49
5 changed files with 41 additions and 21 deletions
+2 -14
View File
@@ -35,11 +35,8 @@ export function Shortcut({
<View style={[styles.sequence, style]}>
{displayChord.map(function (combo, index) {
return (
<View key={`${combo.join("+")}-${index}`} style={styles.sequenceItem}>
<View style={styles.badge}>
<Text style={[styles.text, textStyle]}>{formatShortcut(combo, shortcutOs)}</Text>
</View>
{index < displayChord.length - 1 ? <Text style={styles.separator}>→</Text> : null}
<View key={`${combo.join("+")}-${index}`} style={styles.badge}>
<Text style={[styles.text, textStyle]}>{formatShortcut(combo, shortcutOs)}</Text>
</View>
);
})}
@@ -62,15 +59,6 @@ const styles = StyleSheet.create((theme) => ({
flexWrap: "wrap",
gap: theme.spacing[1],
},
sequenceItem: {
flexDirection: "row",
alignItems: "center",
gap: theme.spacing[1],
},
separator: {
fontSize: theme.fontSize.xs,
color: theme.colors.foregroundMuted,
},
text: {
fontSize: theme.fontSize.xs,
fontWeight: theme.fontWeight.normal,
@@ -125,11 +125,6 @@ export function KeyboardShortcutsSection() {
event.stopPropagation();
const key = event.key ?? "";
if (key === "Escape") {
cancelCapture();
return;
}
if (key === "Backspace") {
setCapturedCombos((current) => (current.length > 0 ? current.slice(0, -1) : current));
return;
@@ -147,7 +142,7 @@ export function KeyboardShortcutsSection() {
return () => {
window.removeEventListener("keydown", handleKeyDown, true);
};
}, [cancelCapture, capturingBindingId]);
}, [capturingBindingId]);
useEffect(() => {
return () => {
+1 -1
View File
@@ -5,7 +5,7 @@ export type ShortcutOs = "mac" | "non-mac";
const KEY_DISPLAY: Record<string, string> = {
Backspace: "⌫",
Enter: "↩",
Esc: "⎋",
Esc: "Esc",
Space: "␣",
Left: "←",
Right: "→",