0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

🎉 Add support color management via library

This commit is contained in:
Alejandro Alonso 2022-11-28 09:47:47 +01:00
parent 399d57ace0
commit 4c1f2cfded
2 changed files with 39 additions and 4 deletions

View file

@ -498,15 +498,30 @@
(defn add-library-color
[file color]
(let [id (or (:id color) (uuid/next))]
(-> file
(commit-change
{:type :add-color
:id id
:color (assoc color :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
[file typography]
(let [id (or (:id typography) (uuid/next))]

View file

@ -27,7 +27,6 @@
key (-> key d/name str/kebab keyword)]
[key value])) $)))
(defn export-file
[file]
(let [file (assoc file
@ -51,6 +50,14 @@
(rx/observe-on :async)
(rx/flat-map e/get-page-data)
(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
(->> render-stream
(rx/map e/collect-page))]
@ -64,7 +71,8 @@
(->> (rx/merge
manifest-stream
pages-stream)
pages-stream
colors-stream)
(rx/reduce conj [])
(rx/with-latest-from files-stream)
(rx/flat-map (fn [[data _]]
@ -133,6 +141,18 @@
(closeSVG [_]
(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 [_]
(clj->js file))