mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 22:06:10 +02:00
54 lines
1.6 KiB
Clojure
54 lines
1.6 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) UXBOX Labs SL
|
|
|
|
(ns app.main.ui.handoff.attributes.svg
|
|
(:require
|
|
[rumext.alpha :as mf]
|
|
[app.common.data :as d]
|
|
[cuerdas.core :as str]
|
|
[app.util.i18n :refer [tr]]
|
|
#_[app.common.math :as mth]
|
|
#_[app.main.ui.icons :as i]
|
|
#_[app.util.code-gen :as cg]
|
|
[app.main.ui.components.copy-button :refer [copy-button]]))
|
|
|
|
|
|
(defn map->css [attr]
|
|
(->> attr
|
|
(map (fn [[attr-key attr-value]] (str (d/name attr-key) ":" attr-value)))
|
|
(str/join "; ")))
|
|
|
|
(mf/defc svg-attr [{:keys [attr value]}]
|
|
(if (map? value)
|
|
[:*
|
|
[:div.attributes-block-title
|
|
[:div.attributes-block-title-text (d/name attr)]
|
|
[:& copy-button {:data (map->css value)}]]
|
|
|
|
(for [[attr-key attr-value] value]
|
|
[:& svg-attr {:attr attr-key :value attr-value}])]
|
|
|
|
[:div.attributes-unit-row
|
|
[:div.attributes-label (d/name attr)]
|
|
[:div.attributes-value (str value)]
|
|
[:& copy-button {:data (d/name value)}]]))
|
|
|
|
(mf/defc svg-block
|
|
[{:keys [shape]}]
|
|
[:*
|
|
(for [[attr-key attr-value] (:svg-attrs shape)]
|
|
[:& svg-attr {:attr attr-key :value attr-value}])] )
|
|
|
|
|
|
(mf/defc svg-panel
|
|
[{:keys [shapes]}]
|
|
|
|
(let [shape (first shapes)]
|
|
(when (and (:svg-attrs shape) (not (empty? (:svg-attrs shape))))
|
|
[:div.attributes-block
|
|
[:div.attributes-block-title
|
|
[:div.attributes-block-title-text (tr "workspace.sidebar.options.svg-attrs.title")]]
|
|
[:& svg-block {:shape shape}]])))
|