mirror of
https://github.com/penpot/penpot.git
synced 2025-07-15 00:57:15 +02:00
✨ Fix linter issues on frontend (part 5).
This commit is contained in:
parent
e0846ce00e
commit
0f3e4c289c
51 changed files with 406 additions and 660 deletions
|
@ -6,12 +6,11 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.attrs
|
(ns app.main.ui.shapes.attrs
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.data :as d]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.main.ui.context :as muc]
|
[app.main.ui.context :as muc]
|
||||||
[app.util.svg :as usvg]))
|
[app.util.object :as obj]
|
||||||
|
[app.util.svg :as usvg]
|
||||||
|
[cuerdas.core :as str]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn- stroke-type->dasharray
|
(defn- stroke-type->dasharray
|
||||||
[style]
|
[style]
|
||||||
|
|
|
@ -6,17 +6,17 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.circle
|
(ns app.main.ui.shapes.circle
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[app.common.geom.shapes :as geom]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
||||||
[app.common.geom.shapes :as geom]
|
[app.util.object :as obj]
|
||||||
[app.util.object :as obj]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc circle-shape
|
(mf/defc circle-shape
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
{:keys [id x y width height]} shape
|
{:keys [x y width height]} shape
|
||||||
transform (geom/transform-matrix shape)
|
transform (geom/transform-matrix shape)
|
||||||
|
|
||||||
cx (+ x (/ width 2))
|
cx (+ x (/ width 2))
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
(ns app.main.ui.shapes.custom-stroke
|
(ns app.main.ui.shapes.custom-stroke
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.shapes :as geom]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.main.ui.context :as muc]
|
[app.main.ui.context :as muc]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
|
@ -26,7 +24,7 @@
|
||||||
(-> props (obj/merge #js {:style style}))))
|
(-> props (obj/merge #js {:style style}))))
|
||||||
|
|
||||||
(mf/defc inner-stroke-clip-path
|
(mf/defc inner-stroke-clip-path
|
||||||
[{:keys [shape render-id]}]
|
[{:keys [render-id]}]
|
||||||
(let [clip-id (str "inner-stroke-" render-id)
|
(let [clip-id (str "inner-stroke-" render-id)
|
||||||
shape-id (str "stroke-shape-" render-id)]
|
shape-id (str "stroke-shape-" render-id)]
|
||||||
[:> "clipPath" #js {:id clip-id}
|
[:> "clipPath" #js {:id clip-id}
|
||||||
|
@ -70,8 +68,6 @@
|
||||||
child (obj/get props "children")
|
child (obj/get props "children")
|
||||||
base-props (obj/get child "props")
|
base-props (obj/get child "props")
|
||||||
elem-name (obj/get child "type")
|
elem-name (obj/get child "type")
|
||||||
shape (obj/get props "shape")
|
|
||||||
stroke-width (:stroke-width shape 0)
|
|
||||||
stroke-mask-id (str "outer-stroke-" render-id)
|
stroke-mask-id (str "outer-stroke-" render-id)
|
||||||
shape-id (str "stroke-shape-" render-id)
|
shape-id (str "stroke-shape-" render-id)
|
||||||
|
|
||||||
|
@ -148,8 +144,8 @@
|
||||||
stroke-width (:stroke-width shape 0)
|
stroke-width (:stroke-width shape 0)
|
||||||
stroke-style (:stroke-style shape :none)
|
stroke-style (:stroke-style shape :none)
|
||||||
stroke-position (:stroke-alignment shape :center)
|
stroke-position (:stroke-alignment shape :center)
|
||||||
has-stroke? (and (and (> stroke-width 0)
|
has-stroke? (and (> stroke-width 0)
|
||||||
(not= stroke-style :none)))
|
(not= stroke-style :none))
|
||||||
inner? (= :inner stroke-position)
|
inner? (= :inner stroke-position)
|
||||||
outer? (= :outer stroke-position)]
|
outer? (= :outer stroke-position)]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
(ns app.main.ui.shapes.export
|
(ns app.main.ui.shapes.export
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.matrix :as gmt]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.util.json :as json]
|
[app.util.json :as json]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
@ -47,8 +46,7 @@
|
||||||
(cond-> props
|
(cond-> props
|
||||||
(some? val)
|
(some? val)
|
||||||
(obj/set! ns-attr (trfn val))))))]
|
(obj/set! ns-attr (trfn val))))))]
|
||||||
(let [frame? (= :frame (:type shape))
|
(let [group? (= :group (:type shape))
|
||||||
group? (= :group (:type shape))
|
|
||||||
rect? (= :rect (:type shape))
|
rect? (= :rect (:type shape))
|
||||||
text? (= :text (:type shape))
|
text? (= :text (:type shape))
|
||||||
mask? (and group? (:masked-group? shape))
|
mask? (and group? (:masked-group? shape))
|
||||||
|
@ -175,6 +173,6 @@
|
||||||
|
|
||||||
|
|
||||||
(when (and (= (:type shape) :frame)
|
(when (and (= (:type shape) :frame)
|
||||||
(not (empty? (:grids shape))))
|
(seq (:grids shape)))
|
||||||
[:& export-grid-data {:grids (:grids shape)}])]))
|
[:& export-grid-data {:grids (:grids shape)}])]))
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
:result filter-id}]]))
|
:result filter-id}]]))
|
||||||
|
|
||||||
(mf/defc background-blur-filter
|
(mf/defc background-blur-filter
|
||||||
[{:keys [filter-id filter-in params]}]
|
[{:keys [filter-id params]}]
|
||||||
[:*
|
[:*
|
||||||
[:feGaussianBlur {:in "BackgroundImage"
|
[:feGaussianBlur {:in "BackgroundImage"
|
||||||
:stdDeviation (/ (:value params) 2)}]
|
:stdDeviation (/ (:value params) 2)}]
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.frame
|
(ns app.main.ui.shapes.frame
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
@ -20,7 +19,7 @@
|
||||||
[props]
|
[props]
|
||||||
(let [childs (unchecked-get props "childs")
|
(let [childs (unchecked-get props "childs")
|
||||||
shape (unchecked-get props "shape")
|
shape (unchecked-get props "shape")
|
||||||
{:keys [id width height]} shape
|
{:keys [width height]} shape
|
||||||
|
|
||||||
props (-> (merge frame-default-props shape)
|
props (-> (merge frame-default-props shape)
|
||||||
(attrs/extract-style-attrs)
|
(attrs/extract-style-attrs)
|
||||||
|
@ -32,7 +31,7 @@
|
||||||
:className "frame-background"}))]
|
:className "frame-background"}))]
|
||||||
[:*
|
[:*
|
||||||
[:> :rect props]
|
[:> :rect props]
|
||||||
(for [[i item] (d/enumerate childs)]
|
(for [item childs]
|
||||||
[:& shape-wrapper {:frame shape
|
[:& shape-wrapper {:frame shape
|
||||||
:shape item
|
:shape item
|
||||||
:key (:id item)}])])))
|
:key (:id item)}])])))
|
||||||
|
|
|
@ -6,18 +6,15 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.gradients
|
(ns app.main.ui.shapes.gradients
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.main.ui.context :as muc]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.shapes :as gsh]))
|
[app.common.geom.point :as gpt]
|
||||||
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
|
[app.util.object :as obj]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc linear-gradient [{:keys [id gradient shape]}]
|
(mf/defc linear-gradient [{:keys [id gradient shape]}]
|
||||||
(let [{:keys [x y width height]} (:selrect shape)
|
(let [transform (when (= :path (:type shape)) (gsh/transform-matrix shape nil (gpt/point 0.5 0.5)))]
|
||||||
transform (when (= :path (:type shape)) (gsh/transform-matrix shape nil (gpt/point 0.5 0.5)))]
|
|
||||||
[:> :linearGradient #js {:id id
|
[:> :linearGradient #js {:id id
|
||||||
:x1 (:start-x gradient)
|
:x1 (:start-x gradient)
|
||||||
:y1 (:start-y gradient)
|
:y1 (:start-y gradient)
|
||||||
|
@ -43,49 +40,46 @@
|
||||||
|
|
||||||
(mf/defc radial-gradient [{:keys [id gradient shape]}]
|
(mf/defc radial-gradient [{:keys [id gradient shape]}]
|
||||||
(let [{:keys [x y width height]} (:selrect shape)
|
(let [{:keys [x y width height]} (:selrect shape)
|
||||||
center (gsh/center-shape shape)
|
|
||||||
transform (if (= :path (:type shape))
|
transform (if (= :path (:type shape))
|
||||||
(gsh/transform-matrix shape)
|
(gsh/transform-matrix shape)
|
||||||
(gmt/matrix))]
|
(gmt/matrix))
|
||||||
(let [[x y] (if (= (:type shape) :frame) [0 0] [x y])
|
[x y] (if (= (:type shape) :frame) [0 0] [x y])
|
||||||
translate-vec (gpt/point (+ x (* width (:start-x gradient)))
|
translate-vec (gpt/point (+ x (* width (:start-x gradient)))
|
||||||
(+ y (* height (:start-y gradient))))
|
(+ y (* height (:start-y gradient))))
|
||||||
|
|
||||||
gradient-vec (gpt/to-vec (gpt/point (* width (:start-x gradient))
|
gradient-vec (gpt/to-vec (gpt/point (* width (:start-x gradient))
|
||||||
(* height (:start-y gradient)))
|
(* height (:start-y gradient)))
|
||||||
(gpt/point (* width (:end-x gradient))
|
(gpt/point (* width (:end-x gradient))
|
||||||
(* height (:end-y gradient))))
|
(* height (:end-y gradient))))
|
||||||
|
|
||||||
angle (gpt/angle gradient-vec
|
angle (gpt/angle gradient-vec
|
||||||
(gpt/point 1 0))
|
(gpt/point 1 0))
|
||||||
|
|
||||||
shape-height-vec (gpt/point 0 (/ height 2))
|
scale-factor-y (/ (gpt/length gradient-vec) (/ height 2))
|
||||||
|
scale-factor-x (* scale-factor-y (:width gradient))
|
||||||
|
|
||||||
scale-factor-y (/ (gpt/length gradient-vec) (/ height 2))
|
scale-vec (gpt/point (* scale-factor-y (/ height 2))
|
||||||
scale-factor-x (* scale-factor-y (:width gradient))
|
(* scale-factor-x (/ width 2)))
|
||||||
|
|
||||||
scale-vec (gpt/point (* scale-factor-y (/ height 2))
|
transform (gmt/multiply transform
|
||||||
(* scale-factor-x (/ width 2)))
|
(gmt/translate-matrix translate-vec)
|
||||||
|
(gmt/rotate-matrix angle)
|
||||||
|
(gmt/scale-matrix scale-vec))
|
||||||
|
|
||||||
transform (gmt/multiply transform
|
base-props #js {:id id
|
||||||
(gmt/translate-matrix translate-vec)
|
:cx 0
|
||||||
(gmt/rotate-matrix angle)
|
:cy 0
|
||||||
(gmt/scale-matrix scale-vec))
|
:r 1
|
||||||
|
:gradientUnits "userSpaceOnUse"
|
||||||
|
:gradientTransform transform}
|
||||||
|
|
||||||
base-props #js {:id id
|
props (-> base-props (add-metadata gradient))]
|
||||||
:cx 0
|
[:> :radialGradient props
|
||||||
:cy 0
|
(for [{:keys [offset color opacity]} (:stops gradient)]
|
||||||
:r 1
|
[:stop {:key (str id "-stop-" offset)
|
||||||
:gradientUnits "userSpaceOnUse"
|
:offset (or offset 0)
|
||||||
:gradientTransform transform}
|
:stop-color color
|
||||||
|
:stop-opacity opacity}])]))
|
||||||
props (-> base-props (add-metadata gradient))]
|
|
||||||
[:> :radialGradient props
|
|
||||||
(for [{:keys [offset color opacity]} (:stops gradient)]
|
|
||||||
[:stop {:key (str id "-stop-" offset)
|
|
||||||
:offset (or offset 0)
|
|
||||||
:stop-color color
|
|
||||||
:stop-opacity opacity}])])))
|
|
||||||
|
|
||||||
(mf/defc gradient
|
(mf/defc gradient
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.group
|
(ns app.main.ui.shapes.group
|
||||||
(:require
|
(:require
|
||||||
|
[app.main.ui.shapes.mask :refer [mask-str clip-str mask-factory]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
|
||||||
[app.main.ui.shapes.mask :refer [mask-str clip-str mask-factory]]))
|
|
||||||
|
|
||||||
(defn group-shape
|
(defn group-shape
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
|
@ -20,9 +19,8 @@
|
||||||
(let [frame (unchecked-get props "frame")
|
(let [frame (unchecked-get props "frame")
|
||||||
shape (unchecked-get props "shape")
|
shape (unchecked-get props "shape")
|
||||||
childs (unchecked-get props "childs")
|
childs (unchecked-get props "childs")
|
||||||
pointer-events (unchecked-get props "pointer-events")
|
|
||||||
|
|
||||||
{:keys [id x y width height masked-group?]} shape
|
masked-group? (:masked-group? shape)
|
||||||
|
|
||||||
[mask childs] (if masked-group?
|
[mask childs] (if masked-group?
|
||||||
[(first childs) (rest childs)]
|
[(first childs) (rest childs)]
|
||||||
|
|
|
@ -7,39 +7,38 @@
|
||||||
(ns app.main.ui.shapes.image
|
(ns app.main.ui.shapes.image
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.shapes :as geom]
|
[app.common.geom.shapes :as geom]
|
||||||
|
[app.config :as cfg]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.embed :as se]
|
[app.main.ui.shapes.embed :as embed]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]))
|
||||||
[app.config :as cfg]
|
|
||||||
[app.main.ui.shapes.embed :as embed]))
|
|
||||||
|
|
||||||
(mf/defc image-shape
|
(mf/defc image-shape
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
|
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
{:keys [id x y width height rotation metadata]} shape
|
{:keys [x y width height metadata]} shape
|
||||||
uri (cfg/resolve-file-media metadata)
|
uri (cfg/resolve-file-media metadata)
|
||||||
embed (embed/use-data-uris [uri])]
|
embed (embed/use-data-uris [uri])
|
||||||
|
|
||||||
(let [transform (geom/transform-matrix shape)
|
transform (geom/transform-matrix shape)
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
(obj/merge!
|
(obj/merge!
|
||||||
#js {:x x
|
#js {:x x
|
||||||
:y y
|
:y y
|
||||||
:transform transform
|
:transform transform
|
||||||
:width width
|
:width width
|
||||||
:height height
|
:height height
|
||||||
:preserveAspectRatio "none"
|
:preserveAspectRatio "none"
|
||||||
:data-loading (str (not (contains? embed uri)))}))
|
:data-loading (str (not (contains? embed uri)))}))
|
||||||
|
|
||||||
on-drag-start (fn [event]
|
on-drag-start (fn [event]
|
||||||
;; Prevent browser dragging of the image
|
;; Prevent browser dragging of the image
|
||||||
(dom/prevent-default event))]
|
(dom/prevent-default event))]
|
||||||
|
|
||||||
[:> "image" (obj/merge!
|
[:> "image" (obj/merge!
|
||||||
props
|
props
|
||||||
#js {:xlinkHref (get embed uri uri)
|
#js {:xlinkHref (get embed uri uri)
|
||||||
:onDragStart on-drag-start})])))
|
:onDragStart on-drag-start})]))
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.mask
|
(ns app.main.ui.shapes.mask
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[app.common.geom.shapes :as gsh]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[app.common.geom.shapes :as gsh]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn mask-str [mask]
|
(defn mask-str [mask]
|
||||||
(str/fmt "url(#%s)" (str (:id mask) "-mask")))
|
(str/fmt "url(#%s)" (str (:id mask) "-mask")))
|
||||||
|
|
|
@ -6,26 +6,23 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.path
|
(ns app.main.ui.shapes.path
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.path.format :as upf]))
|
[app.util.path.format :as upf]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; --- Path Shape
|
;; --- Path Shape
|
||||||
|
|
||||||
(mf/defc path-shape
|
(mf/defc path-shape
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
background? (unchecked-get props "background?")
|
|
||||||
{:keys [id x y width height]} (:selrect shape)
|
|
||||||
content (:content shape)
|
content (:content shape)
|
||||||
pdata (mf/use-memo (mf/deps content) #(upf/format-path content))
|
pdata (mf/use-memo (mf/deps content) #(upf/format-path content))
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
(obj/merge!
|
(obj/merge!
|
||||||
#js {:d pdata}))]
|
#js {:d pdata}))]
|
||||||
[:& shape-custom-stroke {:shape shape}
|
[:& shape-custom-stroke {:shape shape}
|
||||||
[:> :path props]]))
|
[:> :path props]]))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
||||||
[app.main.ui.shapes.gradients :refer [gradient]]
|
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
{:keys [id x y width height]} shape
|
{:keys [x y width height]} shape
|
||||||
transform (gsh/transform-matrix shape)
|
transform (gsh/transform-matrix shape)
|
||||||
|
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
|
|
|
@ -100,7 +100,8 @@
|
||||||
(cond->> id
|
(cond->> id
|
||||||
(contains? svg-defs id) (str render-id "-")))]
|
(contains? svg-defs id) (str render-id "-")))]
|
||||||
|
|
||||||
(when (and svg-defs (not (empty? svg-defs)))
|
;; TODO: no key?
|
||||||
|
(when (seq svg-defs)
|
||||||
(for [svg-def (vals svg-defs)]
|
(for [svg-def (vals svg-defs)]
|
||||||
[:& svg-node {:node svg-def
|
[:& svg-node {:node svg-def
|
||||||
:prefix-id prefix-id
|
:prefix-id prefix-id
|
||||||
|
|
|
@ -6,15 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.svg-raw
|
(ns app.main.ui.shapes.svg-raw
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as cd]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.ui.shapes.attrs :as usa]
|
[app.main.ui.shapes.attrs :as usa]
|
||||||
[app.util.data :as ud]
|
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.svg :as usvg]
|
[app.util.svg :as usvg]
|
||||||
[cuerdas.core :as str]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; Graphic tags
|
;; Graphic tags
|
||||||
|
@ -53,7 +48,7 @@
|
||||||
children (unchecked-get props "children")
|
children (unchecked-get props "children")
|
||||||
|
|
||||||
{:keys [x y width height]} shape
|
{:keys [x y width height]} shape
|
||||||
{:keys [tag attrs] :as content} (:content shape)
|
{:keys [attrs] :as content} (:content shape)
|
||||||
|
|
||||||
ids-mapping (mf/use-memo #(usvg/generate-id-mapping content))
|
ids-mapping (mf/use-memo #(usvg/generate-id-mapping content))
|
||||||
|
|
||||||
|
@ -85,9 +80,7 @@
|
||||||
element-id (get-in content [:attrs :id])
|
element-id (get-in content [:attrs :id])
|
||||||
attrs (cond-> (set-styles attrs shape)
|
attrs (cond-> (set-styles attrs shape)
|
||||||
(and element-id (contains? ids-mapping element-id))
|
(and element-id (contains? ids-mapping element-id))
|
||||||
(obj/set! "id" (get ids-mapping element-id)))
|
(obj/set! "id" (get ids-mapping element-id)))]
|
||||||
|
|
||||||
{:keys [x y width height]} (:selrect shape)]
|
|
||||||
[:> (name tag) attrs children]))
|
[:> (name tag) attrs children]))
|
||||||
|
|
||||||
(defn svg-raw-shape [shape-wrapper]
|
(defn svg-raw-shape [shape-wrapper]
|
||||||
|
|
|
@ -8,12 +8,9 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.shapes :as geom]
|
[app.common.geom.shapes :as geom]
|
||||||
[app.main.ui.context :as muc]
|
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.text.styles :as sts]
|
[app.main.ui.shapes.text.styles :as sts]
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[cuerdas.core :as str]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc render-text
|
(mf/defc render-text
|
||||||
|
@ -40,8 +37,7 @@
|
||||||
(mf/defc render-paragraph-set
|
(mf/defc render-paragraph-set
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [node (obj/get props "node")
|
(let [children (obj/get props "children")
|
||||||
children (obj/get props "children")
|
|
||||||
shape (obj/get props "shape")
|
shape (obj/get props "shape")
|
||||||
style (sts/generate-paragraph-set-styles shape)]
|
style (sts/generate-paragraph-set-styles shape)]
|
||||||
[:div.paragraph-set {:style style} children]))
|
[:div.paragraph-set {:style style} children]))
|
||||||
|
|
|
@ -75,5 +75,5 @@
|
||||||
;; Creates a style tag by replacing the urls with the data uri
|
;; Creates a style tag by replacing the urls with the data uri
|
||||||
style (replace-embeds fonts-css fonts-urls fonts-embed)]
|
style (replace-embeds fonts-css fonts-urls fonts-embed)]
|
||||||
|
|
||||||
(when (and (some? style) (not (empty? style)))
|
(when (seq style)
|
||||||
[:style style])))
|
[:style style])))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
(defn generate-root-styles
|
(defn generate-root-styles
|
||||||
[shape node]
|
[shape node]
|
||||||
(let [valign (or (:vertical-align node "top"))
|
(let [valign (:vertical-align node "top")
|
||||||
base #js {:height (or (:height shape) "100%")
|
base #js {:height (or (:height shape) "100%")
|
||||||
:width (or (:width shape) "100%")}]
|
:width (or (:width shape) "100%")}]
|
||||||
(cond-> base
|
(cond-> base
|
||||||
|
@ -104,18 +104,18 @@
|
||||||
(when (and (string? font-id)
|
(when (and (string? font-id)
|
||||||
(pos? (alength font-id)))
|
(pos? (alength font-id)))
|
||||||
(fonts/ensure-loaded! font-id)
|
(fonts/ensure-loaded! font-id)
|
||||||
(let [font (get fontsdb font-id)]
|
(let [font (get fontsdb font-id)
|
||||||
(let [font-family (str/quote
|
font-family (str/quote
|
||||||
(or (:family font)
|
(or (:family font)
|
||||||
(:font-family data)))
|
(:font-family data)))
|
||||||
font-variant (d/seek #(= font-variant-id (:id %))
|
font-variant (d/seek #(= font-variant-id (:id %))
|
||||||
(:variants font))
|
(:variants font))
|
||||||
font-style (or (:style font-variant)
|
font-style (or (:style font-variant)
|
||||||
(:font-style data))
|
(:font-style data))
|
||||||
font-weight (or (:weight font-variant)
|
font-weight (or (:weight font-variant)
|
||||||
(:font-weight data))]
|
(:font-weight data))]
|
||||||
(obj/set! base "fontFamily" font-family)
|
(obj/set! base "fontFamily" font-family)
|
||||||
(obj/set! base "fontStyle" font-style)
|
(obj/set! base "fontStyle" font-style)
|
||||||
(obj/set! base "fontWeight" font-weight))))
|
(obj/set! base "fontWeight" font-weight)))
|
||||||
|
|
||||||
base))
|
base))
|
||||||
|
|
|
@ -10,12 +10,9 @@
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.context :as ctx]
|
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[cljs.spec.alpha :as s]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn- go-to-dashboard
|
(defn- go-to-dashboard
|
||||||
|
@ -24,7 +21,7 @@
|
||||||
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
|
(st/emit! (rt/nav :dashboard-projects {:team-id team-id}))))
|
||||||
|
|
||||||
(mf/defc not-found
|
(mf/defc not-found
|
||||||
[{:keys [error] :as props}]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
(let [profile (mf/deref refs/profile)]
|
||||||
[:section.exception-layout
|
[:section.exception-layout
|
||||||
[:div.exception-header
|
[:div.exception-header
|
||||||
|
@ -42,7 +39,7 @@
|
||||||
(tr "labels.sign-out")]]]]]))
|
(tr "labels.sign-out")]]]]]))
|
||||||
|
|
||||||
(mf/defc bad-gateway
|
(mf/defc bad-gateway
|
||||||
[{:keys [error] :as props}]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
(let [profile (mf/deref refs/profile)]
|
||||||
[:section.exception-layout
|
[:section.exception-layout
|
||||||
[:div.exception-header
|
[:div.exception-header
|
||||||
|
@ -59,7 +56,7 @@
|
||||||
(tr "labels.retry")]]]]]))
|
(tr "labels.retry")]]]]]))
|
||||||
|
|
||||||
(mf/defc service-unavailable
|
(mf/defc service-unavailable
|
||||||
[{:keys [error] :as props}]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
(let [profile (mf/deref refs/profile)]
|
||||||
[:section.exception-layout
|
[:section.exception-layout
|
||||||
[:div.exception-header
|
[:div.exception-header
|
||||||
|
@ -76,7 +73,7 @@
|
||||||
(tr "labels.retry")]]]]]))
|
(tr "labels.retry")]]]]]))
|
||||||
|
|
||||||
(mf/defc internal-error
|
(mf/defc internal-error
|
||||||
[props]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)]
|
(let [profile (mf/deref refs/profile)]
|
||||||
[:section.exception-layout
|
[:section.exception-layout
|
||||||
[:div.exception-header
|
[:div.exception-header
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
(ns app.main.ui.viewer
|
(ns app.main.ui.viewer
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as geom]
|
[app.common.geom.shapes :as geom]
|
||||||
|
@ -19,9 +18,8 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.comments :as cmt]
|
[app.main.ui.comments :as cmt]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.main.ui.viewer.header :refer [header]]
|
[app.main.ui.viewer.header :refer [header]]
|
||||||
[app.main.ui.viewer.shapes :as shapes :refer [frame-svg]]
|
[app.main.ui.viewer.shapes :as shapes]
|
||||||
[app.main.ui.viewer.thumbnails :refer [thumbnails-panel]]
|
[app.main.ui.viewer.thumbnails :refer [thumbnails-panel]]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
[app.util.i18n :as i18n :refer [t tr]]
|
||||||
|
@ -44,7 +42,7 @@
|
||||||
(l/derived :comments-local st/state))
|
(l/derived :comments-local st/state))
|
||||||
|
|
||||||
(mf/defc comments-layer
|
(mf/defc comments-layer
|
||||||
[{:keys [width height zoom frame data] :as props}]
|
[{:keys [zoom frame data] :as props}]
|
||||||
(let [profile (mf/deref refs/profile)
|
(let [profile (mf/deref refs/profile)
|
||||||
|
|
||||||
modifier1 (-> (gpt/point (:x frame) (:y frame))
|
modifier1 (-> (gpt/point (:x frame) (:y frame))
|
||||||
|
@ -62,7 +60,7 @@
|
||||||
mframe (geom/transform-shape frame)
|
mframe (geom/transform-shape frame)
|
||||||
threads (->> (vals threads-map)
|
threads (->> (vals threads-map)
|
||||||
(dcm/apply-filters cstate profile)
|
(dcm/apply-filters cstate profile)
|
||||||
(filter (fn [{:keys [seqn position]}]
|
(filter (fn [{:keys [position]}]
|
||||||
(frame-contains? mframe position))))
|
(frame-contains? mframe position))))
|
||||||
|
|
||||||
on-bubble-click
|
on-bubble-click
|
||||||
|
@ -127,7 +125,7 @@
|
||||||
|
|
||||||
(mf/defc viewport
|
(mf/defc viewport
|
||||||
{::mf/wrap [mf/memo]}
|
{::mf/wrap [mf/memo]}
|
||||||
[{:keys [state data index section] :or {zoom 1} :as props}]
|
[{:keys [state data index section] :as props}]
|
||||||
(let [zoom (:zoom state)
|
(let [zoom (:zoom state)
|
||||||
objects (:objects data)
|
objects (:objects data)
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
[app.common.geom.shapes :as geom]
|
[app.common.geom.shapes :as geom]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.main.data.viewer :as dv]
|
[app.main.data.viewer :as dv]
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.shapes.circle :as circle]
|
[app.main.ui.shapes.circle :as circle]
|
||||||
[app.main.ui.shapes.filters :as filters]
|
|
||||||
[app.main.ui.shapes.frame :as frame]
|
[app.main.ui.shapes.frame :as frame]
|
||||||
[app.main.ui.shapes.group :as group]
|
[app.main.ui.shapes.group :as group]
|
||||||
[app.main.ui.shapes.image :as image]
|
[app.main.ui.shapes.image :as image]
|
||||||
|
@ -62,13 +60,10 @@
|
||||||
(mf/fnc generic-wrapper
|
(mf/fnc generic-wrapper
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
objects (unchecked-get props "objects")
|
objects (unchecked-get props "objects")
|
||||||
{:keys [x y width height]} (:selrect shape)
|
childs (unchecked-get props "childs")
|
||||||
frame? (= :frame (:type shape))
|
frame (unchecked-get props "frame")
|
||||||
|
|
||||||
childs (unchecked-get props "childs")
|
|
||||||
frame (unchecked-get props "frame")
|
|
||||||
|
|
||||||
interactions (->> (:interactions shape)
|
interactions (->> (:interactions shape)
|
||||||
(filter #(contains? objects (:destination %))))
|
(filter #(contains? objects (:destination %))))
|
||||||
|
|
|
@ -6,25 +6,16 @@
|
||||||
|
|
||||||
(ns app.main.ui.viewer.thumbnails
|
(ns app.main.ui.viewer.thumbnails
|
||||||
(:require
|
(:require
|
||||||
[goog.events :as events]
|
|
||||||
[goog.object :as gobj]
|
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.data.viewer :as dv]
|
[app.main.data.viewer :as dv]
|
||||||
[app.main.ui.components.dropdown :refer [dropdown']]
|
|
||||||
[app.main.ui.shapes.frame :as frame]
|
|
||||||
[app.main.exports :as exports]
|
[app.main.exports :as exports]
|
||||||
|
[app.main.store :as st]
|
||||||
|
[app.main.ui.components.dropdown :refer [dropdown']]
|
||||||
|
[app.main.ui.icons :as i]
|
||||||
[app.util.data :refer [classnames]]
|
[app.util.data :refer [classnames]]
|
||||||
[app.util.dom :as dom]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.common.geom.matrix :as gmt]
|
[goog.object :as gobj]
|
||||||
[app.common.geom.point :as gpt]
|
[rumext.alpha :as mf]))
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.util.router :as rt]
|
|
||||||
[app.main.data.viewer :as vd])
|
|
||||||
(:import goog.events.EventType))
|
|
||||||
|
|
||||||
(mf/defc thumbnails-content
|
(mf/defc thumbnails-content
|
||||||
[{:keys [children expanded? total] :as props}]
|
[{:keys [children expanded? total] :as props}]
|
||||||
|
@ -35,14 +26,14 @@
|
||||||
offset (mf/use-state 0)
|
offset (mf/use-state 0)
|
||||||
|
|
||||||
on-left-arrow-click
|
on-left-arrow-click
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! offset (fn [v]
|
(swap! offset (fn [v]
|
||||||
(if (pos? v)
|
(if (pos? v)
|
||||||
(dec v)
|
(dec v)
|
||||||
v))))
|
v))))
|
||||||
|
|
||||||
on-right-arrow-click
|
on-right-arrow-click
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(let [visible (/ @width @element-width)
|
(let [visible (/ @width @element-width)
|
||||||
max-val (- total visible)]
|
max-val (- total visible)]
|
||||||
(swap! offset (fn [v]
|
(swap! offset (fn [v]
|
||||||
|
@ -90,26 +81,25 @@
|
||||||
[:span.name {:title (:name frame)} (:name frame)]]])
|
[:span.name {:title (:name frame)} (:name frame)]]])
|
||||||
|
|
||||||
(mf/defc thumbnails-panel
|
(mf/defc thumbnails-panel
|
||||||
[{:keys [data index screen] :as props}]
|
[{:keys [data index] :as props}]
|
||||||
(let [expanded? (mf/use-state false)
|
(let [expanded? (mf/use-state false)
|
||||||
container (mf/use-ref)
|
container (mf/use-ref)
|
||||||
page-id (get-in data [:page :id])
|
|
||||||
file-id (get-in data [:file :id])
|
|
||||||
|
|
||||||
on-close #(st/emit! dv/toggle-thumbnails-panel)
|
on-close #(st/emit! dv/toggle-thumbnails-panel)
|
||||||
selected (mf/use-var false)
|
selected (mf/use-var false)
|
||||||
|
|
||||||
on-mouse-leave
|
on-mouse-leave
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(when @selected
|
(when @selected
|
||||||
(on-close)))
|
(on-close)))
|
||||||
|
|
||||||
on-item-click
|
on-item-click
|
||||||
(fn [event index]
|
(fn [_ index]
|
||||||
(compare-and-set! selected false true)
|
(compare-and-set! selected false true)
|
||||||
(st/emit! (dv/go-to-frame-by-index index))
|
(st/emit! (dv/go-to-frame-by-index index))
|
||||||
(when @expanded?
|
(when @expanded?
|
||||||
(on-close)))]
|
(on-close)))]
|
||||||
|
|
||||||
[:& dropdown' {:on-close on-close
|
[:& dropdown' {:on-close on-close
|
||||||
:container container
|
:container container
|
||||||
:show true}
|
:show true}
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
(when page-id
|
(when page-id
|
||||||
(st/emit! (dw/finalize-page page-id))))))
|
(st/emit! (dw/finalize-page page-id))))))
|
||||||
|
|
||||||
(when-let [page (mf/deref trimmed-page-ref)]
|
(when (mf/deref trimmed-page-ref)
|
||||||
[:& workspace-content {:key page-id
|
[:& workspace-content {:key page-id
|
||||||
:file file
|
:file file
|
||||||
:layout layout}]))
|
:layout layout}]))
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
(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.workspace :as udw]
|
|
||||||
[app.main.data.workspace.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.color-bullet :as cb]
|
[app.main.ui.components.color-bullet :as cb]
|
||||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||||
[app.main.ui.context :as ctx]
|
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
|
@ -39,14 +37,9 @@
|
||||||
(-> (l/in [:workspace-local :selected-palette-size])
|
(-> (l/in [:workspace-local :selected-palette-size])
|
||||||
(l/derived st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defn- make-selected-palette-item-ref
|
|
||||||
[lib-id]
|
|
||||||
(-> (l/in [:library-items :palettes lib-id])
|
|
||||||
(l/derived st/state)))
|
|
||||||
|
|
||||||
;; --- Components
|
;; --- Components
|
||||||
(mf/defc palette-item
|
(mf/defc palette-item
|
||||||
[{:keys [color size local?]}]
|
[{:keys [color size]}]
|
||||||
(let [select-color
|
(let [select-color
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [ids (wsh/lookup-selected @st/state)]
|
(let [ids (wsh/lookup-selected @st/state)]
|
||||||
|
@ -70,13 +63,12 @@
|
||||||
max-offset (- (count current-colors)
|
max-offset (- (count current-colors)
|
||||||
visible)
|
visible)
|
||||||
|
|
||||||
close-fn #(st/emit! (udw/toggle-layout-flags :colorpalette))
|
|
||||||
container (mf/use-ref nil)
|
container (mf/use-ref nil)
|
||||||
|
|
||||||
on-left-arrow-click
|
on-left-arrow-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps max-offset visible)
|
(mf/deps max-offset visible)
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! state update :offset
|
(swap! state update :offset
|
||||||
(fn [offset]
|
(fn [offset]
|
||||||
(if (pos? offset)
|
(if (pos? offset)
|
||||||
|
@ -86,7 +78,7 @@
|
||||||
on-right-arrow-click
|
on-right-arrow-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps max-offset visible)
|
(mf/deps max-offset visible)
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! state update :offset
|
(swap! state update :offset
|
||||||
(fn [offset]
|
(fn [offset]
|
||||||
(if (< offset max-offset)
|
(if (< offset max-offset)
|
||||||
|
@ -104,7 +96,7 @@
|
||||||
|
|
||||||
on-resize
|
on-resize
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(let [dom (mf/ref-val container)
|
(let [dom (mf/ref-val container)
|
||||||
width (obj/get dom "clientWidth")]
|
width (obj/get dom "clientWidth")]
|
||||||
(swap! state assoc :width width))))]
|
(swap! state assoc :width width))))]
|
||||||
|
@ -132,7 +124,7 @@
|
||||||
(when (= selected (:id cur-library)) i/tick)
|
(when (= selected (:id cur-library)) i/tick)
|
||||||
[:div.library-name (str (:name cur-library) " " (str/format "(%s)" (count colors)))]
|
[:div.library-name (str (:name cur-library) " " (str/format "(%s)" (count colors)))]
|
||||||
[:div.color-sample
|
[:div.color-sample
|
||||||
(for [[idx {:keys [id color]}] (map-indexed vector (take 7 colors))]
|
(for [[idx {:keys [color]}] (map-indexed vector (take 7 colors))]
|
||||||
[:& cb/color-bullet {:key (str "color-" idx)
|
[:& cb/color-bullet {:key (str "color-" idx)
|
||||||
:color color}])]]))
|
:color color}])]]))
|
||||||
|
|
||||||
|
@ -193,8 +185,7 @@
|
||||||
|
|
||||||
(mf/defc colorpalette
|
(mf/defc colorpalette
|
||||||
[]
|
[]
|
||||||
(let [team-id (mf/use-ctx ctx/current-team-id)
|
(let [recent-colors (mf/deref refs/workspace-recent-colors)
|
||||||
recent-colors (mf/deref refs/workspace-recent-colors)
|
|
||||||
file-colors (mf/deref refs/workspace-file-colors)
|
file-colors (mf/deref refs/workspace-file-colors)
|
||||||
shared-libs (mf/deref refs/workspace-libraries)
|
shared-libs (mf/deref refs/workspace-libraries)
|
||||||
selected (or (mf/deref selected-palette-ref) :recent)
|
selected (or (mf/deref selected-palette-ref) :recent)
|
||||||
|
|
|
@ -6,28 +6,24 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker
|
(ns app.main.ui.workspace.colorpicker
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.workspace.colors :as dc]
|
||||||
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
|
[app.main.refs :as refs]
|
||||||
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
[app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]]
|
||||||
[app.main.ui.workspace.colorpicker.gradients :refer [gradients]]
|
[app.main.ui.workspace.colorpicker.gradients :refer [gradients]]
|
||||||
[app.main.ui.workspace.colorpicker.harmony :refer [harmony-selector]]
|
[app.main.ui.workspace.colorpicker.harmony :refer [harmony-selector]]
|
||||||
[app.main.ui.workspace.colorpicker.hsva :refer [hsva-selector]]
|
[app.main.ui.workspace.colorpicker.hsva :refer [hsva-selector]]
|
||||||
|
[app.main.ui.workspace.colorpicker.libraries :refer [libraries]]
|
||||||
[app.main.ui.workspace.colorpicker.ramp :refer [ramp-selector]]
|
[app.main.ui.workspace.colorpicker.ramp :refer [ramp-selector]]
|
||||||
[app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]]
|
[app.util.color :as uc]
|
||||||
[app.main.ui.workspace.colorpicker.libraries :refer [libraries]]))
|
[app.util.dom :as dom]
|
||||||
|
[app.util.i18n :as i18n :refer [t]]
|
||||||
|
[cuerdas.core :as str]
|
||||||
|
[okulary.core :as l]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
|
@ -127,7 +123,6 @@
|
||||||
picking-color? (mf/deref picking-color?)
|
picking-color? (mf/deref picking-color?)
|
||||||
picked-color (mf/deref picked-color)
|
picked-color (mf/deref picked-color)
|
||||||
picked-color-select (mf/deref picked-color-select)
|
picked-color-select (mf/deref picked-color-select)
|
||||||
picked-shift? (mf/deref picked-shift?)
|
|
||||||
|
|
||||||
editing-spot-state (mf/deref editing-spot-state-ref)
|
editing-spot-state (mf/deref editing-spot-state-ref)
|
||||||
current-gradient (mf/deref current-gradient-ref)
|
current-gradient (mf/deref current-gradient-ref)
|
||||||
|
@ -156,11 +151,11 @@
|
||||||
handle-change-stop
|
handle-change-stop
|
||||||
(fn [offset]
|
(fn [offset]
|
||||||
(when-let [offset-color (get-in @state [:stops offset])]
|
(when-let [offset-color (get-in @state [:stops offset])]
|
||||||
(do (swap! state assoc
|
(swap! state assoc
|
||||||
:current-color offset-color
|
:current-color offset-color
|
||||||
:editing-stop offset)
|
:editing-stop offset)
|
||||||
|
|
||||||
(st/emit! (dc/select-gradient-stop offset)))))
|
(st/emit! (dc/select-gradient-stop offset))))
|
||||||
|
|
||||||
on-select-library-color
|
on-select-library-color
|
||||||
(fn [color]
|
(fn [color]
|
||||||
|
@ -172,7 +167,7 @@
|
||||||
(on-change color)))))
|
(on-change color)))))
|
||||||
|
|
||||||
on-add-library-color
|
on-add-library-color
|
||||||
(fn [color]
|
(fn [_]
|
||||||
(st/emit! (dwl/add-color (state->data @state))))
|
(st/emit! (dwl/add-color (state->data @state))))
|
||||||
|
|
||||||
on-activate-gradient
|
on-activate-gradient
|
||||||
|
@ -197,7 +192,7 @@
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps current-color)
|
(mf/deps current-color)
|
||||||
(fn [] (let [node (mf/ref-val ref-picker)
|
(fn [] (let [node (mf/ref-val ref-picker)
|
||||||
{:keys [r g b h s v]} current-color
|
{:keys [r g b h v]} current-color
|
||||||
rgb [r g b]
|
rgb [r g b]
|
||||||
hue-rgb (uc/hsv->rgb [h 1.0 255])
|
hue-rgb (uc/hsv->rgb [h 1.0 255])
|
||||||
hsl-from (uc/hsv->hsl [h 0.0 v])
|
hsl-from (uc/hsv->hsl [h 0.0 v])
|
||||||
|
@ -248,9 +243,8 @@
|
||||||
:end-x :end-y
|
:end-x :end-y
|
||||||
:width])]
|
:width])]
|
||||||
(when (not= (:gradient-data @state) gradient-data)
|
(when (not= (:gradient-data @state) gradient-data)
|
||||||
(do
|
(reset! dirty? true)
|
||||||
(reset! dirty? true)
|
(swap! state assoc :gradient-data gradient-data))))))
|
||||||
(swap! state assoc :gradient-data gradient-data)))))))
|
|
||||||
|
|
||||||
;; Check if we've opened a color with gradient
|
;; Check if we've opened a color with gradient
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
|
@ -265,7 +259,7 @@
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps @state)
|
(mf/deps @state)
|
||||||
(fn []
|
(fn []
|
||||||
(if @dirty?
|
(when @dirty?
|
||||||
(let [color (state->data @state)]
|
(let [color (state->data @state)]
|
||||||
(reset! dirty? false)
|
(reset! dirty? false)
|
||||||
(reset! last-color color)
|
(reset! last-color color)
|
||||||
|
@ -357,7 +351,7 @@
|
||||||
(mf/defc colorpicker-modal
|
(mf/defc colorpicker-modal
|
||||||
{::mf/register modal/components
|
{::mf/register modal/components
|
||||||
::mf/register-as :colorpicker}
|
::mf/register-as :colorpicker}
|
||||||
[{:keys [x y default data page position
|
[{:keys [x y data position
|
||||||
disable-gradient
|
disable-gradient
|
||||||
disable-opacity
|
disable-opacity
|
||||||
on-change on-close on-accept] :as props}]
|
on-change on-close on-accept] :as props}]
|
||||||
|
@ -367,7 +361,7 @@
|
||||||
position (or position :left)
|
position (or position :left)
|
||||||
style (calculate-position vport position x y)
|
style (calculate-position vport position x y)
|
||||||
|
|
||||||
handle-change (fn [new-data shift-clicked?]
|
handle-change (fn [new-data _shift-clicked?]
|
||||||
(reset! dirty? (not= data new-data))
|
(reset! dirty? (not= data new-data))
|
||||||
(reset! last-change new-data)
|
(reset! last-change new-data)
|
||||||
(when on-change
|
(when on-change
|
||||||
|
|
|
@ -6,22 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.color-inputs
|
(ns app.main.ui.workspace.colorpicker.color-inputs
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
[app.common.math :as math]
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[app.util.object :as obj]
|
[app.util.dom :as dom]
|
||||||
[app.main.store :as st]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
|
||||||
|
|
||||||
(mf/defc color-inputs [{:keys [type color disable-opacity on-change]}]
|
(mf/defc color-inputs [{:keys [type color disable-opacity on-change]}]
|
||||||
(let [{red :r green :g blue :b
|
(let [{red :r green :g blue :b
|
||||||
|
|
|
@ -6,22 +6,8 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.gradients
|
(ns app.main.ui.workspace.colorpicker.gradients
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[app.common.geom.point :as gpt]
|
[rumext.alpha :as mf]))
|
||||||
[app.common.math :as math]
|
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
|
||||||
|
|
||||||
(defn gradient->string [stops]
|
(defn gradient->string [stops]
|
||||||
(let [format-stop
|
(let [format-stop
|
||||||
|
|
|
@ -6,24 +6,14 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.harmony
|
(ns app.main.ui.workspace.colorpicker.harmony
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.math :as math]
|
[app.common.math :as math]
|
||||||
[app.common.uuid :refer [uuid]]
|
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
|
[app.util.dom :as dom]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.main.store :as st]
|
[cuerdas.core :as str]
|
||||||
[app.main.refs :as refs]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
|
||||||
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]))
|
|
||||||
|
|
||||||
|
|
||||||
(defn create-color-wheel
|
(defn create-color-wheel
|
||||||
[canvas-node]
|
[canvas-node]
|
||||||
|
@ -100,7 +90,7 @@
|
||||||
(on-change {:hex hex
|
(on-change {:hex hex
|
||||||
:r r :g g :b b
|
:r r :g g :b b
|
||||||
:v new-value})))
|
:v new-value})))
|
||||||
on-complement-click (fn [ev]
|
on-complement-click (fn [_]
|
||||||
(let [new-hue (mod (+ hue 180) 360)
|
(let [new-hue (mod (+ hue 180) 360)
|
||||||
hex (uc/hsv->hex [new-hue saturation value])
|
hex (uc/hsv->hex [new-hue saturation value])
|
||||||
[r g b] (uc/hex->rgb hex)]
|
[r g b] (uc/hex->rgb hex)]
|
||||||
|
|
|
@ -6,23 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.hsva
|
(ns app.main.ui.workspace.colorpicker.hsva
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[app.util.object :as obj]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
|
||||||
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]))
|
|
||||||
|
|
||||||
(mf/defc hsva-selector [{:keys [color disable-opacity on-change]}]
|
(mf/defc hsva-selector [{:keys [color disable-opacity on-change]}]
|
||||||
(let [{hue :h saturation :s value :v alpha :alpha} color
|
(let [{hue :h saturation :s value :v alpha :alpha} color
|
||||||
|
|
|
@ -6,42 +6,29 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.libraries
|
(ns app.main.ui.workspace.colorpicker.libraries
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
|
||||||
[app.common.uuid :refer [uuid]]
|
[app.common.uuid :refer [uuid]]
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.refs :as refs]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.store :as st]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
|
||||||
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
||||||
[app.main.ui.workspace.colorpicker.gradients :refer [gradients]]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.workspace.colorpicker.harmony :refer [harmony-selector]]
|
[app.util.dom :as dom]
|
||||||
[app.main.ui.workspace.colorpicker.hsva :refer [hsva-selector]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.main.ui.workspace.colorpicker.ramp :refer [ramp-selector]]
|
[okulary.core :as l]
|
||||||
[app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def selected-palette-ref
|
(def selected-palette-ref
|
||||||
(-> (l/in [:workspace-local :selected-palette-colorpicker])
|
(-> (l/in [:workspace-local :selected-palette-colorpicker])
|
||||||
(l/derived st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(mf/defc libraries [{:keys [current-color on-select-color on-add-library-color
|
(mf/defc libraries
|
||||||
disable-gradient disable-opacity]}]
|
[{:keys [on-select-color on-add-library-color disable-gradient disable-opacity]}]
|
||||||
(let [selected-library (or (mf/deref selected-palette-ref) :recent)
|
(let [selected-library (or (mf/deref selected-palette-ref) :recent)
|
||||||
current-library-colors (mf/use-state [])
|
current-library-colors (mf/use-state [])
|
||||||
|
|
||||||
shared-libs (mf/deref refs/workspace-libraries)
|
shared-libs (mf/deref refs/workspace-libraries)
|
||||||
file-colors (mf/deref refs/workspace-file-colors)
|
file-colors (mf/deref refs/workspace-file-colors)
|
||||||
recent-colors (mf/deref refs/workspace-recent-colors)
|
recent-colors (mf/deref refs/workspace-recent-colors)
|
||||||
locale (mf/deref i18n/locale)
|
|
||||||
|
|
||||||
parse-selected
|
parse-selected
|
||||||
(fn [selected-str]
|
(fn [selected-str]
|
||||||
|
@ -85,8 +72,8 @@
|
||||||
(when-let [val (parse-selected (dom/get-target-val e))]
|
(when-let [val (parse-selected (dom/get-target-val e))]
|
||||||
(st/emit! (dc/change-palette-selected-colorpicker val))))
|
(st/emit! (dc/change-palette-selected-colorpicker val))))
|
||||||
:value (name selected-library)}
|
:value (name selected-library)}
|
||||||
[:option {:value "recent"} (t locale "workspace.libraries.colors.recent-colors")]
|
[:option {:value "recent"} (tr "workspace.libraries.colors.recent-colors")]
|
||||||
[:option {:value "file"} (t locale "workspace.libraries.colors.file-library")]
|
[:option {:value "file"} (tr "workspace.libraries.colors.file-library")]
|
||||||
|
|
||||||
(for [[_ {:keys [name id]}] shared-libs]
|
(for [[_ {:keys [name id]}] shared-libs]
|
||||||
[:option {:key id
|
[:option {:key id
|
||||||
|
|
|
@ -6,26 +6,14 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.ramp
|
(ns app.main.ui.workspace.colorpicker.ramp
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
[app.common.math :as math]
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
|
||||||
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
||||||
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]))
|
[app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]]
|
||||||
|
[app.util.color :as uc]
|
||||||
|
[app.util.dom :as dom]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc value-saturation-selector [{:keys [hue saturation value on-change]}]
|
(mf/defc value-saturation-selector [{:keys [saturation value on-change]}]
|
||||||
(let [dragging? (mf/use-state false)
|
(let [dragging? (mf/use-state false)
|
||||||
calculate-pos
|
calculate-pos
|
||||||
(fn [ev]
|
(fn [ev]
|
||||||
|
|
|
@ -6,22 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.colorpicker.slider-selector
|
(ns app.main.ui.workspace.colorpicker.slider-selector
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.math :as math]
|
[app.common.math :as math]
|
||||||
[app.common.uuid :refer [uuid]]
|
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.color :as uc]
|
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.main.store :as st]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
|
||||||
[app.main.data.workspace.colors :as dc]
|
|
||||||
[app.main.data.modal :as modal]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.i18n :as i18n :refer [t]]))
|
|
||||||
|
|
||||||
(mf/defc slider-selector
|
(mf/defc slider-selector
|
||||||
[{:keys [value class min-value max-value vertical? reverse? on-change]}]
|
[{:keys [value class min-value max-value vertical? reverse? on-change]}]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.timers :as tm]
|
[app.util.timers :as tm]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
@ -25,10 +25,8 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(mf/defc sidebar-options
|
(mf/defc sidebar-options
|
||||||
[{:keys [local] :as props}]
|
[]
|
||||||
(let [{cmode :mode cshow :show} (mf/deref refs/comments-local)
|
(let [{cmode :mode cshow :show} (mf/deref refs/comments-local)
|
||||||
locale (mf/deref i18n/locale)
|
|
||||||
|
|
||||||
update-mode
|
update-mode
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [mode]
|
(fn [mode]
|
||||||
|
@ -43,19 +41,19 @@
|
||||||
[:li {:class (dom/classnames :selected (or (= :all cmode) (nil? cmode)))
|
[:li {:class (dom/classnames :selected (or (= :all cmode) (nil? cmode)))
|
||||||
:on-click #(update-mode :all)}
|
:on-click #(update-mode :all)}
|
||||||
[:span.icon i/tick]
|
[:span.icon i/tick]
|
||||||
[:span.label (t locale "labels.show-all-comments")]]
|
[:span.label (tr "labels.show-all-comments")]]
|
||||||
|
|
||||||
[:li {:class (dom/classnames :selected (= :yours cmode))
|
[:li {:class (dom/classnames :selected (= :yours cmode))
|
||||||
:on-click #(update-mode :yours)}
|
:on-click #(update-mode :yours)}
|
||||||
[:span.icon i/tick]
|
[:span.icon i/tick]
|
||||||
[:span.label (t locale "labels.show-your-comments")]]
|
[:span.label (tr "labels.show-your-comments")]]
|
||||||
|
|
||||||
[:hr]
|
[:hr]
|
||||||
|
|
||||||
[:li {:class (dom/classnames :selected (= :pending cshow))
|
[:li {:class (dom/classnames :selected (= :pending cshow))
|
||||||
:on-click #(update-show (if (= :pending cshow) :all :pending))}
|
:on-click #(update-show (if (= :pending cshow) :all :pending))}
|
||||||
[:span.icon i/tick]
|
[:span.icon i/tick]
|
||||||
[:span.label (t locale "labels.hide-resolved-comments")]]]))
|
[:span.label (tr "labels.hide-resolved-comments")]]]))
|
||||||
|
|
||||||
(mf/defc comments-sidebar
|
(mf/defc comments-sidebar
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -9,23 +9,17 @@
|
||||||
(:require
|
(:require
|
||||||
[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.undo :as dwu]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.shortcuts :as sc]
|
[app.main.data.workspace.shortcuts :as sc]
|
||||||
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.streams :as ms]
|
|
||||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.hooks :refer [use-rxsub]]
|
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :refer [t] :as i18n]
|
[app.util.i18n :refer [tr] :as i18n]
|
||||||
[app.util.timers :as timers]
|
[app.util.timers :as timers]
|
||||||
[beicon.core :as rx]
|
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[potok.core :as ptk]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def menu-ref
|
(def menu-ref
|
||||||
|
@ -43,13 +37,12 @@
|
||||||
[:span.shortcut (or shortcut "")]])
|
[:span.shortcut (or shortcut "")]])
|
||||||
|
|
||||||
(mf/defc menu-separator
|
(mf/defc menu-separator
|
||||||
[props]
|
[]
|
||||||
[:li.separator])
|
[:li.separator])
|
||||||
|
|
||||||
(mf/defc shape-context-menu
|
(mf/defc shape-context-menu
|
||||||
[{:keys [mdata] :as props}]
|
[{:keys [mdata] :as props}]
|
||||||
(let [locale (mf/deref i18n/locale)
|
(let [{:keys [id] :as shape} (:shape mdata)
|
||||||
{:keys [id] :as shape} (:shape mdata)
|
|
||||||
selected (:selected mdata)
|
selected (:selected mdata)
|
||||||
|
|
||||||
single? (= (count selected) 1)
|
single? (= (count selected) 1)
|
||||||
|
@ -97,91 +90,91 @@
|
||||||
do-update-remote-component (st/emitf (modal/show
|
do-update-remote-component (st/emitf (modal/show
|
||||||
{:type :confirm
|
{:type :confirm
|
||||||
:message ""
|
:message ""
|
||||||
:title (t locale "modals.update-remote-component.message")
|
:title (tr "modals.update-remote-component.message")
|
||||||
:hint (t locale "modals.update-remote-component.hint")
|
:hint (tr "modals.update-remote-component.hint")
|
||||||
:cancel-label (t locale "modals.update-remote-component.cancel")
|
:cancel-label (tr "modals.update-remote-component.cancel")
|
||||||
:accept-label (t locale "modals.update-remote-component.accept")
|
:accept-label (tr "modals.update-remote-component.accept")
|
||||||
:accept-style :primary
|
:accept-style :primary
|
||||||
:on-accept confirm-update-remote-component}))
|
:on-accept confirm-update-remote-component}))
|
||||||
do-show-component (st/emitf (dw/go-to-layout :assets))
|
do-show-component (st/emitf (dw/go-to-layout :assets))
|
||||||
do-navigate-component-file (st/emitf (dwl/nav-to-component-file
|
do-navigate-component-file (st/emitf (dwl/nav-to-component-file
|
||||||
(:component-file shape)))]
|
(:component-file shape)))]
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.copy")
|
[:& menu-entry {:title (tr "workspace.shape.menu.copy")
|
||||||
:shortcut (sc/get-tooltip :copy)
|
:shortcut (sc/get-tooltip :copy)
|
||||||
:on-click do-copy}]
|
:on-click do-copy}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.cut")
|
[:& menu-entry {:title (tr "workspace.shape.menu.cut")
|
||||||
:shortcut (sc/get-tooltip :cut)
|
:shortcut (sc/get-tooltip :cut)
|
||||||
:on-click do-cut}]
|
:on-click do-cut}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.paste")
|
[:& menu-entry {:title (tr "workspace.shape.menu.paste")
|
||||||
:shortcut (sc/get-tooltip :paste)
|
:shortcut (sc/get-tooltip :paste)
|
||||||
:on-click do-paste}]
|
:on-click do-paste}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.duplicate")
|
[:& menu-entry {:title (tr "workspace.shape.menu.duplicate")
|
||||||
:shortcut (sc/get-tooltip :duplicate)
|
:shortcut (sc/get-tooltip :duplicate)
|
||||||
:on-click do-duplicate}]
|
:on-click do-duplicate}]
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.forward")
|
[:& menu-entry {:title (tr "workspace.shape.menu.forward")
|
||||||
:shortcut (sc/get-tooltip :bring-forward)
|
:shortcut (sc/get-tooltip :bring-forward)
|
||||||
:on-click do-bring-forward}]
|
:on-click do-bring-forward}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.front")
|
[:& menu-entry {:title (tr "workspace.shape.menu.front")
|
||||||
:shortcut (sc/get-tooltip :bring-front)
|
:shortcut (sc/get-tooltip :bring-front)
|
||||||
:on-click do-bring-to-front}]
|
:on-click do-bring-to-front}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.backward")
|
[:& menu-entry {:title (tr "workspace.shape.menu.backward")
|
||||||
:shortcut (sc/get-tooltip :bring-backward)
|
:shortcut (sc/get-tooltip :bring-backward)
|
||||||
:on-click do-send-backward}]
|
:on-click do-send-backward}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.back")
|
[:& menu-entry {:title (tr "workspace.shape.menu.back")
|
||||||
:shortcut (sc/get-tooltip :bring-back)
|
:shortcut (sc/get-tooltip :bring-back)
|
||||||
:on-click do-send-to-back}]
|
:on-click do-send-to-back}]
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
|
|
||||||
(when multiple?
|
(when multiple?
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.group")
|
[:& menu-entry {:title (tr "workspace.shape.menu.group")
|
||||||
:shortcut (sc/get-tooltip :group)
|
:shortcut (sc/get-tooltip :group)
|
||||||
:on-click do-create-group}]
|
:on-click do-create-group}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.mask")
|
[:& menu-entry {:title (tr "workspace.shape.menu.mask")
|
||||||
:shortcut (sc/get-tooltip :mask)
|
:shortcut (sc/get-tooltip :mask)
|
||||||
:on-click do-mask-group}]
|
:on-click do-mask-group}]
|
||||||
[:& menu-separator]])
|
[:& menu-separator]])
|
||||||
|
|
||||||
(when (or single? multiple?)
|
(when (or single? multiple?)
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.flip-vertical")
|
[:& menu-entry {:title (tr "workspace.shape.menu.flip-vertical")
|
||||||
:shortcut (sc/get-tooltip :flip-vertical)
|
:shortcut (sc/get-tooltip :flip-vertical)
|
||||||
:on-click do-flip-vertical}]
|
:on-click do-flip-vertical}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.flip-horizontal")
|
[:& menu-entry {:title (tr "workspace.shape.menu.flip-horizontal")
|
||||||
:shortcut (sc/get-tooltip :flip-horizontal)
|
:shortcut (sc/get-tooltip :flip-horizontal)
|
||||||
:on-click do-flip-horizontal}]
|
:on-click do-flip-horizontal}]
|
||||||
[:& menu-separator]])
|
[:& menu-separator]])
|
||||||
|
|
||||||
(when (and single? (= (:type shape) :group))
|
(when (and single? (= (:type shape) :group))
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.ungroup")
|
[:& menu-entry {:title (tr "workspace.shape.menu.ungroup")
|
||||||
:shortcut (sc/get-tooltip :ungroup)
|
:shortcut (sc/get-tooltip :ungroup)
|
||||||
:on-click do-remove-group}]
|
:on-click do-remove-group}]
|
||||||
(if (:masked-group? shape)
|
(if (:masked-group? shape)
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.unmask")
|
[:& menu-entry {:title (tr "workspace.shape.menu.unmask")
|
||||||
:shortcut (sc/get-tooltip :unmask)
|
:shortcut (sc/get-tooltip :unmask)
|
||||||
:on-click do-unmask-group}]
|
:on-click do-unmask-group}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.mask")
|
[:& menu-entry {:title (tr "workspace.shape.menu.mask")
|
||||||
:shortcut (sc/get-tooltip :group)
|
:shortcut (sc/get-tooltip :group)
|
||||||
:on-click do-mask-group}])])
|
:on-click do-mask-group}])])
|
||||||
|
|
||||||
(when (and single? editable-shape?)
|
(when (and single? editable-shape?)
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.edit")
|
[:& menu-entry {:title (tr "workspace.shape.menu.edit")
|
||||||
:shortcut (sc/get-tooltip :start-editing)
|
:shortcut (sc/get-tooltip :start-editing)
|
||||||
:on-click do-start-editing}])
|
:on-click do-start-editing}])
|
||||||
|
|
||||||
(if (:hidden shape)
|
(if (:hidden shape)
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.show")
|
[:& menu-entry {:title (tr "workspace.shape.menu.show")
|
||||||
:on-click do-show-shape}]
|
:on-click do-show-shape}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.hide")
|
[:& menu-entry {:title (tr "workspace.shape.menu.hide")
|
||||||
:on-click do-hide-shape}])
|
:on-click do-hide-shape}])
|
||||||
|
|
||||||
(if (:blocked shape)
|
(if (:blocked shape)
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.unlock")
|
[:& menu-entry {:title (tr "workspace.shape.menu.unlock")
|
||||||
:on-click do-unlock-shape}]
|
:on-click do-unlock-shape}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.lock")
|
[:& menu-entry {:title (tr "workspace.shape.menu.lock")
|
||||||
:on-click do-lock-shape}])
|
:on-click do-lock-shape}])
|
||||||
|
|
||||||
(when (and (or (nil? (:shape-ref shape))
|
(when (and (or (nil? (:shape-ref shape))
|
||||||
|
@ -189,7 +182,7 @@
|
||||||
(not= (:type shape) :frame))
|
(not= (:type shape) :frame))
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.create-component")
|
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
||||||
:shortcut (sc/get-tooltip :create-component)
|
:shortcut (sc/get-tooltip :create-component)
|
||||||
:on-click do-add-component}]])
|
:on-click do-add-component}]])
|
||||||
|
|
||||||
|
@ -201,41 +194,39 @@
|
||||||
(if (= (:component-file shape) current-file-id)
|
(if (= (:component-file shape) current-file-id)
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.detach-instance")
|
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instance")
|
||||||
:on-click do-detach-component}]
|
:on-click do-detach-component}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides")
|
[:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides")
|
||||||
:on-click do-reset-component}]
|
:on-click do-reset-component}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.update-main")
|
[:& menu-entry {:title (tr "workspace.shape.menu.update-main")
|
||||||
:on-click do-update-component}]
|
:on-click do-update-component}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.show-main")
|
[:& menu-entry {:title (tr "workspace.shape.menu.show-main")
|
||||||
:on-click do-show-component}]]
|
:on-click do-show-component}]]
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.detach-instance")
|
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instance")
|
||||||
:on-click do-detach-component}]
|
:on-click do-detach-component}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides")
|
[:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides")
|
||||||
:on-click do-reset-component}]
|
:on-click do-reset-component}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.go-main")
|
[:& menu-entry {:title (tr "workspace.shape.menu.go-main")
|
||||||
:on-click do-navigate-component-file}]
|
:on-click do-navigate-component-file}]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.update-main")
|
[:& menu-entry {:title (tr "workspace.shape.menu.update-main")
|
||||||
:on-click do-update-remote-component}]]))
|
:on-click do-update-remote-component}]]))
|
||||||
|
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.delete")
|
[:& menu-entry {:title (tr "workspace.shape.menu.delete")
|
||||||
:shortcut (sc/get-tooltip :delete)
|
:shortcut (sc/get-tooltip :delete)
|
||||||
:on-click do-delete}]]))
|
:on-click do-delete}]]))
|
||||||
|
|
||||||
(mf/defc viewport-context-menu
|
(mf/defc viewport-context-menu
|
||||||
[{:keys [mdata] :as props}]
|
[]
|
||||||
(let [locale (mf/deref i18n/locale)
|
(let [do-paste (st/emitf dw/paste)]
|
||||||
do-paste (st/emitf dw/paste)]
|
[:& menu-entry {:title (tr "workspace.shape.menu.paste")
|
||||||
[:*
|
:shortcut (sc/get-tooltip :paste)
|
||||||
[:& menu-entry {:title (t locale "workspace.shape.menu.paste")
|
:on-click do-paste}]))
|
||||||
:shortcut (sc/get-tooltip :paste)
|
|
||||||
:on-click do-paste}]]))
|
|
||||||
|
|
||||||
(mf/defc context-menu
|
(mf/defc context-menu
|
||||||
[props]
|
[]
|
||||||
(let [mdata (mf/deref menu-ref)
|
(let [mdata (mf/deref menu-ref)
|
||||||
top (- (get-in mdata [:position :y]) 20)
|
top (- (get-in mdata [:position :y]) 20)
|
||||||
left (get-in mdata [:position :x])
|
left (get-in mdata [:position :x])
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.coordinates
|
(ns app.main.ui.workspace.coordinates
|
||||||
(:require
|
(:require
|
||||||
[app.main.ui.hooks :as hooks]
|
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
|
[app.main.ui.hooks :as hooks]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc coordinates
|
(mf/defc coordinates
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
|
||||||
(let [toggle-selected? (and selected? shift?)
|
(let [toggle-selected? (and selected? shift?)
|
||||||
deselect? (and (not selected?) (not (empty? selected)) (not shift?))]
|
deselect? (and (not selected?) (seq selected) (not shift?))]
|
||||||
(apply
|
(apply
|
||||||
st/emit!
|
st/emit!
|
||||||
(cond-> []
|
(cond-> []
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[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.shortcuts :as sc]
|
[app.main.data.workspace.shortcuts :as sc]
|
||||||
[app.main.data.workspace.shortcuts :as sc]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||||
|
@ -89,8 +88,6 @@
|
||||||
(let [show-menu? (mf/use-state false)
|
(let [show-menu? (mf/use-state false)
|
||||||
editing? (mf/use-state false)
|
editing? (mf/use-state false)
|
||||||
|
|
||||||
locale (mf/deref i18n/locale)
|
|
||||||
|
|
||||||
edit-input-ref (mf/use-ref nil)
|
edit-input-ref (mf/use-ref nil)
|
||||||
|
|
||||||
add-shared-fn
|
add-shared-fn
|
||||||
|
@ -125,7 +122,7 @@
|
||||||
:on-accept del-shared-fn})))
|
:on-accept del-shared-fn})))
|
||||||
|
|
||||||
|
|
||||||
handle-blur (fn [event]
|
handle-blur (fn [_]
|
||||||
(let [value (-> edit-input-ref mf/ref-val dom/get-value)]
|
(let [value (-> edit-input-ref mf/ref-val dom/get-value)]
|
||||||
(st/emit! (dw/rename-file (:id file) value)))
|
(st/emit! (dw/rename-file (:id file) value)))
|
||||||
(reset! editing? false))
|
(reset! editing? false))
|
||||||
|
@ -243,9 +240,7 @@
|
||||||
[{:keys [file layout project page-id] :as props}]
|
[{:keys [file layout project page-id] :as props}]
|
||||||
(let [team-id (:team-id project)
|
(let [team-id (:team-id project)
|
||||||
zoom (mf/deref refs/selected-zoom)
|
zoom (mf/deref refs/selected-zoom)
|
||||||
router (mf/deref refs/router)
|
|
||||||
params {:page-id page-id :file-id (:id file)}
|
params {:page-id page-id :file-id (:id file)}
|
||||||
view-url (rt/resolve router :viewer params {:index 0})
|
|
||||||
|
|
||||||
go-back
|
go-back
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
|
|
@ -7,18 +7,18 @@
|
||||||
(ns app.main.ui.workspace.libraries
|
(ns app.main.ui.workspace.libraries
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[rumext.alpha :as mf]
|
[app.main.data.modal :as modal]
|
||||||
[cuerdas.core :as str]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
|
||||||
[app.util.data :refer [classnames matches-search]]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
|
[app.main.refs :as refs]
|
||||||
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.data.modal :as modal]))
|
[app.util.data :refer [classnames matches-search]]
|
||||||
|
[app.util.dom :as dom]
|
||||||
|
[app.util.i18n :as i18n :refer [t tr]]
|
||||||
|
[cuerdas.core :as str]
|
||||||
|
[okulary.core :as l]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def workspace-file
|
(def workspace-file
|
||||||
(l/derived :workspace-file st/state))
|
(l/derived :workspace-file st/state))
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
on-search-clear
|
on-search-clear
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(reset! search-term "")))
|
(reset! search-term "")))
|
||||||
|
|
||||||
link-library
|
link-library
|
||||||
|
@ -152,8 +152,7 @@
|
||||||
project (mf/deref refs/workspace-project)
|
project (mf/deref refs/workspace-project)
|
||||||
file (mf/deref workspace-file)
|
file (mf/deref workspace-file)
|
||||||
libraries (->> (mf/deref refs/workspace-libraries)
|
libraries (->> (mf/deref refs/workspace-libraries)
|
||||||
(d/removem (fn [[key val]]
|
(d/removem (fn [[_ val]] (:is-indirect val))))
|
||||||
(:is-indirect val))))
|
|
||||||
shared-files (mf/deref refs/workspace-shared-files)
|
shared-files (mf/deref refs/workspace-shared-files)
|
||||||
|
|
||||||
change-tab #(reset! selected-tab %)
|
change-tab #(reset! selected-tab %)
|
||||||
|
|
|
@ -8,14 +8,12 @@
|
||||||
(:require
|
(:require
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.util.router :as rt]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; --- SESSION WIDGET
|
;; --- SESSION WIDGET
|
||||||
|
|
||||||
(mf/defc session-widget
|
(mf/defc session-widget
|
||||||
[{:keys [session self? profile] :as props}]
|
[{:keys [session profile] :as props}]
|
||||||
[:li.tooltip.tooltip-bottom
|
[:li.tooltip.tooltip-bottom
|
||||||
{:alt (:fullname profile)}
|
{:alt (:fullname profile)}
|
||||||
[:img {:style {:border-color (:color session)}
|
[:img {:style {:border-color (:color session)}
|
||||||
|
@ -24,15 +22,13 @@
|
||||||
(mf/defc active-sessions
|
(mf/defc active-sessions
|
||||||
{::mf/wrap [mf/memo]}
|
{::mf/wrap [mf/memo]}
|
||||||
[]
|
[]
|
||||||
(let [profile (mf/deref refs/profile)
|
(let [users (mf/deref refs/users)
|
||||||
users (mf/deref refs/users)
|
|
||||||
presence (mf/deref refs/workspace-presence)]
|
presence (mf/deref refs/workspace-presence)]
|
||||||
[:ul.active-users
|
[:ul.active-users
|
||||||
(for [session (vals presence)]
|
(for [session (vals presence)]
|
||||||
[:& session-widget
|
[:& session-widget
|
||||||
{:session session
|
{:session session
|
||||||
:profile (get users (:profile-id session))
|
:profile (get users (:profile-id session))
|
||||||
:self? (= (:profile-id session) (:id profile))
|
|
||||||
:key (:id session)}])]))
|
:key (:id session)}])]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.rules
|
(ns app.main.ui.workspace.rules
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.timers :as timers]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn- calculate-step-size
|
(defn- calculate-step-size
|
||||||
[zoom]
|
[zoom]
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
:else 1))
|
:else 1))
|
||||||
|
|
||||||
(defn draw-rule!
|
(defn draw-rule!
|
||||||
[dctx {:keys [zoom size start count type] :or {count 200}}]
|
[dctx {:keys [zoom size start type]}]
|
||||||
(when start
|
(when start
|
||||||
(let [txfm (- (* (- 0 start) zoom) 20)
|
(let [txfm (- (* (- 0 start) zoom) 20)
|
||||||
step (calculate-step-size zoom)
|
step (calculate-step-size zoom)
|
||||||
|
|
|
@ -6,15 +6,11 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.bounding-box
|
(ns app.main.ui.workspace.shapes.bounding-box
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
["randomcolor" :as rdcolor]
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[app.util.debug :as debug]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.geom.matrix :as gmt]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.util.debug :refer [debug?]]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
["randomcolor" :as rdcolor]))
|
[cuerdas.core :as str]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(defn fixed
|
(defn fixed
|
||||||
[num]
|
[num]
|
||||||
|
@ -58,15 +54,11 @@
|
||||||
(mf/defc bounding-box
|
(mf/defc bounding-box
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (-> (unchecked-get props "shape"))
|
(let [shape (unchecked-get props "shape")
|
||||||
frame (unchecked-get props "frame")
|
|
||||||
bounding-box (gsh/points->selrect (-> shape :points))
|
bounding-box (gsh/points->selrect (-> shape :points))
|
||||||
shape-center (gsh/center-shape shape)
|
shape-center (gsh/center-shape shape)
|
||||||
line-color (rdcolor #js {:seed (str (:id shape))})
|
line-color (rdcolor #js {:seed (str (:id shape))})
|
||||||
zoom (mf/deref refs/selected-zoom)
|
zoom (mf/deref refs/selected-zoom)]
|
||||||
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
|
|
||||||
childs (->> (mf/deref childs-ref)
|
|
||||||
(map gsh/transform-shape))]
|
|
||||||
|
|
||||||
[:g.bounding-box
|
[:g.bounding-box
|
||||||
[:text {:x (:x bounding-box)
|
[:text {:x (:x bounding-box)
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
(ns app.main.ui.workspace.shapes.frame
|
(ns app.main.ui.workspace.shapes.frame
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.ui.shapes.frame :as frame]
|
[app.main.ui.shapes.frame :as frame]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.main.ui.shapes.text.fontfaces :as ff]
|
[app.main.ui.shapes.text.fontfaces :as ff]
|
||||||
|
@ -77,14 +76,10 @@
|
||||||
objects (unchecked-get props "objects")
|
objects (unchecked-get props "objects")
|
||||||
thumbnail? (unchecked-get props "thumbnail?")
|
thumbnail? (unchecked-get props "thumbnail?")
|
||||||
|
|
||||||
edition (mf/deref refs/selected-edition)
|
|
||||||
|
|
||||||
shape (gsh/transform-shape shape)
|
shape (gsh/transform-shape shape)
|
||||||
children (mapv #(get objects %) (:shapes shape))
|
children (mapv #(get objects %) (:shapes shape))
|
||||||
|
|
||||||
ds-modifier (get-in shape [:modifiers :displacement])
|
rendered? (mf/use-state false)
|
||||||
|
|
||||||
rendered? (mf/use-state false)
|
|
||||||
|
|
||||||
show-thumbnail? (and thumbnail? (some? (:thumbnail shape)))
|
show-thumbnail? (and thumbnail? (some? (:thumbnail shape)))
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,12 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.group
|
(ns app.main.ui.workspace.shapes.group
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.main.ui.hooks :as hooks]
|
|
||||||
[app.main.ui.shapes.group :as group]
|
[app.main.ui.shapes.group :as group]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.util.debug :refer [debug?]]
|
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
@ -33,10 +30,8 @@
|
||||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))]
|
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
frame (unchecked-get props "frame")
|
frame (unchecked-get props "frame")
|
||||||
|
|
||||||
{:keys [id x y width height]} shape
|
|
||||||
|
|
||||||
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape) {:with-modifiers? true}))
|
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape) {:with-modifiers? true}))
|
||||||
childs (mf/deref childs-ref)]
|
childs (mf/deref childs-ref)]
|
||||||
|
|
|
@ -6,13 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.path
|
(ns app.main.ui.workspace.shapes.path
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.workspace :as dw]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.ui.shapes.path :as path]
|
[app.main.ui.shapes.path :as path]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.main.ui.workspace.shapes.path.common :as pc]
|
[app.main.ui.workspace.shapes.path.common :as pc]
|
||||||
[app.util.dom :as dom]
|
|
||||||
[app.util.path.commands :as upc]
|
[app.util.path.commands :as upc]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.workspace.shapes.path.common :as pc]
|
[app.main.ui.workspace.shapes.path.common :as pc]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.path.geom :as upg]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.path.commands :as upc]
|
[app.util.path.commands :as upc]
|
||||||
[app.util.path.format :as upf]
|
[app.util.path.format :as upf]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.path.geom :as upg]
|
||||||
[clojure.set :refer [map-invert]]
|
[clojure.set :refer [map-invert]]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[rumext.alpha :as mf])
|
[rumext.alpha :as mf])
|
||||||
|
@ -31,12 +31,12 @@
|
||||||
|
|
||||||
on-enter
|
on-enter
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(st/emit! (drp/path-pointer-enter position))))
|
(st/emit! (drp/path-pointer-enter position))))
|
||||||
|
|
||||||
on-leave
|
on-leave
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(st/emit! (drp/path-pointer-leave position))))
|
(st/emit! (drp/path-pointer-leave position))))
|
||||||
|
|
||||||
on-mouse-down
|
on-mouse-down
|
||||||
|
@ -96,11 +96,11 @@
|
||||||
(when (and point handler)
|
(when (and point handler)
|
||||||
(let [{:keys [x y]} handler
|
(let [{:keys [x y]} handler
|
||||||
on-enter
|
on-enter
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(st/emit! (drp/path-handler-enter index prefix)))
|
(st/emit! (drp/path-handler-enter index prefix)))
|
||||||
|
|
||||||
on-leave
|
on-leave
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(st/emit! (drp/path-handler-leave index prefix)))
|
(st/emit! (drp/path-handler-leave index prefix)))
|
||||||
|
|
||||||
on-mouse-down
|
on-mouse-down
|
||||||
|
@ -225,7 +225,6 @@
|
||||||
|
|
||||||
points (into #{} content-points)
|
points (into #{} content-points)
|
||||||
|
|
||||||
last-command (last content)
|
|
||||||
last-p (->> content last upc/command->point)
|
last-p (->> content last upc/command->point)
|
||||||
handlers (upc/content->handlers content)
|
handlers (upc/content->handlers content)
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@
|
||||||
moving-nodes))
|
moving-nodes))
|
||||||
|
|
||||||
handle-double-click-outside
|
handle-double-click-outside
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(when (= edit-mode :move)
|
(when (= edit-mode :move)
|
||||||
(st/emit! :interrupt)))]
|
(st/emit! :interrupt)))]
|
||||||
|
|
||||||
|
@ -298,7 +297,7 @@
|
||||||
last-p? (= last-point (get point->base position))
|
last-p? (= last-point (get point->base position))
|
||||||
|
|
||||||
pos-handlers (->> pos-handlers (filter show-handler?))
|
pos-handlers (->> pos-handlers (filter show-handler?))
|
||||||
curve? (not (empty? pos-handlers))]
|
curve? (boolean (seq pos-handlers))]
|
||||||
|
|
||||||
[:g.path-node
|
[:g.path-node
|
||||||
[:g.point-handlers {:pointer-events (when (= edit-mode :draw) "none")}
|
[:g.point-handlers {:pointer-events (when (= edit-mode :draw) "none")}
|
||||||
|
|
|
@ -7,11 +7,9 @@
|
||||||
(ns app.main.ui.workspace.shapes.svg-raw
|
(ns app.main.ui.workspace.shapes.svg-raw
|
||||||
(:require
|
(:require
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.ui.shapes.svg-raw :as svg-raw]
|
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[rumext.alpha :as mf]
|
[app.main.ui.shapes.svg-raw :as svg-raw]
|
||||||
[app.common.geom.shapes :as gsh]
|
[rumext.alpha :as mf]))
|
||||||
[app.main.ui.context :as muc]))
|
|
||||||
|
|
||||||
(defn svg-raw-wrapper-factory
|
(defn svg-raw-wrapper-factory
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
|
@ -20,20 +18,12 @@
|
||||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))]
|
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
frame (unchecked-get props "frame")
|
frame (unchecked-get props "frame")
|
||||||
|
|
||||||
{:keys [id x y width height]} shape
|
|
||||||
|
|
||||||
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
|
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
|
||||||
childs (mf/deref childs-ref)
|
childs (mf/deref childs-ref)]
|
||||||
|
|
||||||
{:keys [id x y width height]} shape
|
|
||||||
transform (gsh/transform-matrix shape)
|
|
||||||
|
|
||||||
tag (get-in shape [:content :tag])
|
|
||||||
|
|
||||||
def-ctx? (mf/use-ctx muc/def-ctx)]
|
|
||||||
|
|
||||||
(if (or (= (get-in shape [:content :tag]) :svg)
|
(if (or (= (get-in shape [:content :tag]) :svg)
|
||||||
(and (contains? shape :svg-attrs) (map? (:content shape))))
|
(and (contains? shape :svg-attrs) (map? (:content shape))))
|
||||||
|
|
|
@ -6,25 +6,20 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.text
|
(ns app.main.ui.workspace.shapes.text
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.main.data.workspace :as dw]
|
|
||||||
[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]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.context :as muc]
|
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.main.ui.shapes.text :as text]
|
[app.main.ui.shapes.text :as text]
|
||||||
[app.main.ui.workspace.shapes.common :as common]
|
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.logging :as log]
|
[app.util.logging :as log]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
[app.util.text-editor :as ted]
|
||||||
[app.util.timers :as timers]
|
[app.util.timers :as timers]
|
||||||
[app.util.webapi :as wapi]
|
[app.util.webapi :as wapi]
|
||||||
[app.util.text-editor :as ted]
|
|
||||||
[okulary.core :as l]
|
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; Change this to :info :debug or :trace to debug this module
|
;; Change this to :info :debug or :trace to debug this module
|
||||||
|
@ -50,7 +45,7 @@
|
||||||
(mf/defc text-resize-content
|
(mf/defc text-resize-content
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [{:keys [id name x y grow-type] :as shape} (obj/get props "shape")
|
(let [{:keys [id name grow-type] :as shape} (obj/get props "shape")
|
||||||
|
|
||||||
;; NOTE: this breaks the hooks rule of "no hooks inside
|
;; NOTE: this breaks the hooks rule of "no hooks inside
|
||||||
;; conditional code"; but we ensure that this component will
|
;; conditional code"; but we ensure that this component will
|
||||||
|
@ -77,8 +72,8 @@
|
||||||
#(let [width (obj/get-in entries [0 "contentRect" "width"])
|
#(let [width (obj/get-in entries [0 "contentRect" "width"])
|
||||||
height (obj/get-in entries [0 "contentRect" "height"])]
|
height (obj/get-in entries [0 "contentRect" "height"])]
|
||||||
(when (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height)))
|
(when (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height)))
|
||||||
(do (log/debug :msg "Resize detected" :shape-id id :width width :height height)
|
(log/debug :msg "Resize detected" :shape-id id :width width :height height)
|
||||||
(st/emit! (dwt/resize-text id (mth/ceil width) (mth/ceil height))))))))))
|
(st/emit! (dwt/resize-text id (mth/ceil width) (mth/ceil height)))))))))
|
||||||
|
|
||||||
text-ref-cb
|
text-ref-cb
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -109,7 +104,7 @@
|
||||||
(mf/defc text-wrapper
|
(mf/defc text-wrapper
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [{:keys [id x y width height] :as shape} (unchecked-get props "shape")
|
(let [{:keys [id] :as shape} (unchecked-get props "shape")
|
||||||
edition-ref (mf/use-memo (mf/deps id) #(l/derived (fn [o] (= id (:edition o))) refs/workspace-local))
|
edition-ref (mf/use-memo (mf/deps id) #(l/derived (fn [o] (= id (:edition o))) refs/workspace-local))
|
||||||
edition? (mf/deref edition-ref)]
|
edition? (mf/deref edition-ref)]
|
||||||
|
|
||||||
|
@ -124,4 +119,4 @@
|
||||||
;; the component if the edition flag changes.
|
;; the component if the edition flag changes.
|
||||||
[:& text-resize-content {:shape shape
|
[:& text-resize-content {:shape shape
|
||||||
:edition? edition?
|
:edition? edition?
|
||||||
:key (str (:id shape) edition?)}]]]))
|
:key (str id edition?)}]]]))
|
||||||
|
|
|
@ -7,12 +7,9 @@
|
||||||
(ns app.main.ui.workspace.shapes.text.editor
|
(ns app.main.ui.workspace.shapes.text.editor
|
||||||
(:require
|
(:require
|
||||||
["draft-js" :as draft]
|
["draft-js" :as draft]
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.common :as dwc]
|
|
||||||
[app.main.data.workspace.selection :as dws]
|
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -22,9 +19,7 @@
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.text-editor :as ted]
|
[app.util.text-editor :as ted]
|
||||||
[cuerdas.core :as str]
|
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[okulary.core :as l]
|
|
||||||
[rumext.alpha :as mf])
|
[rumext.alpha :as mf])
|
||||||
(:import
|
(:import
|
||||||
goog.events.EventType))
|
goog.events.EventType))
|
||||||
|
@ -34,12 +29,11 @@
|
||||||
(mf/defc block-component
|
(mf/defc block-component
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [children (obj/get props "children")
|
(let [bprops (obj/get props "blockProps")
|
||||||
bprops (obj/get props "blockProps")
|
data (obj/get bprops "data")
|
||||||
data (obj/get bprops "data")
|
style (sts/generate-paragraph-styles (obj/get bprops "shape")
|
||||||
style (sts/generate-paragraph-styles (obj/get bprops "shape")
|
|
||||||
(obj/get bprops "data"))
|
(obj/get bprops "data"))
|
||||||
dir (:text-direction data "auto")]
|
dir (:text-direction data "auto")]
|
||||||
|
|
||||||
|
|
||||||
[:div {:style style :dir dir}
|
[:div {:style style :dir dir}
|
||||||
|
@ -72,10 +66,9 @@
|
||||||
{::mf/wrap [mf/memo]
|
{::mf/wrap [mf/memo]
|
||||||
::mf/wrap-props false
|
::mf/wrap-props false
|
||||||
::mf/forward-ref true}
|
::mf/forward-ref true}
|
||||||
[props ref]
|
[props _]
|
||||||
(let [{:keys [id x y width height grow-type content] :as shape} (obj/get props "shape")
|
(let [{:keys [id content] :as shape} (obj/get props "shape")
|
||||||
|
|
||||||
zoom (mf/deref refs/selected-zoom)
|
|
||||||
state-map (mf/deref refs/workspace-editor-state)
|
state-map (mf/deref refs/workspace-editor-state)
|
||||||
state (get state-map id empty-editor-state)
|
state (get state-map id empty-editor-state)
|
||||||
self-ref (mf/use-ref)
|
self-ref (mf/use-ref)
|
||||||
|
@ -86,9 +79,8 @@
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(when (kbd/esc? event)
|
(when (kbd/esc? event)
|
||||||
(do
|
(st/emit! :interrupt)
|
||||||
(st/emit! :interrupt)
|
(st/emit! dw/clear-edition-mode)))
|
||||||
(st/emit! dw/clear-edition-mode))))
|
|
||||||
|
|
||||||
on-mount
|
on-mount
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -111,7 +103,7 @@
|
||||||
on-focus
|
on-focus
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps shape state)
|
(mf/deps shape state)
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(reset! blured false)))
|
(reset! blured false)))
|
||||||
|
|
||||||
on-change
|
on-change
|
||||||
|
@ -131,7 +123,7 @@
|
||||||
|
|
||||||
handle-return
|
handle-return
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event state]
|
(fn [_ state]
|
||||||
(st/emit! (dwt/update-editor-state shape (ted/editor-split-block state)))
|
(st/emit! (dwt/update-editor-state shape (ted/editor-split-block state)))
|
||||||
"handled"))
|
"handled"))
|
||||||
]
|
]
|
||||||
|
@ -165,7 +157,7 @@
|
||||||
{::mf/wrap [mf/memo]
|
{::mf/wrap [mf/memo]
|
||||||
::mf/wrap-props false
|
::mf/wrap-props false
|
||||||
::mf/forward-ref true}
|
::mf/forward-ref true}
|
||||||
[props ref]
|
[props _]
|
||||||
(let [{:keys [id x y width height grow-type] :as shape} (obj/get props "shape")
|
(let [{:keys [id x y width height grow-type] :as shape} (obj/get props "shape")
|
||||||
clip-id (str "clip-" id)]
|
clip-id (str "clip-" id)]
|
||||||
[:g.text-editor {:clip-path (str "url(#" clip-id ")")}
|
[:g.text-editor {:clip-path (str "url(#" clip-id ")")}
|
||||||
|
|
|
@ -7,22 +7,18 @@
|
||||||
(ns app.main.ui.workspace.sidebar.assets
|
(ns app.main.ui.workspace.sidebar.assets
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.shapes :as geom]
|
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
|
[app.common.spec :as us]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[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.colors :as dc]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.exports :as exports]
|
[app.main.exports :as exports]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -31,17 +27,15 @@
|
||||||
[app.main.ui.components.editable-label :refer [editable-label]]
|
[app.main.ui.components.editable-label :refer [editable-label]]
|
||||||
[app.main.ui.components.file-uploader :refer [file-uploader]]
|
[app.main.ui.components.file-uploader :refer [file-uploader]]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
[app.main.ui.components.tab-container :refer [tab-container tab-element]]
|
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.workspace.sidebar.options.menus.typography :refer [typography-entry]]
|
[app.main.ui.workspace.sidebar.options.menus.typography :refer [typography-entry]]
|
||||||
[app.util.data :refer [matches-search]]
|
[app.util.data :refer [matches-search]]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.dom.dnd :as dnd]
|
[app.util.dom.dnd :as dnd]
|
||||||
[app.util.i18n :as i18n :refer [tr t]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[app.util.timers :as timers]
|
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
|
@ -133,7 +127,7 @@
|
||||||
on-accept
|
on-accept
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps form)
|
(mf/deps form)
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(let [asset-name (get-in @form [:clean-data :asset-name])]
|
(let [asset-name (get-in @form [:clean-data :asset-name])]
|
||||||
(if create?
|
(if create?
|
||||||
(accept asset-name)
|
(accept asset-name)
|
||||||
|
@ -219,7 +213,7 @@
|
||||||
content)]))
|
content)]))
|
||||||
|
|
||||||
(mf/defc asset-section-block
|
(mf/defc asset-section-block
|
||||||
[{:keys [children role]}]
|
[{:keys [children]}]
|
||||||
[:* children])
|
[:* children])
|
||||||
|
|
||||||
(mf/defc asset-group-title
|
(mf/defc asset-group-title
|
||||||
|
@ -352,11 +346,11 @@
|
||||||
|
|
||||||
selected-components (:components selected-assets)
|
selected-components (:components selected-assets)
|
||||||
multi-components? (> (count selected-components) 1)
|
multi-components? (> (count selected-components) 1)
|
||||||
multi-assets? (or (not (empty? (:graphics selected-assets)))
|
multi-assets? (or (seq (:graphics selected-assets))
|
||||||
(not (empty? (:colors selected-assets)))
|
(seq (:colors selected-assets))
|
||||||
(not (empty? (:typographies selected-assets))))
|
(seq (:typographies selected-assets)))
|
||||||
|
|
||||||
groups (group-assets components)
|
groups (group-assets components)
|
||||||
|
|
||||||
on-duplicate
|
on-duplicate
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -603,9 +597,9 @@
|
||||||
|
|
||||||
selected-objects (:graphics selected-assets)
|
selected-objects (:graphics selected-assets)
|
||||||
multi-objects? (> (count selected-objects) 1)
|
multi-objects? (> (count selected-objects) 1)
|
||||||
multi-assets? (or (not (empty? (:components selected-assets)))
|
multi-assets? (or (seq (:components selected-assets))
|
||||||
(not (empty? (:colors selected-assets)))
|
(seq (:colors selected-assets))
|
||||||
(not (empty? (:typographies selected-assets))))
|
(seq (:typographies selected-assets)))
|
||||||
|
|
||||||
groups (group-assets objects)
|
groups (group-assets objects)
|
||||||
|
|
||||||
|
@ -776,10 +770,8 @@
|
||||||
|
|
||||||
(mf/defc color-item
|
(mf/defc color-item
|
||||||
[{:keys [color local? file-id selected-colors multi-colors? multi-assets?
|
[{:keys [color local? file-id selected-colors multi-colors? multi-assets?
|
||||||
on-asset-click on-assets-delete on-clear-selection on-group
|
on-asset-click on-assets-delete on-clear-selection on-group] :as props}]
|
||||||
colors locale] :as props}]
|
|
||||||
(let [rename? (= (:color-for-rename @refs/workspace-local) (:id color))
|
(let [rename? (= (:color-for-rename @refs/workspace-local) (:id color))
|
||||||
id (:id color)
|
|
||||||
input-ref (mf/use-ref)
|
input-ref (mf/use-ref)
|
||||||
state (mf/use-state {:editing rename?})
|
state (mf/use-state {:editing rename?})
|
||||||
|
|
||||||
|
@ -790,8 +782,9 @@
|
||||||
(:color color) (:color color)
|
(:color color) (:color color)
|
||||||
:else (:value color))
|
:else (:value color))
|
||||||
|
|
||||||
|
;; TODO: looks like the first argument is not necessary
|
||||||
apply-color
|
apply-color
|
||||||
(fn [color-id event]
|
(fn [_ event]
|
||||||
(let [ids (wsh/lookup-selected @st/state)]
|
(let [ids (wsh/lookup-selected @st/state)]
|
||||||
(if (kbd/shift? event)
|
(if (kbd/shift? event)
|
||||||
(st/emit! (dc/change-stroke ids color))
|
(st/emit! (dc/change-stroke ids color))
|
||||||
|
@ -892,17 +885,17 @@
|
||||||
{:on-close on-close-menu
|
{:on-close on-close-menu
|
||||||
:state @menu-state
|
:state @menu-state
|
||||||
:options [(when-not (or multi-colors? multi-assets?)
|
:options [(when-not (or multi-colors? multi-assets?)
|
||||||
[(t locale "workspace.assets.rename") rename-color-clicked])
|
[(tr "workspace.assets.rename") rename-color-clicked])
|
||||||
(when-not (or multi-colors? multi-assets?)
|
(when-not (or multi-colors? multi-assets?)
|
||||||
[(t locale "workspace.assets.edit") edit-color-clicked])
|
[(tr "workspace.assets.edit") edit-color-clicked])
|
||||||
[(t locale "workspace.assets.delete") delete-color]
|
[(tr "workspace.assets.delete") delete-color]
|
||||||
(when-not multi-assets?
|
(when-not multi-assets?
|
||||||
[(tr "workspace.assets.group") (on-group (:id color))])]}])]))
|
[(tr "workspace.assets.group") (on-group (:id color))])]}])]))
|
||||||
|
|
||||||
(mf/defc colors-group
|
(mf/defc colors-group
|
||||||
[{:keys [file-id prefix groups open-groups local? selected-colors
|
[{:keys [file-id prefix groups open-groups local? selected-colors
|
||||||
multi-colors? multi-assets? on-asset-click on-assets-delete
|
multi-colors? multi-assets? on-asset-click on-assets-delete
|
||||||
on-clear-selection on-group on-rename-group on-ungroup colors locale]}]
|
on-clear-selection on-group on-rename-group on-ungroup colors]}]
|
||||||
(let [group-open? (get open-groups prefix true)]
|
(let [group-open? (get open-groups prefix true)]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
|
@ -932,8 +925,7 @@
|
||||||
:on-assets-delete on-assets-delete
|
:on-assets-delete on-assets-delete
|
||||||
:on-clear-selection on-clear-selection
|
:on-clear-selection on-clear-selection
|
||||||
:on-group on-group
|
:on-group on-group
|
||||||
:colors colors
|
:colors colors}]))])
|
||||||
:locale locale}]))])
|
|
||||||
(for [[path-item content] groups]
|
(for [[path-item content] groups]
|
||||||
(when-not (empty? path-item)
|
(when-not (empty? path-item)
|
||||||
[:& colors-group {:file-id file-id
|
[:& colors-group {:file-id file-id
|
||||||
|
@ -950,24 +942,23 @@
|
||||||
:on-group on-group
|
:on-group on-group
|
||||||
:on-rename-group on-rename-group
|
:on-rename-group on-rename-group
|
||||||
:on-ungroup on-ungroup
|
:on-ungroup on-ungroup
|
||||||
:colors colors
|
:colors colors}]))])]))
|
||||||
:locale locale}]))])]))
|
|
||||||
|
|
||||||
(mf/defc colors-box
|
(mf/defc colors-box
|
||||||
[{:keys [file-id local? colors locale open? open-groups selected-assets
|
[{:keys [file-id local? colors open? open-groups selected-assets
|
||||||
on-asset-click on-assets-delete on-clear-selection] :as props}]
|
on-asset-click on-assets-delete on-clear-selection] :as props}]
|
||||||
(let [selected-colors (:colors selected-assets)
|
(let [selected-colors (:colors selected-assets)
|
||||||
multi-colors? (> (count selected-colors) 1)
|
multi-colors? (> (count selected-colors) 1)
|
||||||
multi-assets? (or (not (empty? (:components selected-assets)))
|
multi-assets? (or (seq (:components selected-assets))
|
||||||
(not (empty? (:graphics selected-assets)))
|
(seq (:graphics selected-assets))
|
||||||
(not (empty? (:typographies selected-assets))))
|
(seq (:typographies selected-assets)))
|
||||||
|
|
||||||
groups (group-assets colors)
|
groups (group-assets colors)
|
||||||
|
|
||||||
add-color
|
add-color
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps file-id)
|
(mf/deps file-id)
|
||||||
(fn [value opacity]
|
(fn [value _opacity]
|
||||||
(st/emit! (dwl/add-color value))))
|
(st/emit! (dwl/add-color value))))
|
||||||
|
|
||||||
add-color-clicked
|
add-color-clicked
|
||||||
|
@ -1072,8 +1063,7 @@
|
||||||
:on-group on-group
|
:on-group on-group
|
||||||
:on-rename-group on-rename-group
|
:on-rename-group on-rename-group
|
||||||
:on-ungroup on-ungroup
|
:on-ungroup on-ungroup
|
||||||
:colors colors
|
:colors colors}]]]))
|
||||||
:locale locale}]]]))
|
|
||||||
|
|
||||||
;; ---- Typography box ----
|
;; ---- Typography box ----
|
||||||
|
|
||||||
|
@ -1127,7 +1117,7 @@
|
||||||
:on-context-menu on-context-menu}]))])]))
|
:on-context-menu on-context-menu}]))])]))
|
||||||
|
|
||||||
(mf/defc typographies-box
|
(mf/defc typographies-box
|
||||||
[{:keys [file file-id local? typographies locale open? open-groups selected-assets
|
[{:keys [file file-id local? typographies open? open-groups selected-assets
|
||||||
on-asset-click on-assets-delete on-clear-selection] :as props}]
|
on-asset-click on-assets-delete on-clear-selection] :as props}]
|
||||||
(let [state (mf/use-state {:detail-open? false
|
(let [state (mf/use-state {:detail-open? false
|
||||||
:id nil})
|
:id nil})
|
||||||
|
@ -1140,14 +1130,14 @@
|
||||||
|
|
||||||
selected-typographies (:typographies selected-assets)
|
selected-typographies (:typographies selected-assets)
|
||||||
multi-typographies? (> (count selected-typographies) 1)
|
multi-typographies? (> (count selected-typographies) 1)
|
||||||
multi-assets? (or (not (empty? (:components selected-assets)))
|
multi-assets? (or (seq (:components selected-assets))
|
||||||
(not (empty? (:graphics selected-assets)))
|
(seq (:graphics selected-assets))
|
||||||
(not (empty? (:colors selected-assets))))
|
(seq (:colors selected-assets)))
|
||||||
|
|
||||||
add-typography
|
add-typography
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps file-id)
|
(mf/deps file-id)
|
||||||
(fn [value opacity]
|
(fn [_]
|
||||||
(st/emit! (dwl/add-typography txt/default-typography))))
|
(st/emit! (dwl/add-typography txt/default-typography))))
|
||||||
|
|
||||||
handle-change
|
handle-change
|
||||||
|
@ -1157,7 +1147,7 @@
|
||||||
(st/emit! (dwl/update-typography (merge typography changes) file-id))))
|
(st/emit! (dwl/update-typography (merge typography changes) file-id))))
|
||||||
|
|
||||||
apply-typography
|
apply-typography
|
||||||
(fn [typography event]
|
(fn [typography _event]
|
||||||
(let [ids (wsh/lookup-selected @st/state)
|
(let [ids (wsh/lookup-selected @st/state)
|
||||||
attrs (merge
|
attrs (merge
|
||||||
{:typography-ref-file file-id
|
{:typography-ref-file file-id
|
||||||
|
@ -1243,11 +1233,6 @@
|
||||||
(fn []
|
(fn []
|
||||||
(swap! menu-state close-auto-pos-menu)))
|
(swap! menu-state close-auto-pos-menu)))
|
||||||
|
|
||||||
closed-typography-edit
|
|
||||||
(mf/use-callback
|
|
||||||
(mf/deps file-id)
|
|
||||||
(fn [event] ))
|
|
||||||
|
|
||||||
handle-rename-typography-clicked
|
handle-rename-typography-clicked
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! #(assoc-in % [:workspace-local :rename-typography] (:id @state))))
|
(st/emit! #(assoc-in % [:workspace-local :rename-typography] (:id @state))))
|
||||||
|
@ -1307,10 +1292,10 @@
|
||||||
{:on-close on-close-menu
|
{:on-close on-close-menu
|
||||||
:state @menu-state
|
:state @menu-state
|
||||||
:options [(when-not (or multi-typographies? multi-assets?)
|
:options [(when-not (or multi-typographies? multi-assets?)
|
||||||
[(t locale "workspace.assets.rename") handle-rename-typography-clicked])
|
[(tr "workspace.assets.rename") handle-rename-typography-clicked])
|
||||||
(when-not (or multi-typographies? multi-assets?)
|
(when-not (or multi-typographies? multi-assets?)
|
||||||
[(t locale "workspace.assets.edit") handle-edit-typography-clicked])
|
[(tr "workspace.assets.edit") handle-edit-typography-clicked])
|
||||||
[(t locale "workspace.assets.delete") handle-delete-typography]
|
[(tr "workspace.assets.delete") handle-delete-typography]
|
||||||
(when-not multi-assets?
|
(when-not multi-assets?
|
||||||
[(tr "workspace.assets.group") on-group])]}])]]))
|
[(tr "workspace.assets.group") on-group])]}])]]))
|
||||||
|
|
||||||
|
@ -1322,7 +1307,7 @@
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [state]
|
||||||
(let [wfile (:workspace-data state)]
|
(let [wfile (:workspace-data state)]
|
||||||
(if (= (:id wfile) id)
|
(if (= (:id wfile) id)
|
||||||
(vals (get-in wfile [:colors]))
|
(vals (get wfile :colors))
|
||||||
(vals (get-in state [:workspace-libraries id :data :colors])))))
|
(vals (get-in state [:workspace-libraries id :data :colors])))))
|
||||||
st/state =))
|
st/state =))
|
||||||
|
|
||||||
|
@ -1331,7 +1316,7 @@
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [state]
|
||||||
(let [wfile (:workspace-data state)]
|
(let [wfile (:workspace-data state)]
|
||||||
(if (= (:id wfile) id)
|
(if (= (:id wfile) id)
|
||||||
(vals (get-in wfile [:media]))
|
(vals (get wfile :media))
|
||||||
(vals (get-in state [:workspace-libraries id :data :media])))))
|
(vals (get-in state [:workspace-libraries id :data :media])))))
|
||||||
st/state =))
|
st/state =))
|
||||||
|
|
||||||
|
@ -1340,7 +1325,7 @@
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [state]
|
||||||
(let [wfile (:workspace-data state)]
|
(let [wfile (:workspace-data state)]
|
||||||
(if (= (:id wfile) id)
|
(if (= (:id wfile) id)
|
||||||
(vals (get-in wfile [:components]))
|
(vals (get wfile :components))
|
||||||
(vals (get-in state [:workspace-libraries id :data :components])))))
|
(vals (get-in state [:workspace-libraries id :data :components])))))
|
||||||
st/state =))
|
st/state =))
|
||||||
|
|
||||||
|
@ -1349,7 +1334,7 @@
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [state]
|
||||||
(let [wfile (:workspace-data state)]
|
(let [wfile (:workspace-data state)]
|
||||||
(if (= (:id wfile) id)
|
(if (= (:id wfile) id)
|
||||||
(vals (get-in wfile [:typographies]))
|
(vals (get wfile :typographies))
|
||||||
(vals (get-in state [:workspace-libraries id :data :typographies])))))
|
(vals (get-in state [:workspace-libraries id :data :typographies])))))
|
||||||
st/state =))
|
st/state =))
|
||||||
|
|
||||||
|
@ -1374,7 +1359,7 @@
|
||||||
comp-fn))))
|
comp-fn))))
|
||||||
|
|
||||||
(mf/defc file-library
|
(mf/defc file-library
|
||||||
[{:keys [file local? default-open? filters locale] :as props}]
|
[{:keys [file local? default-open? filters] :as props}]
|
||||||
(let [open-file (mf/deref (open-file-ref (:id file)))
|
(let [open-file (mf/deref (open-file-ref (:id file)))
|
||||||
open? (-> open-file
|
open? (-> open-file
|
||||||
:library
|
:library
|
||||||
|
@ -1425,23 +1410,23 @@
|
||||||
|
|
||||||
toggle-sort
|
toggle-sort
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! reverse-sort? not)))
|
(swap! reverse-sort? not)))
|
||||||
|
|
||||||
toggle-listing
|
toggle-listing
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! listing-thumbs? not)))
|
(swap! listing-thumbs? not)))
|
||||||
|
|
||||||
toggle-selected-asset
|
toggle-selected-asset
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps @selected-assets)
|
(mf/deps @selected-assets)
|
||||||
(fn [asset-type asset-id]
|
(fn [asset-type asset-id]
|
||||||
(swap! selected-assets update asset-type
|
(swap! selected-assets update asset-type
|
||||||
(fn [selected]
|
(fn [selected]
|
||||||
(if (contains? selected asset-id)
|
(if (contains? selected asset-id)
|
||||||
(disj selected asset-id)
|
(disj selected asset-id)
|
||||||
(conj selected asset-id))))))
|
(conj selected asset-id))))))
|
||||||
|
|
||||||
extend-selected-assets
|
extend-selected-assets
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -1453,7 +1438,7 @@
|
||||||
(get groups "" [])
|
(get groups "" [])
|
||||||
(reduce concat
|
(reduce concat
|
||||||
[]
|
[]
|
||||||
(->> (filter #(not (empty? (first %))) groups)
|
(->> (filter #(seq (first %)) groups)
|
||||||
(map second)
|
(map second)
|
||||||
(map flatten-groups)))))]
|
(map flatten-groups)))))]
|
||||||
(swap! selected-assets update asset-type
|
(swap! selected-assets update asset-type
|
||||||
|
@ -1504,17 +1489,16 @@
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps @selected-assets)
|
(mf/deps @selected-assets)
|
||||||
(fn []
|
(fn []
|
||||||
(do
|
(st/emit! (dwu/start-undo-transaction))
|
||||||
(st/emit! (dwu/start-undo-transaction))
|
(apply st/emit! (map #(dwl/delete-component {:id %})
|
||||||
(apply st/emit! (map #(dwl/delete-component {:id %})
|
(:components @selected-assets)))
|
||||||
(:components @selected-assets)))
|
(apply st/emit! (map #(dwl/delete-media {:id %})
|
||||||
(apply st/emit! (map #(dwl/delete-media {:id %})
|
(:graphics @selected-assets)))
|
||||||
(:graphics @selected-assets)))
|
(apply st/emit! (map #(dwl/delete-color {:id %})
|
||||||
(apply st/emit! (map #(dwl/delete-color {:id %})
|
(:colors @selected-assets)))
|
||||||
(:colors @selected-assets)))
|
(apply st/emit! (map #(dwl/delete-typography %)
|
||||||
(apply st/emit! (map #(dwl/delete-typography %)
|
(:typographies @selected-assets)))
|
||||||
(:typographies @selected-assets)))
|
(st/emit! (dwu/commit-undo-transaction))))]
|
||||||
(st/emit! (dwu/commit-undo-transaction)))))]
|
|
||||||
|
|
||||||
[:div.tool-window {:on-context-menu #(dom/prevent-default %)
|
[:div.tool-window {:on-context-menu #(dom/prevent-default %)
|
||||||
:on-click unselect-all}
|
:on-click unselect-all}
|
||||||
|
@ -1526,9 +1510,9 @@
|
||||||
|
|
||||||
(if local?
|
(if local?
|
||||||
[:*
|
[:*
|
||||||
[:span (t locale "workspace.assets.file-library")]
|
[:span (tr "workspace.assets.file-library")]
|
||||||
(when shared?
|
(when shared?
|
||||||
[:span.tool-badge (t locale "workspace.assets.shared")])]
|
[:span.tool-badge (tr "workspace.assets.shared")])]
|
||||||
[:*
|
[:*
|
||||||
[:span (:name file)]
|
[:span (:name file)]
|
||||||
[:span.tool-link.tooltip.tooltip-left {:alt "Open library file"}
|
[:span.tool-link.tooltip.tooltip-left {:alt "Open library file"}
|
||||||
|
@ -1594,7 +1578,6 @@
|
||||||
(when show-colors?
|
(when show-colors?
|
||||||
[:& colors-box {:file-id (:id file)
|
[:& colors-box {:file-id (:id file)
|
||||||
:local? local?
|
:local? local?
|
||||||
:locale locale
|
|
||||||
:colors colors
|
:colors colors
|
||||||
:open? (open-box? :colors)
|
:open? (open-box? :colors)
|
||||||
:open-groups (open-groups :colors)
|
:open-groups (open-groups :colors)
|
||||||
|
@ -1607,7 +1590,6 @@
|
||||||
[:& typographies-box {:file file
|
[:& typographies-box {:file file
|
||||||
:file-id (:id file)
|
:file-id (:id file)
|
||||||
:local? local?
|
:local? local?
|
||||||
:locale locale
|
|
||||||
:typographies typographies
|
:typographies typographies
|
||||||
:open? (open-box? :typographies)
|
:open? (open-box? :typographies)
|
||||||
:open-groups (open-groups :typographies)
|
:open-groups (open-groups :typographies)
|
||||||
|
@ -1618,7 +1600,7 @@
|
||||||
|
|
||||||
(when (and (not show-components?) (not show-graphics?) (not show-colors?))
|
(when (and (not show-components?) (not show-graphics?) (not show-colors?))
|
||||||
[:div.asset-section
|
[:div.asset-section
|
||||||
[:div.asset-title (t locale "workspace.assets.not-found")]])]))]))
|
[:div.asset-title (tr "workspace.assets.not-found")]])]))]))
|
||||||
|
|
||||||
|
|
||||||
(mf/defc assets-toolbox
|
(mf/defc assets-toolbox
|
||||||
|
@ -1627,7 +1609,6 @@
|
||||||
(vals)
|
(vals)
|
||||||
(remove :is-indirect))
|
(remove :is-indirect))
|
||||||
file (mf/deref refs/workspace-file)
|
file (mf/deref refs/workspace-file)
|
||||||
locale (mf/deref i18n/locale)
|
|
||||||
team-id (mf/use-ctx ctx/current-team-id)
|
team-id (mf/use-ctx ctx/current-team-id)
|
||||||
filters (mf/use-state {:term "" :box :all})
|
filters (mf/use-state {:term "" :box :all})
|
||||||
|
|
||||||
|
@ -1641,7 +1622,7 @@
|
||||||
on-search-clear-click
|
on-search-clear-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps team-id)
|
(mf/deps team-id)
|
||||||
(fn [event]
|
(fn [_]
|
||||||
(swap! filters assoc :term "")))
|
(swap! filters assoc :term "")))
|
||||||
|
|
||||||
on-box-filter-change
|
on-box-filter-change
|
||||||
|
@ -1657,10 +1638,10 @@
|
||||||
[:div.tool-window
|
[:div.tool-window
|
||||||
[:div.tool-window-content
|
[:div.tool-window-content
|
||||||
[:div.assets-bar-title
|
[:div.assets-bar-title
|
||||||
(t locale "workspace.assets.assets")
|
(tr "workspace.assets.assets")
|
||||||
[:div.libraries-button {:on-click #(modal/show! :libraries-dialog {})}
|
[:div.libraries-button {:on-click #(modal/show! :libraries-dialog {})}
|
||||||
i/text-align-justify
|
i/text-align-justify
|
||||||
(t locale "workspace.assets.libraries")]]
|
(tr "workspace.assets.libraries")]]
|
||||||
|
|
||||||
[:div.search-block
|
[:div.search-block
|
||||||
[:input.search-input
|
[:input.search-input
|
||||||
|
@ -1677,16 +1658,15 @@
|
||||||
|
|
||||||
[:select.input-select {:value (:box @filters)
|
[:select.input-select {:value (:box @filters)
|
||||||
:on-change on-box-filter-change}
|
:on-change on-box-filter-change}
|
||||||
[:option {:value ":all"} (t locale "workspace.assets.box-filter-all")]
|
[:option {:value ":all"} (tr "workspace.assets.box-filter-all")]
|
||||||
[:option {:value ":components"} (t locale "workspace.assets.components")]
|
[:option {:value ":components"} (tr "workspace.assets.components")]
|
||||||
[:option {:value ":graphics"} (t locale "workspace.assets.graphics")]
|
[:option {:value ":graphics"} (tr "workspace.assets.graphics")]
|
||||||
[:option {:value ":colors"} (t locale "workspace.assets.colors")]
|
[:option {:value ":colors"} (tr "workspace.assets.colors")]
|
||||||
[:option {:value ":typographies"} (t locale "workspace.assets.typography")]]]]
|
[:option {:value ":typographies"} (tr "workspace.assets.typography")]]]]
|
||||||
|
|
||||||
[:div.libraries-wrapper
|
[:div.libraries-wrapper
|
||||||
[:& file-library
|
[:& file-library
|
||||||
{:file file
|
{:file file
|
||||||
:locale locale
|
|
||||||
:local? true
|
:local? true
|
||||||
:default-open? true
|
:default-open? true
|
||||||
:filters @filters}]
|
:filters @filters}]
|
||||||
|
@ -1697,7 +1677,6 @@
|
||||||
{:key (:id file)
|
{:key (:id file)
|
||||||
:file file
|
:file file
|
||||||
:local? false
|
:local? false
|
||||||
:locale locale
|
|
||||||
:default-open? false
|
:default-open? false
|
||||||
:filters @filters}])]]))
|
:filters @filters}])]]))
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,15 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.sidebar.history
|
(ns app.main.ui.workspace.sidebar.history
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.main.data.workspace :as dw]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.data :refer [read-string]]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :refer [t] :as i18n]
|
[app.util.i18n :refer [t] :as i18n]
|
||||||
[app.util.router :as r]
|
[cuerdas.core :as str]
|
||||||
[app.util.time :as dt]
|
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[app.main.store :as st]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def workspace-undo
|
(def workspace-undo
|
||||||
(l/derived :workspace-undo st/state))
|
(l/derived :workspace-undo st/state))
|
||||||
|
@ -136,7 +131,7 @@
|
||||||
i/layers))
|
i/layers))
|
||||||
|
|
||||||
(defn is-shape? [type]
|
(defn is-shape? [type]
|
||||||
#{:shape :rect :circle :text :path :frame :group})
|
(contains? #{:shape :rect :circle :text :path :frame :group} type))
|
||||||
|
|
||||||
(defn parse-entry [{:keys [redo-changes]}]
|
(defn parse-entry [{:keys [redo-changes]}]
|
||||||
(->> redo-changes
|
(->> redo-changes
|
||||||
|
@ -210,7 +205,7 @@
|
||||||
:modify (->> candidates
|
:modify (->> candidates
|
||||||
(filter #(= :modify (:operation %)))
|
(filter #(= :modify (:operation %)))
|
||||||
(group-by :id)
|
(group-by :id)
|
||||||
(d/mapm (fn [k v] (->> v
|
(d/mapm (fn [_ v] (->> v
|
||||||
(mapcat :detail)
|
(mapcat :detail)
|
||||||
(map (comp safe-name :attr))
|
(map (comp safe-name :attr))
|
||||||
(remove nil?)
|
(remove nil?)
|
||||||
|
@ -279,7 +274,7 @@
|
||||||
(mf/defc history-toolbox []
|
(mf/defc history-toolbox []
|
||||||
(let [locale (mf/deref i18n/locale)
|
(let [locale (mf/deref i18n/locale)
|
||||||
objects (mf/deref refs/workspace-page-objects)
|
objects (mf/deref refs/workspace-page-objects)
|
||||||
{:keys [items index transaction]} (mf/deref workspace-undo)
|
{:keys [items index]} (mf/deref workspace-undo)
|
||||||
entries (parse-entries items objects)]
|
entries (parse-entries items objects)]
|
||||||
[:div.history-toolbox
|
[:div.history-toolbox
|
||||||
[:div.history-toolbox-title (t locale "workspace.undo.title")]
|
[:div.history-toolbox-title (t locale "workspace.undo.title")]
|
||||||
|
|
|
@ -16,12 +16,9 @@
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [t]]
|
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.perf :as perf]
|
|
||||||
[app.util.timers :as ts]
|
[app.util.timers :as ts]
|
||||||
[beicon.core :as rx]
|
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
@ -175,7 +172,7 @@
|
||||||
(st/emit! (dw/select-shape id))))
|
(st/emit! (dw/select-shape id))))
|
||||||
|
|
||||||
on-drop
|
on-drop
|
||||||
(fn [side {:keys [id] :as data}]
|
(fn [side _data]
|
||||||
(if (= side :center)
|
(if (= side :center)
|
||||||
(st/emit! (dw/relocate-selected-shapes (:id item) 0))
|
(st/emit! (dw/relocate-selected-shapes (:id item) 0))
|
||||||
(let [to-index (if (= side :top) (inc index) index)
|
(let [to-index (if (= side :top) (inc index) index)
|
||||||
|
|
|
@ -6,13 +6,11 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.sidebar.options
|
(ns app.main.ui.workspace.sidebar.options
|
||||||
(:require
|
(:require
|
||||||
[app.common.spec :as us]
|
|
||||||
[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]
|
||||||
[app.main.ui.components.tab-container :refer [tab-container tab-element]]
|
[app.main.ui.components.tab-container :refer [tab-container tab-element]]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.icons :as i]
|
|
||||||
[app.main.ui.workspace.sidebar.align :refer [align-options]]
|
[app.main.ui.workspace.sidebar.align :refer [align-options]]
|
||||||
[app.main.ui.workspace.sidebar.options.menus.exports :refer [exports-menu]]
|
[app.main.ui.workspace.sidebar.options.menus.exports :refer [exports-menu]]
|
||||||
[app.main.ui.workspace.sidebar.options.menus.interactions :refer [interactions-menu]]
|
[app.main.ui.workspace.sidebar.options.menus.interactions :refer [interactions-menu]]
|
||||||
|
@ -26,9 +24,8 @@
|
||||||
[app.main.ui.workspace.sidebar.options.shapes.rect :as rect]
|
[app.main.ui.workspace.sidebar.options.shapes.rect :as rect]
|
||||||
[app.main.ui.workspace.sidebar.options.shapes.svg-raw :as svg-raw]
|
[app.main.ui.workspace.sidebar.options.shapes.svg-raw :as svg-raw]
|
||||||
[app.main.ui.workspace.sidebar.options.shapes.text :as text]
|
[app.main.ui.workspace.sidebar.options.shapes.text :as text]
|
||||||
[app.util.i18n :as i18n :refer [tr t]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[beicon.core :as rx]
|
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
;; --- Options
|
;; --- Options
|
||||||
|
@ -52,32 +49,30 @@
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:file-id file-id}]])
|
:file-id file-id}]])
|
||||||
|
|
||||||
|
|
||||||
(mf/defc options-content
|
(mf/defc options-content
|
||||||
{::mf/wrap [mf/memo]}
|
{::mf/wrap [mf/memo]}
|
||||||
[{:keys [selected section shapes shapes-with-children page-id file-id]}]
|
[{:keys [selected section shapes shapes-with-children page-id file-id]}]
|
||||||
(let [locale (mf/deref i18n/locale)]
|
[:div.tool-window
|
||||||
[:div.tool-window
|
[:div.tool-window-content
|
||||||
[:div.tool-window-content
|
[:& tab-container {:on-change-tab #(st/emit! (udw/set-options-mode %))
|
||||||
[:& tab-container {:on-change-tab #(st/emit! (udw/set-options-mode %))
|
:selected section}
|
||||||
:selected section}
|
[:& tab-element {:id :design
|
||||||
[:& tab-element {:id :design
|
:title (tr "workspace.options.design")}
|
||||||
:title (t locale "workspace.options.design")}
|
[:div.element-options
|
||||||
[:div.element-options
|
[:& align-options]
|
||||||
[:& align-options]
|
(case (count selected)
|
||||||
(case (count selected)
|
0 [:& page/options]
|
||||||
0 [:& page/options]
|
1 [:& shape-options {:shape (first shapes)
|
||||||
1 [:& shape-options {:shape (first shapes)
|
:page-id page-id
|
||||||
:page-id page-id
|
:file-id file-id
|
||||||
:file-id file-id
|
:shapes-with-children shapes-with-children}]
|
||||||
:shapes-with-children shapes-with-children}]
|
[:& multiple/options {:shapes-with-children shapes-with-children
|
||||||
[:& multiple/options {:shapes-with-children shapes-with-children
|
:shapes shapes}])]]
|
||||||
:shapes shapes}])]]
|
|
||||||
|
|
||||||
[:& tab-element {:id :prototype
|
[:& tab-element {:id :prototype
|
||||||
:title (t locale "workspace.options.prototype")}
|
:title (tr "workspace.options.prototype")}
|
||||||
[:div.element-options
|
[:div.element-options
|
||||||
[:& interactions-menu {:shape (first shapes)}]]]]]]))
|
[:& interactions-menu {:shape (first shapes)}]]]]]])
|
||||||
|
|
||||||
|
|
||||||
;; TODO: this need optimizations, selected-objects and
|
;; TODO: this need optimizations, selected-objects and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue