New Responsive design
This commit is contained in:
@@ -126,6 +126,14 @@ onUnmounted(() => {
|
||||
right: 15px;
|
||||
cursor: pointer;
|
||||
font-size: 22px;
|
||||
z-index: 10;
|
||||
background: rgba(255,255,255,0.9);
|
||||
border-radius: 50%;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Animation */
|
||||
@@ -146,4 +154,41 @@ onUnmounted(() => {
|
||||
transform: scale(0.98);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* ─── Tablet ─── */
|
||||
@media (max-width: 1023px) {
|
||||
.full-screen-modal-content {
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.full-screen-modal-body {
|
||||
padding: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
.full-screen-modal-content {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.full-screen-modal-body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.full-screen-modal-close {
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
font-size: 26px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+113
-84
@@ -1,42 +1,42 @@
|
||||
<template>
|
||||
<teleport to="body">
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="show"
|
||||
class="modal-overlay"
|
||||
@click.self="close"
|
||||
>
|
||||
<transition name="scale">
|
||||
<div
|
||||
v-if="show"
|
||||
ref="modalRef"
|
||||
class="modal-content"
|
||||
tabindex="-1"
|
||||
:style="{ width: width }"
|
||||
>
|
||||
<teleport to="body">
|
||||
<transition name="fade">
|
||||
<div
|
||||
v-if="show"
|
||||
class="modal-overlay"
|
||||
@click.self="close"
|
||||
>
|
||||
<transition name="scale">
|
||||
<div
|
||||
v-if="show"
|
||||
ref="modalRef"
|
||||
class="modal-content"
|
||||
tabindex="-1"
|
||||
:style="{ width: width }"
|
||||
>
|
||||
|
||||
<div class="modal-header">
|
||||
<div class="title"><label>{{ title }}</label>
|
||||
<span @click="close" class="dashicons dashicons-dismiss modal-close"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<div class="title"><label>{{ title }}</label>
|
||||
<span @click="close" class="dashicons dashicons-dismiss modal-close"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-body" style="max-height: 600px; overflow: auto;">
|
||||
<slot />
|
||||
<div class="modal-body">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</transition>
|
||||
</teleport>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
show: Boolean,
|
||||
title: { type: String, default: 'Modal' },
|
||||
show: Boolean,
|
||||
title: { type: String, default: 'Modal' },
|
||||
width: { type: String, default: '1200px' },
|
||||
})
|
||||
const emit = defineEmits(['close'])
|
||||
@@ -44,98 +44,127 @@ const emit = defineEmits(['close'])
|
||||
const modalRef = ref(null)
|
||||
|
||||
function close() {
|
||||
emit('close')
|
||||
emit('close')
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. ESC-Key schließt Modal
|
||||
*/
|
||||
function handleKeyDown(e) {
|
||||
if (e.key === 'Escape') {
|
||||
close()
|
||||
}
|
||||
|
||||
// 2. Focus-Trap
|
||||
if (e.key === 'Tab' && modalRef.value) {
|
||||
const focusable = modalRef.value.querySelectorAll(
|
||||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
||||
)
|
||||
if (focusable.length === 0) return
|
||||
|
||||
const first = focusable[0]
|
||||
const last = focusable[focusable.length - 1]
|
||||
|
||||
if (e.shiftKey && document.activeElement === first) {
|
||||
e.preventDefault()
|
||||
last.focus()
|
||||
} else if (!e.shiftKey && document.activeElement === last) {
|
||||
e.preventDefault()
|
||||
first.focus()
|
||||
if (e.key === 'Escape') {
|
||||
close()
|
||||
}
|
||||
|
||||
if (e.key === 'Tab' && modalRef.value) {
|
||||
const focusable = modalRef.value.querySelectorAll(
|
||||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
||||
)
|
||||
if (focusable.length === 0) return
|
||||
|
||||
const first = focusable[0]
|
||||
const last = focusable[focusable.length - 1]
|
||||
|
||||
if (e.shiftKey && document.activeElement === first) {
|
||||
e.preventDefault()
|
||||
last.focus()
|
||||
} else if (!e.shiftKey && document.activeElement === last) {
|
||||
e.preventDefault()
|
||||
first.focus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. Body-Scroll sperren wenn Modal offen
|
||||
*/
|
||||
watch(
|
||||
() => props.show,
|
||||
async (newVal) => {
|
||||
if (newVal) {
|
||||
document.body.style.overflow = 'hidden'
|
||||
await nextTick()
|
||||
modalRef.value?.focus() // Setzt Focus ins Modal
|
||||
} else {
|
||||
document.body.style.overflow = ''
|
||||
}
|
||||
if (newVal) {
|
||||
document.body.style.overflow = 'hidden'
|
||||
await nextTick()
|
||||
modalRef.value?.focus()
|
||||
} else {
|
||||
document.body.style.overflow = ''
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleKeyDown)
|
||||
document.body.style.overflow = '' // fallback cleanup
|
||||
window.removeEventListener('keydown', handleKeyDown)
|
||||
document.body.style.overflow = ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
}
|
||||
.modal-content {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
|
||||
max-width: 1200px;
|
||||
width: 90%;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
||||
outline: none;
|
||||
max-width: 1200px;
|
||||
width: 90%;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
max-height: 600px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Animation */
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
.scale-enter-active,
|
||||
.scale-leave-active {
|
||||
transition: transform 0.25s ease, opacity 0.25s ease;
|
||||
transition: transform 0.25s ease, opacity 0.25s ease;
|
||||
}
|
||||
.scale-enter-from,
|
||||
.scale-leave-to {
|
||||
transform: scale(0.95);
|
||||
opacity: 0;
|
||||
transform: scale(0.95);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* ─── Tablet ─── */
|
||||
@media (max-width: 1023px) {
|
||||
.modal-content {
|
||||
width: 95% !important;
|
||||
max-width: 95vw;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
max-height: 70vh;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
.modal-overlay {
|
||||
align-items: flex-end;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
border-radius: 16px 16px 0 0;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
max-height: 75vh;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,21 +2,20 @@
|
||||
import { ref, shallowRef, onMounted } from "vue"
|
||||
|
||||
const props = defineProps({
|
||||
tabs: {
|
||||
type: Array,
|
||||
required: true,
|
||||
// [{ title: "Titel", component: Component, endpoint: "/wp-json/..." }]
|
||||
},
|
||||
subTabIndex: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0
|
||||
}
|
||||
tabs: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
subTabIndex: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
const activeTab = ref(null) // aktuell ausgewählter Tab
|
||||
const tabData = ref({}) // Daten für jeden Tab
|
||||
const tabComponent = shallowRef(null) // Komponente für aktuellen Tab
|
||||
const activeTab = ref(null)
|
||||
const tabData = ref({})
|
||||
const tabComponent = shallowRef(null)
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
|
||||
@@ -34,13 +33,13 @@ async function selectTab(index) {
|
||||
?.getAttribute('content')
|
||||
|
||||
const response = await fetch(tab.endpoint, {
|
||||
method: 'GET', // oder POST, PUT, DELETE …
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
credentials: 'same-origin', // wichtig für Session/Auth
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
|
||||
if (!response.ok) throw new Error("Fehler: " + response.status)
|
||||
@@ -56,65 +55,102 @@ async function selectTab(index) {
|
||||
}
|
||||
}
|
||||
|
||||
// ersten Tab automatisch laden
|
||||
onMounted(() => {
|
||||
if (props.tabs.length > 0) {
|
||||
selectTab(props.subTabIndex)
|
||||
}
|
||||
if (props.tabs.length > 0) {
|
||||
selectTab(props.subTabIndex)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="tabs">
|
||||
<!-- Tab Header -->
|
||||
<div class="tab-header">
|
||||
<button
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="index"
|
||||
:class="['tab-button', { active: activeTab === index }]"
|
||||
@click="selectTab(index)"
|
||||
>
|
||||
{{ tab.title }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="tabs">
|
||||
<div class="tab-header">
|
||||
<button
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="index"
|
||||
:class="['tab-button', { active: activeTab === index }]"
|
||||
@click="selectTab(index)"
|
||||
>
|
||||
{{ tab.title }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Tab Content -->
|
||||
<div class="tab-content" id="tab-content">
|
||||
<div v-if="loading">⏳ Lädt...</div>
|
||||
<div v-else-if="error">❌ {{ error }}</div>
|
||||
<component
|
||||
v-else-if="tabComponent"
|
||||
:is="tabComponent"
|
||||
:data="tabData[activeTab]"
|
||||
:deep_jump_id="tabs[activeTab].deep_jump_id"
|
||||
:deep_jump_id_sub="tabs[activeTab].deep_jump_id_sub"
|
||||
/>
|
||||
<div class="tab-content" id="tab-content">
|
||||
<div v-if="loading">⏳ Lädt...</div>
|
||||
<div v-else-if="error">❌ {{ error }}</div>
|
||||
<component
|
||||
v-else-if="tabComponent"
|
||||
:is="tabComponent"
|
||||
:data="tabData[activeTab]"
|
||||
:deep_jump_id="tabs[activeTab].deep_jump_id"
|
||||
:deep_jump_id_sub="tabs[activeTab].deep_jump_id_sub"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tabs {
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.tab-header {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: flex;
|
||||
border-bottom: 1px solid #ddd;
|
||||
flex-wrap: wrap;
|
||||
gap: 2px;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
.tab-button {
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: #f8f8f8;
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: #f8f8f8;
|
||||
white-space: nowrap;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.tab-button.active {
|
||||
font-weight: bold;
|
||||
background: white;
|
||||
border-bottom: 2px solid #0073aa;
|
||||
font-weight: bold;
|
||||
background: white;
|
||||
border-bottom: 2px solid #0073aa;
|
||||
}
|
||||
.tab-content {
|
||||
padding: 1rem;
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
/* ─── Tablet ─── */
|
||||
@media (max-width: 1023px) {
|
||||
.tab-button {
|
||||
font-size: 0.85rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
.tab-header {
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.tab-button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 0.65rem 1rem;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.tab-button.active {
|
||||
border-bottom: none;
|
||||
border-left: 4px solid #0073aa;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user