main
html 162 lines 4.16 KB
Raw
1 <html>
2 <head>
3 <title>File Editor</title>
4 <script type="module">
5 import { store } from "/components/modals/file-editor/file-editor-store.js";
6 </script>
7 </head>
8 <body>
9 <div x-data>
10 <template x-if="$store.fileEditor">
11 <div class="file-edit-modal-root">
12 <template x-if="$store.fileEditor.isEditLoading">
13 <div class="loading-state">
14 <div class="loading-spinner"></div>
15 <p>Loading file…</p>
16 </div>
17 </template>
18
19 <template x-if="$store.fileEditor.editError">
20 <div class="error-state">
21 <p class="error-message" x-text="$store.fileEditor.editError"></p>
22 </div>
23 </template>
24
25 <template x-if="!$store.fileEditor.isEditLoading && !$store.fileEditor.editError">
26 <div class="file-edit-content">
27 <div class="file-edit-meta">
28 <div class="file-edit-field">
29 <label>File name</label>
30 <input
31 type="text"
32 x-model="$store.fileEditor.editFileName"
33 @input="$store.fileEditor.updateEditorMode()"
34 :disabled="!$store.fileEditor.editIsNew"
35 />
36 <template x-if="$store.fileEditor.editSaveError">
37 <p class="file-edit-inline-error" x-text="$store.fileEditor.editSaveError"></p>
38 </template>
39 </div>
40 <div class="file-edit-path" x-text="$store.fileEditor.editPathLabel()"></div>
41 </div>
42 <div id="file-editor-container" class="no-scrollbar"></div>
43 </div>
44 </template>
45 </div>
46 </template>
47 </div>
48
49 <template x-if="$store.fileEditor">
50 <div class="modal-footer" data-modal-footer>
51 <button
52 class="btn btn-ok"
53 @click="$store.fileEditor.saveFileEdits()"
54 :disabled="$store.fileEditor.isSaving || $store.fileEditor.isEditLoading || $store.fileEditor.editError"
55 x-text="$store.fileEditor.isSaving ? 'Saving…' : 'Save'"
56 ></button>
57 <button class="btn btn-cancel" @click="$store.fileEditor.closeFileEditor()" :disabled="$store.fileEditor.isSaving">Cancel</button>
58 </div>
59 </template>
60
61 <style>
62 .file-edit-modal-root {
63 display: flex;
64 flex-direction: column;
65 width: 100%;
66 min-height: 400px;
67 }
68
69 .file-edit-content {
70 display: flex;
71 flex-direction: column;
72 gap: var(--spacing-md);
73 margin: 1rem;
74 }
75
76 .file-edit-meta {
77 display: flex;
78 flex-direction: column;
79 gap: var(--spacing-xs);
80 }
81
82 .file-edit-field {
83 display: flex;
84 flex-direction: column;
85 gap: 6px;
86 }
87
88 .file-edit-field label {
89 font-weight: 600;
90 color: var(--color-text);
91 }
92
93 .file-edit-field input {
94 padding: 8px 12px;
95 border-radius: 6px;
96 border: 1px solid var(--color-border);
97 background: var(--color-background);
98 color: var(--color-text);
99 }
100
101 .file-edit-field input:disabled {
102 opacity: 0.7;
103 cursor: not-allowed;
104 }
105
106 .file-edit-inline-error {
107 margin: 0;
108 color: var(--color-error);
109 font-weight: 500;
110 font-size: 0.85rem;
111 }
112
113 .file-edit-path {
114 font-size: 0.85rem;
115 color: var(--color-text-secondary);
116 word-break: break-all;
117 }
118
119 #file-editor-container {
120 width: 100%;
121 min-height: 55vh;
122 border-radius: 0.4rem;
123 overflow: auto;
124 }
125
126 .ace_scrollbar-v {
127 overflow-y: auto;
128 }
129
130 .loading-state,
131 .error-state {
132 display: flex;
133 flex-direction: column;
134 align-items: center;
135 justify-content: center;
136 padding: var(--spacing-lg);
137 min-height: 200px;
138 }
139
140 .loading-spinner {
141 width: 40px;
142 height: 40px;
143 border: 3px solid var(--color-border);
144 border-top: 3px solid var(--color-primary);
145 border-radius: 50%;
146 animation: spin 1s linear infinite;
147 margin-bottom: var(--spacing-md);
148 }
149
150 @keyframes spin {
151 0% { transform: rotate(0deg); }
152 100% { transform: rotate(360deg); }
153 }
154
155 .error-message {
156 color: var(--color-error);
157 font-weight: 500;
158 margin: 0;
159 }
160 </style>
161 </body>
162 </html>