0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🎉 Add a label to frames in workspace.

This commit is contained in:
Andrés Moya 2020-03-25 12:15:27 +01:00 committed by Andrey Antukh
parent 002f736b97
commit 461e003805
2 changed files with 22 additions and 0 deletions

View file

@ -173,3 +173,13 @@
}
}
.workspace-frame-label {
fill: $color-gray-dark;
font-size: $fs12;
}
.selected .workspace-frame-label {
fill: $color-primary-dark;
}

View file

@ -94,9 +94,14 @@
on-mouse-down #(common/on-mouse-down % shape)
on-context-menu #(common/on-context-menu % shape)
shape (merge frame-default-props shape)
{:keys [x y width height]} shape
childs (mapv #(get objects %) (:shapes shape))
ds-modifier (:displacement-modifier shape)
label-pos (cond-> (gpt/point x (- y 10))
(gmt/matrix? ds-modifier) (gpt/transform ds-modifier))
on-double-click
(fn [event]
(dom/prevent-default event)
@ -106,6 +111,13 @@
:on-context-menu on-context-menu
:on-double-click on-double-click
:on-mouse-down on-mouse-down}
[:text {:x (:x label-pos)
:y (:y label-pos)
:width width
:height 20
:class-name "workspace-frame-label"
:on-click on-double-click} ; user may also select with single click in the label
(:name shape)]
[:& frame-shape {:shape shape :childs childs}]])))
(mf/defc frame-shape