Typographic styles enhancements and fixes

This commit is contained in:
alonso.torres 2020-10-16 09:37:33 +02:00 committed by Andrey Antukh
parent a7335533bb
commit 447bb5204d
5 changed files with 37 additions and 22 deletions

View file

@ -768,6 +768,17 @@
z-index: 10; z-index: 10;
} }
.advanced-options-wrapper {
position: absolute;
width: 100%;
padding-right: 1.5rem;
padding-left: 0.25rem;
}
.element-options .advanced-options-wrapper {
padding-right: 1rem;
}
.advanced-options { .advanced-options {
background-color: #303236; background-color: #303236;
border-radius: 4px; border-radius: 4px;

View file

@ -533,20 +533,21 @@
:sync-dialog)))))) :sync-dialog))))))
(defn add-typography (defn add-typography
[typography] ([typography] (add-typography typography true))
(let [typography (update typography :id #(or % (uuid/next)))] ([typography edit?]
(us/assert ::cp/typography typography) (let [typography (update typography :id #(or % (uuid/next)))]
(ptk/reify ::add-typography (us/assert ::cp/typography typography)
ptk/WatchEvent (ptk/reify ::add-typography
(watch [_ state s] ptk/WatchEvent
(let [rchg {:type :add-typography (watch [_ state s]
:typography (assoc typography :ts (.now js/Date))} (let [rchg {:type :add-typography
uchg {:type :del-typography :typography (assoc typography :ts (.now js/Date))}
:id (:id typography)}] uchg {:type :del-typography
(rx/of (dwc/commit-changes [rchg] [uchg] {:commit-local? true}) :id (:id typography)}]
#(assoc-in % (rx/of (dwc/commit-changes [rchg] [uchg] {:commit-local? true})
[:workspace-local :rename-typography] #(cond-> %
(:id typography)))))))) edit?
(assoc-in [:workspace-local :rename-typography] (:id typography))))))))))
(defn update-typography (defn update-typography
[typography] [typography]

View file

@ -391,7 +391,9 @@
handle-delete-typography handle-delete-typography
(fn [] (fn []
(st/emit! (dwl/delete-typography (:id @state))))] (st/emit! (dwl/delete-typography (:id @state))))
editting-id (or (:rename-typography local) (:edit-typography local))]
(mf/use-effect (mf/use-effect
(mf/deps local) (mf/deps local)
@ -428,8 +430,7 @@
:on-context-menu #(on-context-menu (:id typography) %) :on-context-menu #(on-context-menu (:id typography) %)
:on-change #(handle-change 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)) :editting? (= editting-id (:id typography))
(= (:edit-typography local) (:id typography)))
:focus-name? (= (:rename-typography local) (:id typography))}])])])) :focus-name? (= (:rename-typography local) (:id typography))}])])]))
(defn file-colors-ref (defn file-colors-ref

View file

@ -19,6 +19,7 @@
(when visible? (when visible?
[:* [:*
[:div.focus-overlay {:on-click handle-click}] [:div.focus-overlay {:on-click handle-click}]
[:div.advanced-options {} [:div.advanced-options-wrapper
children]]))) [:div.advanced-options {}
children]]])))

View file

@ -215,7 +215,7 @@
(get typographies (:typography-ref-id values))) (get typographies (:typography-ref-id values)))
handle-click on-convert-to-typography
(mf/use-callback (mf/use-callback
(mf/deps values) (mf/deps values)
(fn [event] (fn [event]
@ -227,7 +227,7 @@
typography (merge ut/default-typography setted-values) typography (merge ut/default-typography setted-values)
typography (generate-typography-name typography)] typography (generate-typography-name typography)]
(let [id (uuid/next)] (let [id (uuid/next)]
(st/emit! (dwl/add-typography (assoc typography :id id))) (st/emit! (dwl/add-typography (assoc typography :id id) false))
(run! #(emit-update! % {:typography-ref-id id}) ids))))) (run! #(emit-update! % {:typography-ref-id id}) ids)))))
handle-deattach-typography handle-deattach-typography
@ -251,7 +251,8 @@
[:div.element-set [:div.element-set
[:div.element-set-title [:div.element-set-title
[:span label] [:span label]
[:div.add-page {:on-click handle-click} i/close]] (when (not typography)
[:div.add-page {:on-click on-convert-to-typography} i/close])]
(cond (cond
typography typography