Skip to content

Commit

Permalink
Updates element wrapper style when is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecmart committed Feb 5, 2024
1 parent 38233d8 commit 943d8e4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/visualui/src/components/RenderNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ReactDOM from 'react-dom';
import { ArrowDown, Trash2, Redo, ArrowUp, Move } from 'lucide-react';

export const RenderNode = ({ render }) => {
const enableEdit = true
const { id } = useNode();
const { actions, query, isActive } = useEditor((_, query) => ({
isActive: query.getEvent('selected').contains(id),
Expand Down Expand Up @@ -46,12 +45,14 @@ export const RenderNode = ({ render }) => {
const currentRef = useRef<HTMLDivElement>();
useEffect(() => {
if (dom) {
if ((isActive || isHover) && enableEdit) {
if (isActive) {
dom.style.border = "1px solid "+ componentColor
} else if (isHover) {
dom.style.border = "1px dashed "+ componentColor
}
else dom.style.border = ""
}
}, [dom, isActive, isHover, enableEdit]);
}, [dom, isActive, isHover]);

const getPos = useCallback((dom: HTMLElement) => {
const { top, left, bottom } = dom
Expand Down Expand Up @@ -98,7 +99,7 @@ export const RenderNode = ({ render }) => {
return (
<>
{
((isHover || isActive) && enableEdit)
(isHover || isActive)
?
ReactDOM.createPortal(
<div
Expand Down

0 comments on commit 943d8e4

Please sign in to comment.