mirror of
https://github.com/penpot/penpot.git
synced 2025-06-18 18:42:14 +02:00
🎉 Add support color management via library
This commit is contained in:
parent
399d57ace0
commit
4c1f2cfded
2 changed files with 39 additions and 4 deletions
|
@ -498,15 +498,30 @@
|
||||||
|
|
||||||
(defn add-library-color
|
(defn add-library-color
|
||||||
[file color]
|
[file color]
|
||||||
|
|
||||||
(let [id (or (:id color) (uuid/next))]
|
(let [id (or (:id color) (uuid/next))]
|
||||||
(-> file
|
(-> file
|
||||||
(commit-change
|
(commit-change
|
||||||
{:type :add-color
|
{:type :add-color
|
||||||
:id id
|
|
||||||
:color (assoc color :id id)})
|
:color (assoc color :id id)})
|
||||||
(assoc :last-id id))))
|
(assoc :last-id id))))
|
||||||
|
|
||||||
|
(defn update-library-color
|
||||||
|
[file color]
|
||||||
|
(let [id (uuid/uuid (:id color))]
|
||||||
|
(-> file
|
||||||
|
(commit-change
|
||||||
|
{:type :mod-color
|
||||||
|
:color (assoc color :id id)})
|
||||||
|
(assoc :last-id (:id color)))))
|
||||||
|
|
||||||
|
(defn delete-library-color
|
||||||
|
[file color-id]
|
||||||
|
(let [id (uuid/uuid color-id)]
|
||||||
|
(-> file
|
||||||
|
(commit-change
|
||||||
|
{:type :del-color
|
||||||
|
:id id}))))
|
||||||
|
|
||||||
(defn add-library-typography
|
(defn add-library-typography
|
||||||
[file typography]
|
[file typography]
|
||||||
(let [id (or (:id typography) (uuid/next))]
|
(let [id (or (:id typography) (uuid/next))]
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
key (-> key d/name str/kebab keyword)]
|
key (-> key d/name str/kebab keyword)]
|
||||||
[key value])) $)))
|
[key value])) $)))
|
||||||
|
|
||||||
|
|
||||||
(defn export-file
|
(defn export-file
|
||||||
[file]
|
[file]
|
||||||
(let [file (assoc file
|
(let [file (assoc file
|
||||||
|
@ -51,6 +50,14 @@
|
||||||
(rx/observe-on :async)
|
(rx/observe-on :async)
|
||||||
(rx/flat-map e/get-page-data)
|
(rx/flat-map e/get-page-data)
|
||||||
(rx/share))
|
(rx/share))
|
||||||
|
|
||||||
|
colors-stream
|
||||||
|
(->> files-stream
|
||||||
|
(rx/flat-map vals)
|
||||||
|
(rx/map #(vector (:id %) (get-in % [:data :colors])))
|
||||||
|
(rx/filter #(d/not-empty? (second %)))
|
||||||
|
(rx/map e/parse-library-color))
|
||||||
|
|
||||||
pages-stream
|
pages-stream
|
||||||
(->> render-stream
|
(->> render-stream
|
||||||
(rx/map e/collect-page))]
|
(rx/map e/collect-page))]
|
||||||
|
@ -64,7 +71,8 @@
|
||||||
|
|
||||||
(->> (rx/merge
|
(->> (rx/merge
|
||||||
manifest-stream
|
manifest-stream
|
||||||
pages-stream)
|
pages-stream
|
||||||
|
colors-stream)
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/with-latest-from files-stream)
|
(rx/with-latest-from files-stream)
|
||||||
(rx/flat-map (fn [[data _]]
|
(rx/flat-map (fn [[data _]]
|
||||||
|
@ -133,6 +141,18 @@
|
||||||
(closeSVG [_]
|
(closeSVG [_]
|
||||||
(set! file (fb/close-svg-raw file)))
|
(set! file (fb/close-svg-raw file)))
|
||||||
|
|
||||||
|
(addLibraryColor [_ data]
|
||||||
|
(set! file (fb/add-library-color file (parse-data data)))
|
||||||
|
(str (:last-id file)))
|
||||||
|
|
||||||
|
(updateLibraryColor [_ data]
|
||||||
|
(set! file (fb/update-library-color file (parse-data data)))
|
||||||
|
(str (:last-id file)))
|
||||||
|
|
||||||
|
(deleteLibraryColor [_ data]
|
||||||
|
(set! file (fb/delete-library-color file (parse-data data)))
|
||||||
|
(str (:last-id file)))
|
||||||
|
|
||||||
(asMap [_]
|
(asMap [_]
|
||||||
(clj->js file))
|
(clj->js file))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue