ToolJet/frontend/src/Editor/BoxDragPreview.jsx
Navaneeth Pk 20cccd1df7
Responsive canvas (#1363)
* Better canvas

* Better canvas

* Better canvas

* Fix for resize

* Fix for drag

* Fix for drag

* Fix for drag

* Adjust width of components by # of grid lines

* Adjust components to comply with gridline based width

* Fix the width of rigth sidebar

* Fix for subcontainer resize issue

* Fix for dropped widget width (sc)

* Fix subcontainer drag width

* Fix grid for sub container

* Fix viewer

* Fix

* Fix

* Use RnD for dragging within canvas

* bounds for subcontainers

* fix for subcontainers

* Fix for mouseover issue

* Fix

* Fix widget widths

* Fixes chart

* Fixes qr scanner and divider

* Remove scaleValue

* Mmerge fix

* Mmerge fix

* Fix for ormconfig

* Fixes for comments

* Add comment where the user clicked

* Disable dragging on viewer

* Max width for canvas

* Fix for widget click events

* Fix for radio button

* Rebase widget width and left offset for responsive canvas

* Fix

* Fix the width of file picker

* Fix for calendar widget

* Disable zoom selector

* Fixes comment positions

* css fixes

* Fix

* Recompute width and offset of subcontainer widgets based on its parent's width

* Calculate container width separately for modal children while migrating to responsive

* Refactor migration to responsive canvas whereinwhich all mutations are done only after all required changes are computed

Co-authored-by: Sherfin Shamsudeen <sherfin94@gmail.com>
2021-11-16 17:14:09 +05:30

37 lines
1,011 B
JavaScript

import React, { useEffect, useState, memo } from 'react';
export const BoxDragPreview = memo(function BoxDragPreview({ item, currentLayout, canvasWidth }) {
const [tickTock, setTickTock] = useState(false);
useEffect(
function subscribeToIntervalTick() {
const interval = setInterval(() => setTickTock(!tickTock), 500);
return () => clearInterval(interval);
},
[tickTock]
);
const layouts = item.layouts;
let { width, height } = layouts ? item.layouts[currentLayout] : {};
if (item.id === undefined) {
width = item.component.defaultSize.width;
height = item.component.defaultSize.height;
}
return (
<div
className="resizer-active draggable-box"
style={{ height, width: (width * canvasWidth) / 43, border: 'solid 1px rgb(70, 165, 253)', padding: '2px' }}
>
<div
style={{
background: '#438fd7',
opacity: '0.7',
height: '100%',
width: '100%',
}}
></div>
</div>
);
});