feat: Add core components and styling for the new simulation dashboard editor.
This commit is contained in:
@@ -59,7 +59,6 @@ const DashboardEditor: React.FC = () => {
|
|||||||
peekUpdateCommonValue,
|
peekUpdateCommonValue,
|
||||||
peekUpdateDataValue,
|
peekUpdateDataValue,
|
||||||
peekUpdateDataSource,
|
peekUpdateDataSource,
|
||||||
|
|
||||||
} = simulationDashBoardStore();
|
} = simulationDashBoardStore();
|
||||||
|
|
||||||
const [editMode, setEditMode] = useState(false);
|
const [editMode, setEditMode] = useState(false);
|
||||||
@@ -209,6 +208,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
const elementToDrag = document.querySelector(`[data-element-id="${draggingElement}"]`) as HTMLElement;
|
const elementToDrag = document.querySelector(`[data-element-id="${draggingElement}"]`) as HTMLElement;
|
||||||
|
|
||||||
if (blockElement && elementToDrag) {
|
if (blockElement && elementToDrag) {
|
||||||
|
// Disable transitions during drag
|
||||||
|
elementToDrag.classList.add("no-transition");
|
||||||
|
|
||||||
const blockRect = blockElement.getBoundingClientRect();
|
const blockRect = blockElement.getBoundingClientRect();
|
||||||
const elementRect = elementToDrag.getBoundingClientRect();
|
const elementRect = elementToDrag.getBoundingClientRect();
|
||||||
const newX = e.clientX - blockRect.left - elementDragOffset.x;
|
const newX = e.clientX - blockRect.left - elementDragOffset.x;
|
||||||
@@ -233,6 +235,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
const blockToDrag = document.querySelector(`[data-block-id="${draggingBlock}"]`) as HTMLElement;
|
const blockToDrag = document.querySelector(`[data-block-id="${draggingBlock}"]`) as HTMLElement;
|
||||||
|
|
||||||
if (editorElement && blockToDrag) {
|
if (editorElement && blockToDrag) {
|
||||||
|
// Disable transitions during drag
|
||||||
|
blockToDrag.classList.add("no-transition");
|
||||||
|
|
||||||
const editorRect = editorElement.getBoundingClientRect();
|
const editorRect = editorElement.getBoundingClientRect();
|
||||||
const newX = e.clientX - editorRect.left - blockDragOffset.x;
|
const newX = e.clientX - editorRect.left - blockDragOffset.x;
|
||||||
const newY = e.clientY - editorRect.top - blockDragOffset.y;
|
const newY = e.clientY - editorRect.top - blockDragOffset.y;
|
||||||
@@ -248,6 +253,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
if (resizingElement && selectedBlock) {
|
if (resizingElement && selectedBlock) {
|
||||||
const elementToResize = document.querySelector(`[data-element-id="${resizingElement}"]`) as HTMLElement;
|
const elementToResize = document.querySelector(`[data-element-id="${resizingElement}"]`) as HTMLElement;
|
||||||
if (elementToResize) {
|
if (elementToResize) {
|
||||||
|
// Disable transitions during resize
|
||||||
|
elementToResize.classList.add("no-transition");
|
||||||
|
|
||||||
const deltaX = e.clientX - resizeStart.x;
|
const deltaX = e.clientX - resizeStart.x;
|
||||||
const deltaY = e.clientY - resizeStart.y;
|
const deltaY = e.clientY - resizeStart.y;
|
||||||
|
|
||||||
@@ -280,6 +288,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
} else if (resizingBlock) {
|
} else if (resizingBlock) {
|
||||||
const blockToResize = document.querySelector(`[data-block-id="${resizingBlock}"]`) as HTMLElement;
|
const blockToResize = document.querySelector(`[data-block-id="${resizingBlock}"]`) as HTMLElement;
|
||||||
if (blockToResize) {
|
if (blockToResize) {
|
||||||
|
// Disable transitions during resize
|
||||||
|
blockToResize.classList.add("no-transition");
|
||||||
|
|
||||||
const deltaX = e.clientX - resizeStart.x;
|
const deltaX = e.clientX - resizeStart.x;
|
||||||
const deltaY = e.clientY - resizeStart.y;
|
const deltaY = e.clientY - resizeStart.y;
|
||||||
|
|
||||||
@@ -328,6 +339,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
const elementToDrag = document.querySelector(`[data-element-id="${draggingElement}"]`) as HTMLElement;
|
const elementToDrag = document.querySelector(`[data-element-id="${draggingElement}"]`) as HTMLElement;
|
||||||
|
|
||||||
if (blockElement && elementToDrag) {
|
if (blockElement && elementToDrag) {
|
||||||
|
// Re-enable transitions
|
||||||
|
elementToDrag.classList.remove("no-transition");
|
||||||
|
|
||||||
const computedStyle = window.getComputedStyle(elementToDrag);
|
const computedStyle = window.getComputedStyle(elementToDrag);
|
||||||
const x = parseFloat(computedStyle.left);
|
const x = parseFloat(computedStyle.left);
|
||||||
const y = parseFloat(computedStyle.top);
|
const y = parseFloat(computedStyle.top);
|
||||||
@@ -341,6 +355,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
const blockToDrag = document.querySelector(`[data-block-id="${draggingBlock}"]`) as HTMLElement;
|
const blockToDrag = document.querySelector(`[data-block-id="${draggingBlock}"]`) as HTMLElement;
|
||||||
|
|
||||||
if (blockToDrag) {
|
if (blockToDrag) {
|
||||||
|
// Re-enable transitions
|
||||||
|
blockToDrag.classList.remove("no-transition");
|
||||||
|
|
||||||
const computedStyle = window.getComputedStyle(blockToDrag);
|
const computedStyle = window.getComputedStyle(blockToDrag);
|
||||||
const x = parseFloat(computedStyle.left);
|
const x = parseFloat(computedStyle.left);
|
||||||
const y = parseFloat(computedStyle.top);
|
const y = parseFloat(computedStyle.top);
|
||||||
@@ -355,6 +372,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
const blockElement = document.querySelector(`[data-block-id="${selectedBlock}"]`) as HTMLElement;
|
const blockElement = document.querySelector(`[data-block-id="${selectedBlock}"]`) as HTMLElement;
|
||||||
|
|
||||||
if (elementToResize && blockElement) {
|
if (elementToResize && blockElement) {
|
||||||
|
// Re-enable transitions
|
||||||
|
elementToResize.classList.remove("no-transition");
|
||||||
|
|
||||||
const computedStyle = window.getComputedStyle(elementToResize);
|
const computedStyle = window.getComputedStyle(elementToResize);
|
||||||
const width = parseFloat(computedStyle.width);
|
const width = parseFloat(computedStyle.width);
|
||||||
const height = parseFloat(computedStyle.height);
|
const height = parseFloat(computedStyle.height);
|
||||||
@@ -367,6 +387,9 @@ const DashboardEditor: React.FC = () => {
|
|||||||
// Update backend for block resize
|
// Update backend for block resize
|
||||||
const blockToResize = document.querySelector(`[data-block-id="${resizingBlock}"]`) as HTMLElement;
|
const blockToResize = document.querySelector(`[data-block-id="${resizingBlock}"]`) as HTMLElement;
|
||||||
if (blockToResize) {
|
if (blockToResize) {
|
||||||
|
// Re-enable transitions
|
||||||
|
blockToResize.classList.remove("no-transition");
|
||||||
|
|
||||||
const computedStyle = window.getComputedStyle(blockToResize);
|
const computedStyle = window.getComputedStyle(blockToResize);
|
||||||
const width = parseFloat(computedStyle.width);
|
const width = parseFloat(computedStyle.width);
|
||||||
const height = parseFloat(computedStyle.height);
|
const height = parseFloat(computedStyle.height);
|
||||||
@@ -638,7 +661,6 @@ const DashboardEditor: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const ElementComponent: React.FC<ElementComponentProps> = ({ element, blockId, e
|
|||||||
>
|
>
|
||||||
<ElementContent element={element} resolvedData={resolveElementValue(element)} />
|
<ElementContent element={element} resolvedData={resolveElementValue(element)} />
|
||||||
|
|
||||||
{editMode && (
|
{editMode && isSelected && (
|
||||||
<>
|
<>
|
||||||
<div className="resize-handle" onMouseDown={(e) => handleElementResizeStart(element.elementUuid, e)}>
|
<div className="resize-handle" onMouseDown={(e) => handleElementResizeStart(element.elementUuid, e)}>
|
||||||
<ResizeIcon />
|
<ResizeIcon />
|
||||||
|
|||||||
@@ -12,7 +12,13 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
*> {
|
// Utility class to disable transitions during drag/resize
|
||||||
|
.no-transition,
|
||||||
|
.no-transition * {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
* > {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,9 +485,7 @@
|
|||||||
|
|
||||||
.colorValue {
|
.colorValue {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: linear-gradient(90.85deg,
|
background: linear-gradient(90.85deg, rgba(240, 228, 255, 0.3) 3.6%, rgba(211, 174, 253, 0.3) 96.04%);
|
||||||
rgba(240, 228, 255, 0.3) 3.6%,
|
|
||||||
rgba(211, 174, 253, 0.3) 96.04%);
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
@@ -1116,4 +1120,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user