mirror of https://github.com/penpot/penpot.git
Merge pull request #6882 from penpot/xaviju-11283-info-tab-visibility-attrs-review
♻️ Fix tab info not updating and suggested code refactor
This commit is contained in:
commit
95cfb26b38
|
|
@ -14,7 +14,7 @@
|
|||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn has-blur? [shape]
|
||||
(defn- has-blur? [shape]
|
||||
(:blur shape))
|
||||
|
||||
(mf/defc blur-panel
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties [:background :background-color :background-image])
|
||||
(def ^:private properties [:background :background-color :background-image])
|
||||
|
||||
(defn has-fill? [shape]
|
||||
(defn- has-fill? [shape]
|
||||
(and
|
||||
(not (contains? #{:text :group} (:type shape)))
|
||||
(or (:fill-color shape)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties
|
||||
(def ^:private properties
|
||||
[:width
|
||||
:height
|
||||
:left
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
[app.util.code-gen.style-css :as css]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties
|
||||
(def ^:private properties
|
||||
[:display
|
||||
:flex-direction
|
||||
:flex-wrap
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
[app.util.code-gen.style-css :as css]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties
|
||||
(def ^:private properties
|
||||
[:margin
|
||||
:max-height
|
||||
:min-height
|
||||
|
|
|
|||
|
|
@ -14,16 +14,12 @@
|
|||
[app.main.ui.inspect.attributes.common :refer [color-row]]
|
||||
[app.util.code-gen.style-css :as css]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn has-shadow? [shape]
|
||||
(defn- has-shadow? [shape]
|
||||
(:shadow shape))
|
||||
|
||||
(defn shape-copy-data [shape]
|
||||
(str/join ", " (map css/shadow->css (:shadow shape))))
|
||||
|
||||
(defn shadow-copy-data [shadow]
|
||||
(defn- shadow-copy-data [shadow]
|
||||
(css/shadow->css shadow))
|
||||
|
||||
(mf/defc shadow-block [{:keys [shadow]}]
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties [:border])
|
||||
(def ^:private properties [:border])
|
||||
|
||||
(defn stroke->color [shape]
|
||||
(defn- stroke->color [shape]
|
||||
{:color (:stroke-color shape)
|
||||
:opacity (:stroke-opacity shape)
|
||||
:gradient (:stroke-color-gradient shape)
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
:file-id (:stroke-color-ref-file shape)
|
||||
:image (:stroke-image shape)})
|
||||
|
||||
(defn has-stroke? [shape]
|
||||
(defn- has-stroke? [shape]
|
||||
(seq (:strokes shape)))
|
||||
|
||||
(mf/defc stroke-block
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn map->css [attr]
|
||||
(defn- map->css [attr]
|
||||
(->> attr
|
||||
(map (fn [[attr-key attr-value]] (str (d/name attr-key) ":" attr-value)))
|
||||
(str/join "; ")))
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@
|
|||
[okulary.core :as l]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn has-text? [shape]
|
||||
(defn- has-text? [shape]
|
||||
(:content shape))
|
||||
|
||||
(def file-typographies-ref
|
||||
(def ^:private file-typographies-ref
|
||||
(l/derived (l/in [:viewer :file :data :typographies]) st/state))
|
||||
|
||||
(defn make-typographies-library-ref [file-id]
|
||||
(defn- make-typographies-library-ref [file-id]
|
||||
(let [get-library
|
||||
(fn [state]
|
||||
(get-in state [:viewer-libraries file-id :data :typographies]))]
|
||||
#(l/derived get-library st/state)))
|
||||
|
||||
(defn copy-style-data
|
||||
(defn- copy-style-data
|
||||
[style & properties]
|
||||
(->> properties
|
||||
(map #(dm/str (d/name %) ": " (get style %) ";"))
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
[app.util.code-gen.style-css :as css]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def properties
|
||||
(def ^:private properties
|
||||
[:opacity
|
||||
:blend-mode
|
||||
:visibility])
|
||||
|
||||
(defn has-visibility-props? [shape]
|
||||
(defn- has-visibility-props? [shape]
|
||||
(let [shape-type (:type shape)]
|
||||
(and
|
||||
(not (or (= shape-type :text) (= shape-type :group)))
|
||||
|
|
@ -44,7 +44,8 @@
|
|||
|
||||
(mf/defc visibility-panel*
|
||||
[{:keys [objects shapes]}]
|
||||
(let [shapes (mf/with-memo (filter has-visibility-props? shapes))]
|
||||
(let [shapes (mf/with-memo [shapes]
|
||||
(filter has-visibility-props? shapes))]
|
||||
|
||||
(when (seq shapes)
|
||||
[:div {:class (stl/css :attributes-block)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue