penpot/frontend/src/app/util/code_gen/markup_svg.cljs
2023-07-10 14:49:25 +02:00

27 lines
683 B
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) KALEIDOS INC
(ns app.util.code-gen.markup-svg
(:require
["react-dom/server" :as rds]
[app.main.render :as render]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
(defn generate-svg
[objects shape]
(rds/renderToStaticMarkup
(mf/element
render/object-svg
#js {:objects objects
:object-id (-> shape :id)})))
(defn generate-markup
[objects shapes]
(->> shapes
(map #(generate-svg objects %))
(str/join "\n")))