Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions server/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,22 @@ tr:hover td {
}

/* Preview Modal */
.modal-overlay {
display: none;
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
z-index: 1000;
#preview-dialog {
background: transparent;
border: none;
padding: 2rem;
max-width: 100vw;
max-height: 100vh;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
}

.modal-overlay.active {
display: flex;
#preview-dialog::backdrop {
background-color: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
}

.modal-content {
Expand Down
36 changes: 13 additions & 23 deletions server/templates/buckets/objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ <h1>{{.BucketName}}</h1>
<td>
<div class="actions-cell">
{{if isPreviewable .Name .Length}}
<button class="btn-view" title="Preview File" onclick="openPreview('/buckets/{{$.BucketName}}/preview/{{.Name}}')">
<button class="btn-view" title="Preview File"
hx-get="/buckets/{{$.BucketName}}/preview/{{.Name}}"
hx-target="#preview-dialog" hx-swap="innerHTML">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle>
</svg>
Expand Down Expand Up @@ -194,7 +196,9 @@ <h1>{{.BucketName}}</h1>

{{range .Objects}}
{{if isImage .Name}}
<div class="gallery-card gallery-image" onclick="openPreview('/buckets/{{$.BucketName}}/preview/{{.Name}}')">
<div class="gallery-card gallery-image"
hx-get="/buckets/{{$.BucketName}}/preview/{{.Name}}"
hx-target="#preview-dialog" hx-swap="innerHTML">
<div class="gallery-thumb" data-src="/buckets/{{$.BucketName}}/view/{{.Name}}">
<div class="gallery-thumb-placeholder">
<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
Expand All @@ -208,7 +212,9 @@ <h1>{{.BucketName}}</h1>
<span class="gallery-size">{{formatSize .Length}}</span>
</div>
{{else}}
<div class="gallery-card gallery-file" onclick="{{if isPreviewable .Name .Length}}openPreview('/buckets/{{$.BucketName}}/preview/{{.Name}}'){{end}}">
<div class="gallery-card gallery-file"
{{if isPreviewable .Name .Length}}hx-get="/buckets/{{$.BucketName}}/preview/{{.Name}}"
hx-target="#preview-dialog" hx-swap="innerHTML"{{end}}>
<div class="gallery-file-icon">
<svg viewBox="0 0 24 24" width="32" height="32" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
Expand Down Expand Up @@ -238,25 +244,6 @@ <h1>{{.BucketName}}</h1>

{{define "scripts:buckets/objects.html"}}
<script>
function openPreview(previewUrl) {
var modal = document.getElementById('preview-modal');
htmx.ajax('GET', previewUrl, {target: '#preview-modal', swap: 'innerHTML'}).then(function() {
modal.classList.add('active');
document.addEventListener('keydown', previewKeyHandler);
});
}

function closePreview() {
var modal = document.getElementById('preview-modal');
modal.classList.remove('active');
modal.innerHTML = '';
document.removeEventListener('keydown', previewKeyHandler);
}

function previewKeyHandler(e) {
if (e.key === 'Escape') closePreview();
}

function setViewMode(mode, btn) {
var listView = document.getElementById('list-view');
var galleryView = document.getElementById('gallery-view');
Expand Down Expand Up @@ -310,8 +297,11 @@ <h1>{{.BucketName}}</h1>
}

document.addEventListener('htmx:afterSettle', function(evt) {
if (evt.detail.target.id === 'main-content') {
var id = evt.detail.target.id;
if (id === 'main-content') {
initGalleryView();
} else if (id === 'preview-dialog') {
evt.detail.target.showModal();
}
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion server/templates/buckets/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line>
</svg>
</a>
<button class="modal-close" onclick="closePreview()">&times;</button>
<button class="modal-close" onclick="this.closest('dialog').close()">&times;</button>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions server/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ <h3>Buckets</h3>
</main>
</div>

<div id="preview-modal" class="modal-overlay" onclick="if(event.target===this)closePreview()">
</div>
<dialog id="preview-dialog" onclick="if(event.target===this)this.close()">
</dialog>

<div hx-get="/scripts" hx-trigger="load" hx-swap="innerHTML" style="display:none;"></div>
</body>
Expand Down