mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 04:21:39 +02:00
Adding initial tooltip support
This commit is contained in:
parent
177fa4621c
commit
7264cd5437
5 changed files with 46 additions and 1 deletions
|
@ -46,6 +46,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cursor-tooltip {
|
||||||
|
background-color: $color-dark-bg;
|
||||||
|
border-radius: $br-small;
|
||||||
|
color: $color-white;
|
||||||
|
font-size: $fs14;
|
||||||
|
padding: 3px 8px;
|
||||||
|
transition: none;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.workspace-canvas {
|
.workspace-canvas {
|
||||||
height: calc(100vh - 50px);
|
height: calc(100vh - 50px);
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
|
|
|
@ -204,6 +204,17 @@
|
||||||
[]
|
[]
|
||||||
(ResetZoom.))
|
(ResetZoom.))
|
||||||
|
|
||||||
|
;; --- Set tooltip
|
||||||
|
|
||||||
|
(defrecord SetTooltip [text]
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(assoc-in state [:workspace :tooltip] text)))
|
||||||
|
|
||||||
|
(defn set-tooltip
|
||||||
|
[text]
|
||||||
|
(SetTooltip. text))
|
||||||
|
|
||||||
;; --- Initialize Alignment Index
|
;; --- Initialize Alignment Index
|
||||||
|
|
||||||
(declare initialize-alignment?)
|
(declare initialize-alignment?)
|
||||||
|
|
|
@ -119,6 +119,9 @@
|
||||||
(rx/map :window-coords)
|
(rx/map :window-coords)
|
||||||
(rx/share)))
|
(rx/share)))
|
||||||
|
|
||||||
|
(defonce mouse-absolute-a
|
||||||
|
(rx/to-atom mouse-absolute-s))
|
||||||
|
|
||||||
(defonce mouse-ctrl-s
|
(defonce mouse-ctrl-s
|
||||||
(->> mouse-s
|
(->> mouse-s
|
||||||
(rx/map :ctrl)
|
(rx/map :ctrl)
|
||||||
|
|
|
@ -55,6 +55,17 @@
|
||||||
[:span {:alt "y"}
|
[:span {:alt "y"}
|
||||||
(str "Y: " (:y coords "-"))]]))
|
(str "Y: " (:y coords "-"))]]))
|
||||||
|
|
||||||
|
(mx/defc cursor-tooltip
|
||||||
|
{:mixins [mx/reactive mx/static]}
|
||||||
|
[tooltip]
|
||||||
|
(let [coords (mx/react wb/mouse-absolute-a)]
|
||||||
|
[:span.cursor-tooltip
|
||||||
|
{:style
|
||||||
|
{:position "fixed"
|
||||||
|
:left (str (+ (:x coords) 5) "px")
|
||||||
|
:top (str (- (:y coords) 25) "px")}}
|
||||||
|
tooltip]))
|
||||||
|
|
||||||
;; --- Canvas
|
;; --- Canvas
|
||||||
|
|
||||||
(mx/defc canvas
|
(mx/defc canvas
|
||||||
|
@ -153,6 +164,7 @@
|
||||||
page (mx/react wb/page-ref)
|
page (mx/react wb/page-ref)
|
||||||
flags (:flags workspace)
|
flags (:flags workspace)
|
||||||
drawing? (:drawing workspace)
|
drawing? (:drawing workspace)
|
||||||
|
tooltip (:tooltip workspace)
|
||||||
zoom (or (:zoom workspace) 1)]
|
zoom (or (:zoom workspace) 1)]
|
||||||
(letfn [(on-mouse-down [event]
|
(letfn [(on-mouse-down [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
@ -188,6 +200,8 @@
|
||||||
(rx/push! wb/events-b [:mouse/double-click opts])))]
|
(rx/push! wb/events-b [:mouse/double-click opts])))]
|
||||||
[:div
|
[:div
|
||||||
(coordinates)
|
(coordinates)
|
||||||
|
(when tooltip
|
||||||
|
(cursor-tooltip tooltip))
|
||||||
[:svg.viewport {:width (* c/viewport-width zoom)
|
[:svg.viewport {:width (* c/viewport-width zoom)
|
||||||
:height (* c/viewport-height zoom)
|
:height (* c/viewport-height zoom)
|
||||||
:ref "viewport"
|
:ref "viewport"
|
||||||
|
|
|
@ -81,7 +81,12 @@
|
||||||
(letfn [(on-click [event]
|
(letfn [(on-click [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(swap! drawing-shape drop-last-point)
|
(swap! drawing-shape drop-last-point)
|
||||||
|
(st/emit! (udw/set-tooltip nil))
|
||||||
(rx/push! drawing-stoper true))
|
(rx/push! drawing-stoper true))
|
||||||
|
(on-mouse-enter [event]
|
||||||
|
(st/emit! (udw/set-tooltip "Click to close the path")))
|
||||||
|
(on-mouse-leave [event]
|
||||||
|
(st/emit! (udw/set-tooltip nil)))
|
||||||
(drop-last-point [shape]
|
(drop-last-point [shape]
|
||||||
(let [points (:points shape)
|
(let [points (:points shape)
|
||||||
points (vec (butlast points))]
|
points (vec (butlast points))]
|
||||||
|
@ -94,7 +99,9 @@
|
||||||
[:circle.close-bezier {:cx x
|
[:circle.close-bezier {:cx x
|
||||||
:cy y
|
:cy y
|
||||||
:r 5
|
:r 5
|
||||||
:on-click on-click}])])))
|
:on-click on-click
|
||||||
|
:on-mouse-enter on-mouse-enter
|
||||||
|
:on-mouse-leave on-mouse-leave}])])))
|
||||||
|
|
||||||
;; --- Drawing Initialization
|
;; --- Drawing Initialization
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue