Skip to content

Commit dea02dc

Browse files
committed
Prevent side panels from overlaying on large screens
1 parent b51a902 commit dea02dc

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

resources/views/livewire/vault/show.blade.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ class="fixed inset-0 z-40 opacity-50 bg-light-base-50 dark:bg-base-900"
5252

5353
<div
5454
class="fixed inset-0 z-20 opacity-50 bg-light-base-50 dark:bg-base-900"
55-
x-show="(isLeftPanelOpen || isRightPanelOpen) && isNotExtraLargeDevice()"
55+
x-show="(isLeftPanelOpen || isRightPanelOpen) && isNotLargeDevice()"
5656
@click="closePanels"
5757
x-transition:enter="ease-out duration-300"
5858
x-transition:leave="ease-in duration-200"
5959
></div>
6060

61-
<div
62-
class="absolute xl:static flex flex-col top-0 left-0 bottom-0 z-30 w-[80%] max-w-[300px] xl:w-[20%] xl:max-w-[300px] bg-light-base-200 dark:bg-base-800 transition-all overflow-x-auto overflow-y-auto print:hidden"
61+
<aside
62+
class="absolute lg:static flex flex-col top-0 left-0 bottom-0 z-30 w-[80%] max-w-[300px] lg:w-[20%] lg:max-w-[300px] bg-light-base-200 dark:bg-base-800 transition-all overflow-x-auto overflow-y-auto print:hidden"
6363
:class="{ 'translate-x-0': isLeftPanelOpen, '-translate-x-full hidden': !isLeftPanelOpen }"
6464
x-cloak
6565
>
6666
<livewire:vault.tree-view lazy="on-load" :vault="$this->vault" />
67-
</div>
67+
</aside>
6868

69-
<div class="flex-1 h-full max-w-full transition-all" x-cloak>
69+
<section id="main-content" class="flex-1 h-full max-w-full transition-all" x-cloak>
7070
<div
7171
class="flex flex-col h-full w-full transition-maxwidth duration-300 ease-in-out mx-auto"
7272
:class="{ 'max-w-full': isContentWidthFull, 'max-w-[48rem]': !isContentWidthFull }"
@@ -167,10 +167,10 @@ class="overflow-hidden text-xs whitespace-nowrap text-ellipsis text-light-base-7
167167
</div>
168168
</div>
169169
</div>
170-
</div>
170+
</section>
171171

172-
<div
173-
class="absolute xl:static flex flex-col top-0 right-0 bottom-0 z-30 w-[80%] max-w-[300px] xl:w-[20%] xl:max-w-[300px] py-4 bg-light-base-200 dark:bg-base-800 transition-all overflow-x-auto overflow-y-auto print:hidden"
172+
<aside
173+
class="absolute lg:static flex flex-col top-0 right-0 bottom-0 z-30 w-[80%] max-w-[300px] lg:w-[20%] lg:max-w-[300px] py-4 bg-light-base-200 dark:bg-base-800 transition-all overflow-x-auto overflow-y-auto print:hidden"
174174
:class="{ 'translate-x-0': isRightPanelOpen, '-translate-x-full hidden': !isRightPanelOpen }"
175175
x-cloak
176176
>
@@ -244,7 +244,7 @@ class="text-primary-400 dark:text-primary-500 hover:text-primary-300 dark:hover:
244244
</div>
245245
</div>
246246
</div>
247-
</div>
247+
</aside>
248248
</x-layouts.appMain>
249249

250250
<livewire:modals.add-node :vault="$this->vault" />
@@ -327,39 +327,44 @@ class="text-primary-400 dark:text-primary-500 hover:text-primary-300 dark:hover:
327327
});
328328
},
329329
330-
isMediumDevice() {
331-
return window.innerWidth > 768;
332-
},
333-
334-
isNotExtraLargeDevice() {
335-
return window.innerWidth < 1280;
330+
isNotLargeDevice() {
331+
return window.innerWidth < 1024;
336332
},
337333
338334
handleResponsiveLayout() {
339-
if (this.isNotExtraLargeDevice()) {
335+
if (this.isNotLargeDevice()) {
340336
this.closePanels();
341337
} else {
342338
this.isLeftPanelOpen = this.defaultLeftPanelOpen;
343339
this.isRightPanelOpen = this.defaultRightPanelOpen;
344340
}
345341
346-
this.showToggleContentWidthButton = this.isMediumDevice();
342+
this.checkButtonsVisibility();
343+
},
344+
345+
checkButtonsVisibility() {
346+
this.$nextTick(() => {
347+
const element = document.getElementById('main-content');
348+
this.showToggleContentWidthButton = element.offsetWidth > 768;
349+
});
347350
},
348351
349352
toggleLeftPanel() {
350-
if (!this.isNotExtraLargeDevice()) {
353+
if (!this.isNotLargeDevice()) {
351354
this.defaultLeftPanelOpen = !this.defaultLeftPanelOpen;
352355
}
353356
354357
this.isLeftPanelOpen = !this.isLeftPanelOpen;
358+
this.checkButtonsVisibility();
355359
},
356360
357361
toggleRightPanel() {
358-
if (!this.isNotExtraLargeDevice()) {
362+
if (!this.isNotLargeDevice()) {
359363
this.defaultRightPanelOpen = !this.defaultRightPanelOpen;
360364
}
361365
362366
this.isRightPanelOpen = !this.isRightPanelOpen;
367+
this.checkButtonsVisibility();
363368
},
364369
365370
closePanels() {
@@ -394,7 +399,7 @@ class="text-primary-400 dark:text-primary-500 hover:text-primary-300 dark:hover:
394399
395400
$wire.openFileId(fileId, autofocus);
396401
397-
if (this.isNotExtraLargeDevice()) {
402+
if (this.isNotLargeDevice()) {
398403
this.closePanels();
399404
}
400405
},

0 commit comments

Comments
 (0)