mirror of
https://github.com/penpot/penpot.git
synced 2026-08-08 13:58:35 +00:00
🎉 Improve reset to default flow
This commit is contained in:
parent
056cd3d379
commit
14931c1bac
@ -371,12 +371,15 @@
|
||||
conflict* (mf/use-state nil)
|
||||
conflict (deref conflict*)
|
||||
|
||||
reset-notification* (mf/use-state nil)
|
||||
|
||||
clean-editing-state
|
||||
(fn []
|
||||
(reset! is-editing* false)
|
||||
(reset! display-parts* nil)
|
||||
(reset! recorded-command* nil)
|
||||
(reset! conflict* nil))
|
||||
(reset! conflict* nil)
|
||||
(reset! reset-notification* nil))
|
||||
|
||||
effective-section-key (if (= section-key :basics) :workspace section-key)
|
||||
|
||||
@ -385,7 +388,9 @@
|
||||
(mf/deps effective-section-key command-info)
|
||||
(fn [shortcut-key]
|
||||
(st/emit! (customize/reset-custom-shortcut shortcut-key (:original-command command-info) effective-section-key))
|
||||
(clean-editing-state)))
|
||||
(reset! reset-notification* (:original-command command-info))
|
||||
(reset! recorded-command* nil)
|
||||
(reset! conflict* nil)))
|
||||
|
||||
start-editing
|
||||
(mf/use-fn
|
||||
@ -437,6 +442,15 @@
|
||||
(when is-editing
|
||||
(some-> (mf/ref-val recording-ref) (dom/focus!))))
|
||||
|
||||
(mf/with-effect [display-parts]
|
||||
(when (some? display-parts)
|
||||
(reset! reset-notification* nil)))
|
||||
|
||||
(mf/with-effect [@reset-notification*]
|
||||
(when-let [_ @reset-notification*]
|
||||
(let [timer (js/setTimeout #(reset! reset-notification* nil) 7000)]
|
||||
(fn [] (js/clearTimeout timer)))))
|
||||
|
||||
(mf/with-effect [is-editing]
|
||||
(when is-editing
|
||||
(letfn [(on-keydown [^js event]
|
||||
@ -506,6 +520,14 @@
|
||||
:customized-key customized?)} (:final-key display-parts)])
|
||||
(when-not (:finalized? display-parts)
|
||||
[:span {:class (stl/css :recording-ellipsis)} "..."])])]
|
||||
(when-let [default-cmd @reset-notification*]
|
||||
[:> context-notification* {:level :info :class (stl/css :modal-reset-msg)}
|
||||
(tr "shortcuts.edit-modal.reset-to-default")
|
||||
[:> shortcuts-keys* {:content default-cmd
|
||||
:command (keyword "default")
|
||||
:is-customized false
|
||||
:has-conflict? false}]])
|
||||
|
||||
(when recorded-command
|
||||
(if conflict
|
||||
[:> context-notification* {:level :warning :class (stl/css :modal-error-msg)}
|
||||
|
||||
@ -5710,6 +5710,10 @@ msgstr "Press the key combination"
|
||||
msgid "shortcuts.edit-modal.conflict"
|
||||
msgstr "Combination assigned to \"%s\". Saving will remove it there."
|
||||
|
||||
#: src/app/main/ui/shortcuts.cljs
|
||||
msgid "shortcuts.edit-modal.reset-to-default"
|
||||
msgstr "Shortcut reset to default:"
|
||||
|
||||
#: src/app/main/ui/shortcuts.cljs
|
||||
msgid "shortcuts.edit-modal.success"
|
||||
msgstr "This key combination is available and can be assigned without conflicts."
|
||||
|
||||
@ -5565,6 +5565,10 @@ msgstr "Pulsa la combinación de teclas deseada"
|
||||
msgid "shortcuts.edit-modal.conflict"
|
||||
msgstr "Combinación usada en \"%s\". Guardar este atajo hará que se elimine allí."
|
||||
|
||||
#: src/app/main/ui/shortcuts.cljs
|
||||
msgid "shortcuts.edit-modal.reset-to-default"
|
||||
msgstr "Atajo restablecido a su valor predeterminado:"
|
||||
|
||||
#: src/app/main/ui/shortcuts.cljs
|
||||
msgid "shortcuts.edit-modal.success"
|
||||
msgstr "Esta combinación de teclas está disponible y puede asignarse sin conflictos."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user