mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 11:06:11 +02:00
✨ Move data.colors under workspace namespace.
This commit is contained in:
parent
874378869d
commit
e4d4245b6c
19 changed files with 72 additions and 81 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.data.shortcuts
|
(ns app.main.data.shortcuts
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.workspace.transforms :as dwt]
|
[app.main.data.workspace.transforms :as dwt]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.data.viewer.shortcuts
|
(ns app.main.data.viewer.shortcuts
|
||||||
(:require
|
(:require
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.shortcuts :as ds]
|
[app.main.data.shortcuts :as ds]
|
||||||
[app.main.data.shortcuts :refer [c-mod]]
|
[app.main.data.shortcuts :refer [c-mod]]
|
||||||
[app.main.data.viewer :as dv]
|
[app.main.data.viewer :as dv]
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.constants :as c]
|
[app.main.constants :as c]
|
||||||
[app.main.data.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.messages :as dm]
|
[app.main.data.messages :as dm]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.drawing :as dwd]
|
[app.main.data.workspace.drawing :as dwd]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) UXBOX Labs SL
|
;; Copyright (c) UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.main.data.colors
|
(ns app.main.data.workspace.colors
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
|
@ -38,8 +38,7 @@
|
||||||
(ptk/reify ::rename-color
|
(ptk/reify ::rename-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(->> (rp/mutation! :rename-color {:id color-id
|
(->> (rp/mutation! :rename-color {:id color-id :name name})
|
||||||
:name name})
|
|
||||||
(rx/map (partial rename-color-result file-id))))))
|
(rx/map (partial rename-color-result file-id))))))
|
||||||
|
|
||||||
(defn rename-color-result
|
(defn rename-color-result
|
||||||
|
@ -101,8 +100,7 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :workspace-local dissoc :picked-color-select)
|
(update :workspace-local dissoc :picked-color-select :picked-shift?)
|
||||||
(update :workspace-local dissoc :picked-shift?)
|
|
||||||
(assoc-in [:workspace-local :picking-color?] false)))))
|
(assoc-in [:workspace-local :picking-color?] false)))))
|
||||||
|
|
||||||
(defn pick-color
|
(defn pick-color
|
||||||
|
@ -123,75 +121,68 @@
|
||||||
(assoc-in [:workspace-local :picked-shift?] shift?)))))
|
(assoc-in [:workspace-local :picked-shift?] shift?)))))
|
||||||
|
|
||||||
(defn change-fill
|
(defn change-fill
|
||||||
([ids color]
|
[ids color]
|
||||||
(ptk/reify ::change-fill
|
(ptk/reify ::change-fill
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [pid (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (get-in state [:workspace-data :pages-index pid :objects])
|
objects (dwc/lookup-page-objects state page-id)
|
||||||
not-frame (fn [shape-id] (not= (get-in objects [shape-id :type]) :frame))
|
|
||||||
is-text? #(= :text (:type (get objects %)))
|
|
||||||
text-ids (filter is-text? ids)
|
|
||||||
shape-ids (filter (comp not is-text?) ids)
|
|
||||||
|
|
||||||
attrs (cond-> {}
|
is-text? #(= :text (:type (get objects %)))
|
||||||
(contains? color :color)
|
text-ids (filter is-text? ids)
|
||||||
(assoc :fill-color (:color color))
|
shape-ids (filter (comp not is-text?) ids)
|
||||||
|
|
||||||
(contains? color :id)
|
attrs (cond-> {}
|
||||||
(assoc :fill-color-ref-id (:id color))
|
(contains? color :color)
|
||||||
|
(assoc :fill-color (:color color))
|
||||||
|
|
||||||
(contains? color :file-id)
|
(contains? color :id)
|
||||||
(assoc :fill-color-ref-file (:file-id color))
|
(assoc :fill-color-ref-id (:id color))
|
||||||
|
|
||||||
(contains? color :gradient)
|
(contains? color :file-id)
|
||||||
(assoc :fill-color-gradient (:gradient color))
|
(assoc :fill-color-ref-file (:file-id color))
|
||||||
|
|
||||||
(contains? color :opacity)
|
(contains? color :gradient)
|
||||||
(assoc :fill-opacity (:opacity color)))
|
(assoc :fill-color-gradient (:gradient color))
|
||||||
|
|
||||||
update-fn (fn [shape] (merge shape attrs))
|
(contains? color :opacity)
|
||||||
editors (get-in state [:workspace-local :editors])
|
(assoc :fill-opacity (:opacity color)))]
|
||||||
reduce-fn (fn [state id]
|
|
||||||
(update-in state [:workspace-data :pages-index pid :objects id] update-fn))]
|
|
||||||
|
|
||||||
(rx/from (conj
|
(rx/concat
|
||||||
(map #(dwt/update-text-attrs {:id % :editor (get editors %) :attrs attrs}) text-ids)
|
(rx/from (map #(dwt/update-text-attrs {:id % :attrs attrs}) text-ids))
|
||||||
(dwc/update-shapes shape-ids update-fn))))))))
|
(rx/of (dwc/update-shapes shape-ids (fn [shape] (d/merge shape attrs)))))))))
|
||||||
|
|
||||||
(defn change-stroke
|
(defn change-stroke
|
||||||
[ids color]
|
[ids color]
|
||||||
(ptk/reify ::change-stroke
|
(ptk/reify ::change-stroke
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [pid (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (get-in state [:workspace-data :pages-index pid :objects])
|
objects (dwc/lookup-page-objects state page-id)
|
||||||
not-frame (fn [shape-id] (not= (get-in objects [shape-id :type]) :frame))
|
|
||||||
|
|
||||||
color-attrs (cond-> {}
|
attrs (cond-> {}
|
||||||
(contains? color :color)
|
(contains? color :color)
|
||||||
(assoc :stroke-color (:color color))
|
(assoc :stroke-color (:color color))
|
||||||
|
|
||||||
(contains? color :id)
|
(contains? color :id)
|
||||||
(assoc :stroke-color-ref-id (:id color))
|
(assoc :stroke-color-ref-id (:id color))
|
||||||
|
|
||||||
(contains? color :file-id)
|
(contains? color :file-id)
|
||||||
(assoc :stroke-color-ref-file (:file-id color))
|
(assoc :stroke-color-ref-file (:file-id color))
|
||||||
|
|
||||||
(contains? color :gradient)
|
(contains? color :gradient)
|
||||||
(assoc :stroke-color-gradient (:gradient color))
|
(assoc :stroke-color-gradient (:gradient color))
|
||||||
|
|
||||||
(contains? color :opacity)
|
(contains? color :opacity)
|
||||||
(assoc :stroke-opacity (:opacity color)))
|
(assoc :stroke-opacity (:opacity color)))]
|
||||||
|
|
||||||
|
(rx/of (dwc/update-shapes ids (fn [shape]
|
||||||
|
(cond-> (d/merge shape attrs)
|
||||||
|
(= (:stroke-style shape) :none)
|
||||||
|
(assoc :stroke-style :solid
|
||||||
|
:stroke-width 1
|
||||||
|
:stroke-opacity 1)))))))))
|
||||||
|
|
||||||
update-fn (fn [shape]
|
|
||||||
(-> shape
|
|
||||||
(merge color-attrs)
|
|
||||||
(cond-> (= (:stroke-style s) :none)
|
|
||||||
(assoc :stroke-style :solid
|
|
||||||
:stroke-width 1
|
|
||||||
:stroke-opacity 1))))]
|
|
||||||
(rx/of (dwc/update-shapes ids update-fn))))))
|
|
||||||
|
|
||||||
(defn picker-for-selected-shape
|
(defn picker-for-selected-shape
|
||||||
[]
|
[]
|
||||||
|
@ -199,15 +190,15 @@
|
||||||
(ptk/reify ::picker-for-selected-shape
|
(ptk/reify ::picker-for-selected-shape
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [ids (get-in state [:workspace-local :selected])
|
(let [ids (get-in state [:workspace-local :selected])
|
||||||
stop? (->> stream
|
stop? (rx/filter (ptk/type? ::stop-picker) stream)
|
||||||
(rx/filter (ptk/type? ::stop-picker)))
|
|
||||||
|
|
||||||
update-events (fn [[color shift?]]
|
update-events
|
||||||
(rx/of (if shift?
|
(fn [[color shift?]]
|
||||||
(change-stroke ids color)
|
(rx/of (if shift?
|
||||||
(change-fill ids color))
|
(change-stroke ids color)
|
||||||
(stop-picker)))]
|
(change-fill ids color))
|
||||||
|
(stop-picker)))]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
;; Stream that updates the stroke/width and stops if `esc` pressed
|
;; Stream that updates the stroke/width and stops if `esc` pressed
|
||||||
(->> sub
|
(->> sub
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.data.workspace.shortcuts
|
(ns app.main.data.workspace.shortcuts
|
||||||
(:require
|
(:require
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.shortcuts :as ds]
|
[app.main.data.shortcuts :as ds]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.ui.workspace.colorpalette
|
(ns app.main.ui.workspace.colorpalette
|
||||||
(:require
|
(:require
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.main.data.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.workspace :as udw]
|
[app.main.data.workspace :as udw]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
[app.util.i18n :as i18n :refer [t]]))
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
[app.util.i18n :as i18n :refer [t]]))
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
[app.util.i18n :as i18n :refer [t]]))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.ui.workspace.sidebar.options.menus.fill
|
(ns app.main.ui.workspace.sidebar.options.menus.fill
|
||||||
(:require
|
(:require
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.math :as math]
|
[app.common.math :as math]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]]
|
[app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]]
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.colors :as dc]))
|
[app.main.data.workspace.colors :as dc]))
|
||||||
|
|
||||||
(def gradient-line-stroke-width 2)
|
(def gradient-line-stroke-width 2)
|
||||||
(def gradient-line-stroke-color "white")
|
(def gradient-line-stroke-color "white")
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.ui.workspace.viewport.pixel-overlay
|
(ns app.main.ui.workspace.viewport.pixel-overlay
|
||||||
(:require
|
(:require
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.colors :as dwc]
|
[app.main.data.workspace.colors :as dwc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue