finished the upgrade to filament 4. completely revamped the frontend with codex, now it looks great!

This commit is contained in:
2025-11-13 17:42:43 +01:00
parent f59fda588b
commit b311188bc1
138 changed files with 5440 additions and 4105 deletions

View File

@@ -1,162 +1,129 @@
<template>
<div class="style-selector">
<div class="style-selector-header">
<span class="back-arrow" @click="$emit('back')">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
<path fill-rule="evenodd" d="M11.03 4.272a.75.75 0 0 1 0 1.06L6.31 10.5H20.25a.75.75 0 0 1 0 1.5H6.31l4.72 5.168a.75.75 0 0 1-1.06 1.06l-6-6a.75.75 0 0 1 0-1.06l6-6a.75.75 0 0 1 1.06 0Z" clip-rule="evenodd" />
</svg>
</span>
<h3>Verfügbare Stile</h3>
</div>
<div class="styles-list">
<div
v-for="style in styles"
:key="style.id"
class="style-item"
@click="selectStyle(style)"
<div class="flex h-full flex-col gap-4 rounded-3xl border border-white/10 bg-white/5 p-4 text-white">
<div class="flex items-center justify-between gap-2 text-xs uppercase tracking-[0.3em] text-slate-300">
<span>Varianten</span>
<button
type="button"
class="rounded-full border border-white/20 p-1 text-white/70 transition hover:border-rose-300 hover:text-rose-300"
@click="$emit('close')"
aria-label="Auswahl schließen"
>
<img :data-src="'/storage/' + style.preview_image" :alt="style.title" class="style-thumbnail" />
<div class="style-details">
<h4>{{ style.title }}</h4>
<p>{{ style.description }}</p>
</div>
</div>
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6m-12 0 12 12" />
</svg>
</button>
</div>
<div ref="stylesContainer" class="flex-1 space-y-3 overflow-y-auto pr-1">
<p v-if="isLoading" class="rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-center text-sm text-slate-300">
Stile werden geladen
</p>
<p v-else-if="loadError" class="rounded-2xl border border-rose-400/40 bg-rose-500/10 px-4 py-3 text-center text-sm text-rose-100">
{{ loadError }}
</p>
<template v-else>
<button
v-for="style in styles"
:key="style.id"
type="button"
class="group flex w-full items-center gap-4 rounded-2xl border border-white/10 bg-white/5 p-3 text-left transition hover:border-emerald-300"
@click="selectStyle(style)"
>
<img
v-if="style.preview_image"
:data-src="'/storage/' + style.preview_image"
class="h-24 w-24 flex-none rounded-2xl object-cover opacity-90 transition group-hover:opacity-100"
alt="Style preview"
/>
<div
v-else
class="flex h-24 w-24 flex-none items-center justify-center rounded-2xl border border-dashed border-white/20 text-[0.65rem] uppercase tracking-[0.4em] text-slate-400"
>
AI
</div>
<div class="flex flex-col">
<p class="text-base font-semibold text-white">{{ style.title }}</p>
<p class="text-sm text-slate-200">{{ style.description }}</p>
</div>
</button>
</template>
</div>
</div>
</template>
<script setup>
import axios from 'axios';
import { ref, onMounted, nextTick } from 'vue';
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
const styles = ref([]);
const isLoading = ref(true);
const loadError = ref(null);
const stylesContainer = ref(null);
let observer = null;
const props = defineProps({
image_id: {
type: Number,
type: [Number, String],
required: true,
},
});
const emits = defineEmits(['styleSelected', 'back', 'close']);
const emits = defineEmits(['styleSelected', 'close']);
const hydrateObserver = () => {
if (!stylesContainer.value) {
return;
}
if (observer) {
observer.disconnect();
}
observer = new IntersectionObserver(
(entries, obs) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
obs.unobserve(img);
}
});
},
{ root: stylesContainer.value }
);
stylesContainer.value.querySelectorAll('img[data-src]').forEach((img) => observer.observe(img));
};
const fetchStyles = () => {
axios.get('/api/styles')
.then(response => {
isLoading.value = true;
loadError.value = null;
axios
.get('/api/styles')
.then((response) => {
styles.value = response.data;
nextTick(() => {
const stylesList = document.querySelector('.styles-list');
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
observer.unobserve(img);
}
});
}, {
root: stylesList // Observe intersections relative to .styles-list
});
stylesList.querySelectorAll('.style-thumbnail').forEach(img => {
observer.observe(img);
});
});
nextTick(hydrateObserver);
})
.catch(error => {
.catch((error) => {
console.error('Error fetching styles:', error);
loadError.value = 'Stile konnten nicht geladen werden.';
})
.finally(() => {
isLoading.value = false;
});
};
const selectStyle = (style) => {
console.log('StyleSelector.vue: emitting styleSelected with image_id:', props.image_id);
emits('styleSelected', style, props.image_id);
};
onMounted(() => {
fetchStyles();
});
onUnmounted(() => {
if (observer) {
observer.disconnect();
}
});
</script>
<style scoped>
.style-selector {
@apply bg-white dark:bg-gray-800 !important;
@apply border border-gray-300 dark:border-gray-700;
@apply shadow-lg dark:shadow-none;
@apply text-gray-900 dark:text-white !important;
z-index: 1000;
display: flex;
flex-direction: column;
max-width: 100%; /* Adjusted to fit parent */
max-height: 100%; /* Adjusted to fit parent */
overflow: hidden;
}
.style-selector-header {
display: flex;
align-items: center;
justify-content: center;
position: relative;
margin-bottom: 20px;
padding: 10px;
border-bottom: 1px solid #eee;
}
.style-selector-header h3 {
margin: 0;
@apply dark:text-white;
color: #333;
}
.back-arrow {
position: absolute;
left: 5px; /* Adjusted position */
font-size: 2em; /* Slightly larger */
cursor: pointer;
padding: 10px; /* Larger clickable area */
color: var(--color-text); /* Adapt to theme */
}
.back-arrow:hover {
color: var(--color-background); /* Adjust hover color for dark mode */
background: var(--color-text); /* Adjust hover background for dark mode */
}
.styles-list {
display: flex;
flex-direction: column;
gap: 15px;
padding: 10px;
overflow-y: auto;
}
.style-item {
display: flex;
align-items: center;
padding: 10px;
border: 1px solid #ddd;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.style-item:hover {
background-color: #eef;
}
.style-thumbnail {
width: 120px;
padding-right: 10px;
}
.style-details h4 {
margin: 0;
@apply text-blue-600 dark:text-white;
}
.style-details p {
margin: 5px 0 0;
font-size: 0.9em;
@apply text-gray-600 dark:text-gray-400;
}
</style>