From d9b358bcc20d2603ef94ada765d395e370d58fc7 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Thu, 29 Aug 2024 11:14:04 +0200 Subject: [PATCH] feat(frontend): add indicator when a component is locked (#4296) * feat(frontend): add indicator when a component is locked * feat(frontend): add indicator when a component is locked * feat(frontend): improve interactivity * feat(frontend): fix how the lock overlay renders * feat(frontend): use builin detection * feat(frontend): fix zIndex * feat(frontend): update the shadow when dragged over a locked component --- frontend/src/lib/assets/app.css | 20 ++++++++++++++ .../components/apps/editor/GridEditor.svelte | 6 ++--- .../apps/editor/component/Component.svelte | 27 ++++++++++++++++--- .../components/apps/svelte-grid/Grid.svelte | 8 ++++-- .../apps/svelte-grid/MoveResize.svelte | 14 +++++++--- .../components/apps/svelte-grid/utils/item.ts | 14 +++++++--- 6 files changed, 73 insertions(+), 16 deletions(-) diff --git a/frontend/src/lib/assets/app.css b/frontend/src/lib/assets/app.css index 0a611f0862..2e41b279c0 100644 --- a/frontend/src/lib/assets/app.css +++ b/frontend/src/lib/assets/app.css @@ -124,3 +124,23 @@ svelte-virtual-list-contents > * + * { .nonmain-editor .cursor.monaco-mouse-cursor-text { width: 1px !important; } + +.bg-locked { + background-image: repeating-linear-gradient( + -45deg, + rgba(128, 128, 128, 0.2), + rgba(128, 128, 128, 0.2) 10px, + rgba(192, 192, 192, 0.2) 10px, + rgba(192, 192, 192, 0.2) 20px + ); +} + +.bg-locked-hover { + background-image: repeating-linear-gradient( + -45deg, + rgba(255, 99, 71, 0.2), + rgba(255, 99, 71, 0.2) 10px, + rgba(255, 69, 58, 0.2), + rgba(255, 69, 58, 0.2) 20px + ); +} diff --git a/frontend/src/lib/components/apps/editor/GridEditor.svelte b/frontend/src/lib/components/apps/editor/GridEditor.svelte index 21f3b0afcb..926c5fe26f 100644 --- a/frontend/src/lib/components/apps/editor/GridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/GridEditor.svelte @@ -136,6 +136,7 @@ }} let:dataItem let:hidden + let:overlapped cols={columnConfiguration} > { handleFillHeight(dataItem.id) }} + overlapped={overlapped !== undefined} /> @@ -193,10 +195,6 @@ {/if} diff --git a/frontend/src/lib/components/apps/svelte-grid/utils/item.ts b/frontend/src/lib/components/apps/svelte-grid/utils/item.ts index 1a587ba77c..8cb691d3e5 100644 --- a/frontend/src/lib/components/apps/svelte-grid/utils/item.ts +++ b/frontend/src/lib/components/apps/svelte-grid/utils/item.ts @@ -133,7 +133,12 @@ export function moveItem(active, items, cols) { const fixed = closeObj.find((value) => value[cols].fixed) // If found fixed, reset the active to its original position - if (fixed) return items + if (fixed) { + return { + items: items, + overlap: true + } + } // Update items items = updateItem(items, active, item, cols) @@ -171,7 +176,10 @@ export function moveItem(active, items, cols) { }) // Return result - return tempItems + return { + items: tempItems, + overlap: false + } } // Helper function @@ -181,7 +189,7 @@ export function normalize(items, col) { result.forEach((value) => { const getItem = value[col] if (!getItem.static) { - result = moveItem(getItem, result, col) + result = moveItem(getItem, result, col).items } })