mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 17:36:10 +02:00
✨ Remove cl-format usage from cursors.
This commit is contained in:
parent
5a17237015
commit
1d08bac493
2 changed files with 27 additions and 28 deletions
|
@ -8,11 +8,10 @@
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.main.ui.cursors
|
(ns app.main.ui.cursors
|
||||||
(:import java.net.URLEncoder)
|
(:require
|
||||||
(:require [rumext.alpha]
|
[clojure.java.io :as io]
|
||||||
[clojure.java.io :as io]
|
[cuerdas.core :as str]
|
||||||
[lambdaisland.uri.normalize :as uri]
|
[lambdaisland.uri.normalize :as uri]))
|
||||||
[cuerdas.core :as str]))
|
|
||||||
|
|
||||||
(def cursor-folder "images/cursors")
|
(def cursor-folder "images/cursors")
|
||||||
|
|
||||||
|
@ -55,22 +54,18 @@
|
||||||
|
|
||||||
(defn encode-svg-cursor
|
(defn encode-svg-cursor
|
||||||
[id rotation x y height]
|
[id rotation x y height]
|
||||||
(let [svg-path (str cursor-folder "/" (name id) ".svg")
|
(let [svg-path (str cursor-folder "/" (name id) ".svg")
|
||||||
data (-> svg-path io/resource slurp parse-svg uri/percent-encode)
|
data (-> svg-path io/resource slurp parse-svg uri/percent-encode)
|
||||||
transform (if rotation (str " transform='rotate(" rotation ")'") "")
|
transform (if rotation (str " transform='rotate(" rotation ")'") "")]
|
||||||
data (clojure.pprint/cl-format
|
(str "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='20px' "
|
||||||
nil
|
"height='" height "px' " transform "%3E" data "%3C/svg%3E\") " x " " y ", auto")))
|
||||||
"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='20px' height='~Apx'~A%3E~A%3C/svg%3E\") ~A ~A, auto"
|
|
||||||
height transform data x y )]
|
|
||||||
data))
|
|
||||||
|
|
||||||
(defmacro cursor-ref
|
(defmacro cursor-ref
|
||||||
"Creates a static cursor given its name, rotation and x/y hotspot"
|
"Creates a static cursor given its name, rotation and x/y hotspot"
|
||||||
([id] (encode-svg-cursor id default-rotation default-hotspot-x default-hotspot-y default-height))
|
([id] (encode-svg-cursor id default-rotation default-hotspot-x default-hotspot-y default-height))
|
||||||
([id rotation] (encode-svg-cursor id rotation default-hotspot-x default-hotspot-y default-height))
|
([id rotation] (encode-svg-cursor id rotation default-hotspot-x default-hotspot-y default-height))
|
||||||
([id rotation x y] (encode-svg-cursor id rotation x y default-height))
|
([id rotation x y] (encode-svg-cursor id rotation x y default-height))
|
||||||
([id rotation x y height] (encode-svg-cursor id rotation x y height))
|
([id rotation x y height] (encode-svg-cursor id rotation x y height)))
|
||||||
)
|
|
||||||
|
|
||||||
(defmacro cursor-fn
|
(defmacro cursor-fn
|
||||||
"Creates a dynamic cursor that can be rotated in runtime"
|
"Creates a dynamic cursor that can be rotated in runtime"
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[app.util.timers :as ts]))
|
[app.util.timers :as ts]))
|
||||||
|
|
||||||
|
;; Static cursors
|
||||||
|
(def comments (cursor-ref :comments 0 2 20))
|
||||||
(def create-artboard (cursor-ref :create-artboard))
|
(def create-artboard (cursor-ref :create-artboard))
|
||||||
(def create-ellipse (cursor-ref :create-ellipse))
|
(def create-ellipse (cursor-ref :create-ellipse))
|
||||||
(def create-polygon (cursor-ref :create-polygon))
|
(def create-polygon (cursor-ref :create-polygon))
|
||||||
|
@ -21,21 +23,23 @@
|
||||||
(def duplicate (cursor-ref :duplicate 0 0 0))
|
(def duplicate (cursor-ref :duplicate 0 0 0))
|
||||||
(def hand (cursor-ref :hand))
|
(def hand (cursor-ref :hand))
|
||||||
(def move-pointer (cursor-ref :move-pointer))
|
(def move-pointer (cursor-ref :move-pointer))
|
||||||
(def pencil (cursor-ref :pencil 0 0 24))
|
|
||||||
(def pen (cursor-ref :pen 0 0 0))
|
(def pen (cursor-ref :pen 0 0 0))
|
||||||
(def pointer-inner (cursor-ref :pointer-inner 0 0 0))
|
|
||||||
(def resize-alt (cursor-ref :resize-alt))
|
|
||||||
(def resize-nesw (cursor-fn :resize-h 45))
|
|
||||||
(def resize-nwse (cursor-fn :resize-h 135))
|
|
||||||
(def resize-ew (cursor-fn :resize-h 0))
|
|
||||||
(def resize-ns (cursor-fn :resize-h 90))
|
|
||||||
(def rotate (cursor-fn :rotate 90))
|
|
||||||
(def text (cursor-ref :text))
|
|
||||||
(def picker (cursor-ref :picker 0 0 24))
|
|
||||||
(def pointer-node (cursor-ref :pointer-node 0 0 10 32))
|
|
||||||
(def pointer-move (cursor-ref :pointer-move 0 0 10 42))
|
|
||||||
(def pen-node (cursor-ref :pen-node 0 0 10 36))
|
(def pen-node (cursor-ref :pen-node 0 0 10 36))
|
||||||
(def comments (cursor-ref :comments 0 2 20))
|
(def pencil (cursor-ref :pencil 0 0 24))
|
||||||
|
(def picker (cursor-ref :picker 0 0 24))
|
||||||
|
(def pointer-inner (cursor-ref :pointer-inner 0 0 0))
|
||||||
|
(def pointer-move (cursor-ref :pointer-move 0 0 10 42))
|
||||||
|
(def pointer-node (cursor-ref :pointer-node 0 0 10 32))
|
||||||
|
(def resize-alt (cursor-ref :resize-alt))
|
||||||
|
(def text (cursor-ref :text))
|
||||||
|
|
||||||
|
;; Dynamic cursors
|
||||||
|
(def resize-ew (cursor-fn :resize-h 0))
|
||||||
|
(def resize-nesw (cursor-fn :resize-h 45))
|
||||||
|
(def resize-ns (cursor-fn :resize-h 90))
|
||||||
|
(def resize-nwse (cursor-fn :resize-h 135))
|
||||||
|
(def rotate (cursor-fn :rotate 90))
|
||||||
|
|
||||||
|
|
||||||
(mf/defc debug-preview
|
(mf/defc debug-preview
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue