Skip to content

Commit 53ef6dd

Browse files
authored
Merge pull request #7028 from coollabsio/andrasbacsai/belgrade-v3
feat: add dynamic viewport-based height for compose editor
2 parents 8458ad0 + 1276669 commit 53ef6dd

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class MyComponent extends Component
146146
- State management handled on the server
147147
- Use wire:model for two-way data binding
148148
- Dispatch events for component communication
149+
- **CRITICAL**: Livewire component views **MUST** have exactly ONE root element. ALL content must be contained within this single root element. Placing ANY elements (`<style>`, `<script>`, `<div>`, comments, or any other HTML) outside the root element will break Livewire's component tracking and cause `wire:click` and other directives to fail silently.
149150

150151
### Code Organization Patterns
151152
- **Actions Pattern**: Use Actions for complex business logic (`app/Actions/`)

resources/views/components/forms/monaco-editor.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
}, 5);" :id="monacoId">
105105
</div>
106106
<div class="relative z-10 w-full h-full">
107-
<div x-ref="monacoEditorElement" class="w-full h-[calc(100vh-20rem)] min-h-96 text-md {{ $readonly ? 'opacity-65' : '' }}"></div>
107+
<div x-ref="monacoEditorElement" class="w-full text-md {{ $readonly ? 'opacity-65' : '' }}" style="height: var(--editor-height, calc(100vh - 20rem)); min-height: 300px;"></div>
108108
<div x-ref="monacoPlaceholderElement" x-show="monacoPlaceholder" @click="monacoEditorFocus()"
109109
:style="'font-size: ' + monacoFontSize"
110110
class="w-full text-sm font-mono absolute z-50 text-gray-500 ml-14 -translate-x-0.5 mt-0.5 left-0 top-0"

resources/views/livewire/project/service/edit-compose.blade.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
<style>
2-
.compose-editor-container .coolify-monaco-editor>div>div>div {
3-
height: 512px !important;
4-
min-height: 512px !important;
1+
<div x-data="{
2+
raw: true,
3+
showNormalTextarea: false,
4+
editorHeight: 400,
5+
calculateEditorHeight() {
6+
// Get viewport height
7+
const viewportHeight = window.innerHeight;
8+
// Modal max height is calc(100vh - 2rem) = viewport - 32px
9+
const modalMaxHeight = viewportHeight - 32;
10+
// Account for: modal header (~80px) + info text (~60px) + checkboxes (~80px) + buttons (~80px) + padding (~48px)
11+
const fixedElementsHeight = 348;
12+
// Calculate available height for editor
13+
const availableHeight = modalMaxHeight - fixedElementsHeight;
14+
// Set minimum height of 300px and maximum of available space
15+
this.editorHeight = Math.max(300, Math.min(availableHeight, viewportHeight - 200));
516
}
6-
</style>
7-
<div x-data="{ raw: true, showNormalTextarea: false }">
17+
}" x-init="calculateEditorHeight(); window.addEventListener('resize', () => calculateEditorHeight())">
818
<div class="pb-4">Volume names are updated upon save. The service UUID will be added as a prefix to all volumes, to
919
prevent
1020
name collision. <br>To see the actual volume names, check the Deployable Compose file, or go to Storage
1121
menu.</div>
1222

13-
<div class="compose-editor-container">
23+
<div class="compose-editor-container" x-bind:style="`--editor-height: ${editorHeight}px`">
1424
<div x-cloak x-show="raw" class="font-mono">
1525
<div x-cloak x-show="showNormalTextarea">
16-
<x-forms.textarea rows="25" id="dockerComposeRaw">
26+
<x-forms.textarea x-bind:style="`height: ${editorHeight}px`" id="dockerComposeRaw">
1727
</x-forms.textarea>
1828
</div>
1929
<div x-cloak x-show="!showNormalTextarea">
@@ -22,7 +32,7 @@
2232
</div>
2333
</div>
2434
<div x-cloak x-show="raw === false" class="font-mono">
25-
<x-forms.textarea rows="25" readonly id="dockerCompose">
35+
<x-forms.textarea x-bind:style="`height: ${editorHeight}px`" readonly id="dockerCompose">
2636
</x-forms.textarea>
2737
</div>
2838
</div>

templates/service-templates-latest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4527,7 +4527,7 @@
45274527
"web",
45284528
"admin"
45294529
],
4530-
"category": "vps",
4530+
"category": "vpn",
45314531
"logo": "svgs/wireguard.svg",
45324532
"minversion": "0.0.0",
45334533
"port": "8000"

templates/service-templates.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4527,7 +4527,7 @@
45274527
"web",
45284528
"admin"
45294529
],
4530-
"category": "vps",
4530+
"category": "vpn",
45314531
"logo": "svgs/wireguard.svg",
45324532
"minversion": "0.0.0",
45334533
"port": "8000"

0 commit comments

Comments
 (0)