mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
✨ Allows renaming when new typography and context menu
This commit is contained in:
parent
5f650832e6
commit
bd92936a64
3 changed files with 39 additions and 13 deletions
|
@ -541,10 +541,13 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
(let [rchg {:type :add-typography
|
||||
:typography typography}
|
||||
:typography (assoc typography :ts (.now js/Date))}
|
||||
uchg {:type :del-typography
|
||||
:id (:id typography)}]
|
||||
(rx/of (dwc/commit-changes [rchg] [uchg] {:commit-local? true})))))))
|
||||
(rx/of (dwc/commit-changes [rchg] [uchg] {:commit-local? true})
|
||||
#(assoc-in %
|
||||
[:workspace-local :rename-typography]
|
||||
(:id typography))))))))
|
||||
|
||||
(defn update-typography
|
||||
[typography]
|
||||
|
|
|
@ -380,10 +380,25 @@
|
|||
(mf/deps file-id)
|
||||
(fn [event] ))
|
||||
|
||||
handle-rename-typography-clicked (fn [])
|
||||
handle-edit-typography-clicked (fn [] )
|
||||
handle-delete-typography (fn []
|
||||
(st/emit! (dwl/delete-typography (:id @state))))]
|
||||
handle-rename-typography-clicked
|
||||
(fn []
|
||||
(st/emit! #(assoc-in % [:workspace-local :rename-typography] (:id @state))))
|
||||
|
||||
handle-edit-typography-clicked
|
||||
(fn []
|
||||
(st/emit! #(assoc-in % [:workspace-local :edit-typography] (:id @state))))
|
||||
|
||||
handle-delete-typography
|
||||
(fn []
|
||||
(st/emit! (dwl/delete-typography (:id @state))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps local)
|
||||
(fn []
|
||||
(when (:rename-typography local)
|
||||
(st/emit! #(update % :workspace-local dissoc :rename-typography)))
|
||||
(when (:edit-typography local)
|
||||
(st/emit! #(update % :workspace-local dissoc :edit-typography)))))
|
||||
|
||||
[:div.asset-group
|
||||
[:div.group-title {:class (when (not open?) "closed")}
|
||||
|
@ -403,14 +418,17 @@
|
|||
[(t locale "workspace.assets.delete") handle-delete-typography]]}]
|
||||
(when open?
|
||||
[:div.group-list
|
||||
(for [typography (sort-by (comp - :ts) typographies)]
|
||||
(for [typography (sort-by :ts typographies)]
|
||||
[:& typography-entry
|
||||
{:key (:id typography)
|
||||
:typography typography
|
||||
:read-only? (not local?)
|
||||
:on-context-menu #(on-context-menu (:id typography) %)
|
||||
:on-change #(handle-change typography %)
|
||||
:on-select #(handle-typography-selection typography)}])])]))
|
||||
:on-select #(handle-typography-selection typography)
|
||||
:editting? (or (= (:rename-typography local) (:id typography))
|
||||
(= (:edit-typography local) (:id typography)))
|
||||
:focus-name? (= (:rename-typography local) (:id typography))}])])]))
|
||||
|
||||
(defn file-colors-ref
|
||||
[id]
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
[app.main.data.workspace.texts :as dwt]
|
||||
[app.main.ui.components.editable-select :refer [editable-select]]
|
||||
[app.main.ui.workspace.sidebar.options.common :refer [advanced-options]]
|
||||
[app.util.dom :as dom]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.timers :as ts]
|
||||
[app.util.i18n :as i18n :refer [t]]))
|
||||
|
||||
(defn- attr->string [value]
|
||||
|
@ -216,14 +217,18 @@
|
|||
|
||||
(mf/use-effect
|
||||
(mf/deps editting?)
|
||||
(fn [] (reset! open? editting?)))
|
||||
(fn []
|
||||
(when editting?
|
||||
(reset! open? editting?))))
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps focus-name?)
|
||||
(fn []
|
||||
(when-let [node (mf/ref-val name-input-ref)]
|
||||
(dom/focus! node)
|
||||
(dom/select-text! node))))
|
||||
(when focus-name?
|
||||
(ts/schedule 100
|
||||
#(when-let [node (mf/ref-val name-input-ref)]
|
||||
(dom/focus! node)
|
||||
(dom/select-text! node))))))
|
||||
|
||||
[:*
|
||||
[:div.element-set-options-group.typography-entry
|
||||
|
|
Loading…
Add table
Reference in a new issue