mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
Merge pull request #4245 from penpot/ladybenko-6799-comments-moving
🐛 Fix comments thread displacing bubbles
This commit is contained in:
commit
be22d506a8
5 changed files with 56 additions and 25 deletions
|
@ -152,16 +152,6 @@ $height-palette-max: 80px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// .workspace-loader {
|
|
||||||
// display: flex;
|
|
||||||
// justify-content: center;
|
|
||||||
// align-items: center;
|
|
||||||
|
|
||||||
// svg {
|
|
||||||
// fill: $color-gray-50;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
.workspace-content {
|
.workspace-content {
|
||||||
background-color: $color-canvas;
|
background-color: $color-canvas;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -242,20 +232,22 @@ $height-palette-max: 80px;
|
||||||
|
|
||||||
.viewport-overlays {
|
.viewport-overlays {
|
||||||
cursor: initial;
|
cursor: initial;
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
|
||||||
.pixel-overlay {
|
.pixel-overlay {
|
||||||
height: 100%;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
pointer-events: initial;
|
pointer-events: initial;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,22 +355,41 @@
|
||||||
[thread-id]
|
[thread-id]
|
||||||
(l/derived (l/in [:comments thread-id]) st/state))
|
(l/derived (l/in [:comments thread-id]) st/state))
|
||||||
|
|
||||||
|
(defn- offset-position [position viewport zoom bubble-margin]
|
||||||
|
(let [base-x (+ (* (:x position) zoom) (:offset-x viewport))
|
||||||
|
base-y (+ (* (:y position) zoom) (:offset-y viewport))
|
||||||
|
w (:width viewport)
|
||||||
|
h (:height viewport)
|
||||||
|
comment-width 284 ;; TODO: this is the width set via CSS in an outer container…
|
||||||
|
;; We should probably do this in a different way.
|
||||||
|
orientation-left? (>= (+ base-x comment-width (:x bubble-margin)) w)
|
||||||
|
orientation-top? (>= base-y (/ h 2))
|
||||||
|
h-dir (if orientation-left? :left :right)
|
||||||
|
v-dir (if orientation-top? :top :bottom)
|
||||||
|
x (:x position)
|
||||||
|
y (:y position)]
|
||||||
|
{:x x :y y :h-dir h-dir :v-dir v-dir}))
|
||||||
|
|
||||||
(mf/defc thread-comments
|
(mf/defc thread-comments
|
||||||
{::mf/wrap [mf/memo]}
|
{::mf/wrap [mf/memo]}
|
||||||
[{:keys [thread zoom users origin position-modifier]}]
|
[{:keys [thread zoom users origin position-modifier viewport]}]
|
||||||
(let [ref (mf/use-ref)
|
(let [ref (mf/use-ref)
|
||||||
|
|
||||||
|
|
||||||
thread-id (:id thread)
|
thread-id (:id thread)
|
||||||
thread-pos (:position thread)
|
thread-pos (:position thread)
|
||||||
|
|
||||||
pos (cond-> thread-pos
|
base-pos (cond-> thread-pos
|
||||||
(some? position-modifier)
|
(some? position-modifier)
|
||||||
(gpt/transform position-modifier))
|
(gpt/transform position-modifier))
|
||||||
|
|
||||||
pos-x (+ (* (:x pos) zoom) 24)
|
max-height (int (* (:height viewport) 0.75))
|
||||||
pos-y (- (* (:y pos) zoom) 28)
|
;; We should probably look for a better way of doing this.
|
||||||
|
bubble-margin {:x 24 :y 0}
|
||||||
|
pos (offset-position base-pos viewport zoom bubble-margin)
|
||||||
|
|
||||||
|
margin-x (* (:x bubble-margin) (if (= (:h-dir pos) :left) -1 1))
|
||||||
|
margin-y (* (:y bubble-margin) (if (= (:v-dir pos) :top) -1 1))
|
||||||
|
pos-x (+ (* (:x pos) zoom) margin-x)
|
||||||
|
pos-y (- (* (:y pos) zoom) margin-y)
|
||||||
|
|
||||||
comments-ref (mf/with-memo [thread-id]
|
comments-ref (mf/with-memo [thread-id]
|
||||||
(make-comments-ref thread-id))
|
(make-comments-ref thread-id))
|
||||||
|
@ -393,9 +412,14 @@
|
||||||
(dom/scroll-into-view-if-needed! node)))
|
(dom/scroll-into-view-if-needed! node)))
|
||||||
|
|
||||||
(when (some? comment)
|
(when (some? comment)
|
||||||
[:div {:class (stl/css :thread-content)
|
[:div {:class (stl/css-case :thread-content true
|
||||||
:style {:top (str pos-y "px")
|
:thread-content-left (= (:h-dir pos) :left)
|
||||||
:left (str pos-x "px")}
|
:thread-content-top (= (:v-dir pos) :top))
|
||||||
|
:id (str "thread-" thread-id)
|
||||||
|
:style {:left (str pos-x "px")
|
||||||
|
:top (str pos-y "px")
|
||||||
|
:max-height max-height
|
||||||
|
:overflow-y "scroll"}
|
||||||
:on-click dom/stop-propagation}
|
:on-click dom/stop-propagation}
|
||||||
|
|
||||||
[:div {:class (stl/css :comments)}
|
[:div {:class (stl/css :comments)}
|
||||||
|
|
|
@ -140,6 +140,9 @@
|
||||||
border-radius: $br-8;
|
border-radius: $br-8;
|
||||||
border: $s-2 solid var(--modal-border-color);
|
border: $s-2 solid var(--modal-border-color);
|
||||||
background-color: var(--comment-modal-background-color);
|
background-color: var(--comment-modal-background-color);
|
||||||
|
--translate-x: 0%;
|
||||||
|
--translate-y: 0%;
|
||||||
|
transform: translate(var(--translate-x), var(--translate-y));
|
||||||
.comments {
|
.comments {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -147,6 +150,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.thread-content-left {
|
||||||
|
--translate-x: -100%;
|
||||||
|
}
|
||||||
|
.thread-content-top {
|
||||||
|
--translate-y: -100%;
|
||||||
|
}
|
||||||
|
|
||||||
// comment-item
|
// comment-item
|
||||||
|
|
||||||
.comment-container {
|
.comment-container {
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
(when (seq (dcm/apply-filters local profile [thread]))
|
(when (seq (dcm/apply-filters local profile [thread]))
|
||||||
[:& cmt/thread-comments {:thread (update-position positions thread)
|
[:& cmt/thread-comments {:thread (update-position positions thread)
|
||||||
:users users
|
:users users
|
||||||
|
:viewport {:offset-x pos-x :offset-y pos-y :width (:width vport) :height (:height vport)}
|
||||||
:zoom zoom}])))
|
:zoom zoom}])))
|
||||||
|
|
||||||
(when-let [draft (:comment drawing)]
|
(when-let [draft (:comment drawing)]
|
||||||
|
@ -91,3 +92,4 @@
|
||||||
:on-cancel on-draft-cancel
|
:on-cancel on-draft-cancel
|
||||||
:on-submit on-draft-submit
|
:on-submit on-draft-submit
|
||||||
:zoom zoom}])]]]))
|
:zoom zoom}])]]]))
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,13 @@
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
user-select: text;
|
user-select: text;
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.threads {
|
.threads {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: $s-0;
|
top: 0;
|
||||||
left: $s-0;
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue