Open home widget create forms in popup modals
Deploy with Docker Compose / deploy (push) Successful in 23s
Weekly Maintenance / maintenance (push) Successful in 1m19s

The Places tab already popped its create form up over the page; every other
/stp widget swapped its contents for the form instead, which meant losing
sight of the list you were adding to and a cramped form inside a grid cell.

Extract the Places modal into a shared components/util/Modal.vue (teleported
backdrop, click-outside and Escape to close) and use it for the Feed, Bookmarks,
Favorites, Consumption and Rowing create forms as well. Widget headers keep
their normal titles now that each form carries its own heading in the modal.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KcFtkisHcKJuTZAnv3fVzA
This commit is contained in:
2026-09-12 18:50:17 +01:00
co-authored by Claude Opus 5
parent 894c158afd
commit fe6fc02b6b
9 changed files with 106 additions and 73 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
<script setup>
import { useAuthStore } from "@/stores/auth";
// "+" / "x" button, shown to admins only. Toggles a home widget between its
// normal view and its create form. Designed for <Header>'s #action slot.
// "+" / "x" button, shown to admins only. Opens a home widget's create form in
// a popup <Modal>. Designed for <Header>'s #action slot.
const show = defineModel({ type: Boolean, default: false });
const auth = useAuthStore();
</script>
+61
View File
@@ -0,0 +1,61 @@
<script setup>
import { watch, onUnmounted } from "vue";
// Popup modal: a dimmed backdrop over the page with the content floated on top.
// Closes on backdrop click or Escape. Used by the home widgets so their create
// forms pop up instead of replacing the widget's contents.
const open = defineModel({ type: Boolean, default: false });
const props = defineProps({
maxWidth: { type: String, default: "420px" },
});
function onKeydown(e) {
if (e.key === "Escape") open.value = false;
}
watch(
open,
(isOpen) => {
if (isOpen) {
window.addEventListener("keydown", onKeydown);
} else {
window.removeEventListener("keydown", onKeydown);
}
},
{ immediate: true },
);
onUnmounted(() => window.removeEventListener("keydown", onKeydown));
</script>
<template>
<Teleport to="body">
<div v-if="open" class="modal-backdrop" @click.self="open = false">
<div class="modal bdr-1" :style="{ maxWidth: props.maxWidth }">
<slot />
</div>
</div>
</Teleport>
</template>
<style scoped>
.modal-backdrop {
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 50;
padding: 12px;
}
.modal {
background-color: var(--color-surface);
padding: 16px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
}
</style>