Polish keymap list rendering and filter inactive platform shortcuts

Replace old <code> tag shortcut rendering with proper shui/shortcut key
badges, add flex-wrap layout for multiple bindings, styled status labels
for "Custom:" and "Unset", and filter platform-inactive shortcuts from
the data layer to prevent empty rows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
scheinriese
2026-03-09 12:15:35 +01:00
committed by Tienson Qin
parent def3dfb233
commit a9478e7583
3 changed files with 36 additions and 21 deletions

View File

@@ -716,6 +716,7 @@
(false? (first binding)))
unset? (and (not disabled?)
(or (= user-binding [])
(and (nil? binding) (nil? user-binding))
(and (= binding [])
(nil? user-binding))))]]
@@ -753,23 +754,22 @@
{:class (util/classnames [{:disabled disabled?}])}
(cond
(or unset? user-binding (false? user-binding))
[:code
(if unset?
(t :keymap/unset)
(str (t :keymap/custom) ": "
(if disabled?
(t :keymap/disabled)
(bean/->js
(map #(if (false? %)
(t :keymap/disabled)
(shortcut-utils/decorate-binding %)) user-binding)))))]
unset?
[:span.shortcut-status-label (t :keymap/unset)]
(not unset?)
[:code.flex.items-center.bg-transparent
{:style {:min-height "20px"
:flex-wrap "nowrap"
:white-space "nowrap"}}
(shui/shortcut
(string/join " | " (map #(dh/binding-for-display id %) binding))
{:raw-binding binding})])]]))))])])]]))
(or user-binding (false? user-binding))
[:<>
[:span.shortcut-status-label (str (t :keymap/custom) ":")]
(if disabled?
[:span.shortcut-status-label (t :keymap/disabled)]
(for [b user-binding
:when (string? b)]
[:span {:key b}
(shui/shortcut b)]))]
:else
(for [b binding
:when (string? b)]
[:span {:key b}
(shui/shortcut (dh/binding-for-display id b)
{:raw-binding [b]})]))]]))))])])]]))

View File

@@ -106,15 +106,28 @@
.label-wrap {
@apply flex flex-1;
min-width: 120px;
}
.action-wrap {
@apply flex space-x-2 items-center flex-nowrap
@apply flex items-center flex-wrap justify-end
select-none;
column-gap: 16px;
row-gap: 6px;
max-width: 55%;
&.disabled {
@apply opacity-60 cursor-default;
}
.shortcut-status-label {
@apply text-xs whitespace-nowrap;
opacity: 0.5;
&:not(:only-child) {
margin-right: -8px;
}
}
}
}

View File

@@ -104,7 +104,9 @@
(->> (if plugin?
(->> (keys dict) (filter #(string/starts-with? (str %) ":plugin.")))
(shortcut-config/get-category-shortcuts name))
(mapv (fn [k] [k (assoc (get dict k) :category name)])))))
(keep (fn [k] (when-let [m (get dict k)]
[k (assoc m :category name)])))
(vec))))
(defn shortcuts-map-full
[]