mirror of
https://github.com/penpot/penpot.git
synced 2026-05-30 04:08:08 +00:00
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]]
|
[app.util.i18n :refer [tr]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn has-blur? [shape]
|
(defn- has-blur? [shape]
|
||||||
(:blur shape))
|
(:blur shape))
|
||||||
|
|
||||||
(mf/defc blur-panel
|
(mf/defc blur-panel
|
||||||
|
|||||||
@ -14,9 +14,9 @@
|
|||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[rumext.v2 :as mf]))
|
[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
|
(and
|
||||||
(not (contains? #{:text :group} (:type shape)))
|
(not (contains? #{:text :group} (:type shape)))
|
||||||
(or (:fill-color shape)
|
(or (:fill-color shape)
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def properties
|
(def ^:private properties
|
||||||
[:width
|
[:width
|
||||||
:height
|
:height
|
||||||
:left
|
:left
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
[app.util.code-gen.style-css :as css]
|
[app.util.code-gen.style-css :as css]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def properties
|
(def ^:private properties
|
||||||
[:display
|
[:display
|
||||||
:flex-direction
|
:flex-direction
|
||||||
:flex-wrap
|
:flex-wrap
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
[app.util.code-gen.style-css :as css]
|
[app.util.code-gen.style-css :as css]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def properties
|
(def ^:private properties
|
||||||
[:margin
|
[:margin
|
||||||
:max-height
|
:max-height
|
||||||
:min-height
|
:min-height
|
||||||
|
|||||||
@ -14,16 +14,12 @@
|
|||||||
[app.main.ui.inspect.attributes.common :refer [color-row]]
|
[app.main.ui.inspect.attributes.common :refer [color-row]]
|
||||||
[app.util.code-gen.style-css :as css]
|
[app.util.code-gen.style-css :as css]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[cuerdas.core :as str]
|
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn has-shadow? [shape]
|
(defn- has-shadow? [shape]
|
||||||
(:shadow shape))
|
(:shadow shape))
|
||||||
|
|
||||||
(defn shape-copy-data [shape]
|
(defn- shadow-copy-data [shadow]
|
||||||
(str/join ", " (map css/shadow->css (:shadow shape))))
|
|
||||||
|
|
||||||
(defn shadow-copy-data [shadow]
|
|
||||||
(css/shadow->css shadow))
|
(css/shadow->css shadow))
|
||||||
|
|
||||||
(mf/defc shadow-block [{:keys [shadow]}]
|
(mf/defc shadow-block [{:keys [shadow]}]
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def properties [:border])
|
(def ^:private properties [:border])
|
||||||
|
|
||||||
(defn stroke->color [shape]
|
(defn- stroke->color [shape]
|
||||||
{:color (:stroke-color shape)
|
{:color (:stroke-color shape)
|
||||||
:opacity (:stroke-opacity shape)
|
:opacity (:stroke-opacity shape)
|
||||||
:gradient (:stroke-color-gradient shape)
|
:gradient (:stroke-color-gradient shape)
|
||||||
@ -23,7 +23,7 @@
|
|||||||
:file-id (:stroke-color-ref-file shape)
|
:file-id (:stroke-color-ref-file shape)
|
||||||
:image (:stroke-image shape)})
|
:image (:stroke-image shape)})
|
||||||
|
|
||||||
(defn has-stroke? [shape]
|
(defn- has-stroke? [shape]
|
||||||
(seq (:strokes shape)))
|
(seq (:strokes shape)))
|
||||||
|
|
||||||
(mf/defc stroke-block
|
(mf/defc stroke-block
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn map->css [attr]
|
(defn- map->css [attr]
|
||||||
(->> attr
|
(->> attr
|
||||||
(map (fn [[attr-key attr-value]] (str (d/name attr-key) ":" attr-value)))
|
(map (fn [[attr-key attr-value]] (str (d/name attr-key) ":" attr-value)))
|
||||||
(str/join "; ")))
|
(str/join "; ")))
|
||||||
|
|||||||
@ -23,19 +23,19 @@
|
|||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn has-text? [shape]
|
(defn- has-text? [shape]
|
||||||
(:content shape))
|
(:content shape))
|
||||||
|
|
||||||
(def file-typographies-ref
|
(def ^:private file-typographies-ref
|
||||||
(l/derived (l/in [:viewer :file :data :typographies]) st/state))
|
(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
|
(let [get-library
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(get-in state [:viewer-libraries file-id :data :typographies]))]
|
(get-in state [:viewer-libraries file-id :data :typographies]))]
|
||||||
#(l/derived get-library st/state)))
|
#(l/derived get-library st/state)))
|
||||||
|
|
||||||
(defn copy-style-data
|
(defn- copy-style-data
|
||||||
[style & properties]
|
[style & properties]
|
||||||
(->> properties
|
(->> properties
|
||||||
(map #(dm/str (d/name %) ": " (get style %) ";"))
|
(map #(dm/str (d/name %) ": " (get style %) ";"))
|
||||||
|
|||||||
@ -14,12 +14,12 @@
|
|||||||
[app.util.code-gen.style-css :as css]
|
[app.util.code-gen.style-css :as css]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def properties
|
(def ^:private properties
|
||||||
[:opacity
|
[:opacity
|
||||||
:blend-mode
|
:blend-mode
|
||||||
:visibility])
|
:visibility])
|
||||||
|
|
||||||
(defn has-visibility-props? [shape]
|
(defn- has-visibility-props? [shape]
|
||||||
(let [shape-type (:type shape)]
|
(let [shape-type (:type shape)]
|
||||||
(and
|
(and
|
||||||
(not (or (= shape-type :text) (= shape-type :group)))
|
(not (or (= shape-type :text) (= shape-type :group)))
|
||||||
@ -44,7 +44,8 @@
|
|||||||
|
|
||||||
(mf/defc visibility-panel*
|
(mf/defc visibility-panel*
|
||||||
[{:keys [objects shapes]}]
|
[{: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)
|
(when (seq shapes)
|
||||||
[:div {:class (stl/css :attributes-block)}
|
[:div {:class (stl/css :attributes-block)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user