Update
This commit is contained in:
281
resources/js/projects-renderer/components/blocks/BlockSlot.vue
Normal file
281
resources/js/projects-renderer/components/blocks/BlockSlot.vue
Normal file
@@ -0,0 +1,281 @@
|
||||
<script setup>
|
||||
import { computed, inject } from 'vue';
|
||||
import { useImageUpload } from '../../composables/useImageUpload';
|
||||
import { useIntersectionActivation } from '../../composables/useIntersectionActivation';
|
||||
import { getBunnyEmbedUrl, getFrameIoEmbedUrl, getYouTubeEmbedUrl } from '../../schema/projectSchema';
|
||||
const props = defineProps({
|
||||
slotData: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
blockId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
slotKey: {
|
||||
type: String,
|
||||
default: 'slot',
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
column: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const uploadUrl = inject('editorUploadUrl', null);
|
||||
const updateBlockImage = inject('editorUpdateBlockImage', null);
|
||||
|
||||
// Image upload for image-type slot
|
||||
const { isDragOver, isUploading, fileInputRef, onDragOver, onDragLeave, onDrop, openPicker, onFileSelected } = useImageUpload(
|
||||
() => uploadUrl?.value ?? null,
|
||||
(url) => updateBlockImage?.(props.blockId, props.slotKey, null, url),
|
||||
);
|
||||
|
||||
const resolveAlt = (alt, fallback) => {
|
||||
if (!alt) return fallback;
|
||||
if (typeof alt === 'string') return alt || fallback;
|
||||
return alt[props.activeLang] || alt[Object.keys(alt)[0]] || fallback;
|
||||
};
|
||||
|
||||
// Video activation
|
||||
const { isActive, target } = useIntersectionActivation();
|
||||
const youtubeUrl = computed(() => getYouTubeEmbedUrl(props.slotData?.media));
|
||||
const frameIoUrl = computed(() => getFrameIoEmbedUrl(props.slotData?.media?.url));
|
||||
const bunnyUrl = computed(() => getBunnyEmbedUrl(props.slotData?.media));
|
||||
|
||||
// Text display
|
||||
const displayContent = computed(() => {
|
||||
const c = props.slotData?.content;
|
||||
if (typeof c === 'string') return c;
|
||||
if (c && typeof c === 'object') {
|
||||
return c[props.activeLang] || c[Object.keys(c)[0]] || '';
|
||||
}
|
||||
return '';
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- TEXT -->
|
||||
<section v-if="slotData.type === 'text'" class="slot-text">
|
||||
<div v-if="displayContent" class="slot-text__body" v-html="displayContent"></div>
|
||||
<p v-else class="slot-text__placeholder">Add narrative copy for this text slot.</p>
|
||||
</section>
|
||||
|
||||
<!-- IMAGE -->
|
||||
<figure
|
||||
v-else-if="slotData.type === 'image'"
|
||||
class="slot-image"
|
||||
:class="{
|
||||
'slot-image--column': column,
|
||||
'slot-image--over': isDragOver,
|
||||
'slot-image--uploading': isUploading,
|
||||
'slot-image--editable': !!uploadUrl?.value,
|
||||
}"
|
||||
@dragover="uploadUrl?.value ? onDragOver($event) : null"
|
||||
@dragleave="onDragLeave"
|
||||
@drop="uploadUrl?.value ? onDrop($event) : null"
|
||||
@click="uploadUrl?.value ? openPicker() : null"
|
||||
>
|
||||
<img v-if="slotData.image?.url" :src="slotData.image.url" :alt="resolveAlt(slotData.image.alt, 'Project image')" loading="lazy">
|
||||
<div v-else class="slot-image__placeholder">
|
||||
{{ isUploading ? 'Uploading…' : (uploadUrl?.value ? 'Drop or click to upload.' : 'Add image URL.') }}
|
||||
</div>
|
||||
<div v-if="isDragOver" class="slot-image__overlay"></div>
|
||||
<div v-if="isUploading && slotData.image?.url" class="slot-image__overlay slot-image__overlay--uploading"></div>
|
||||
<input ref="fileInputRef" type="file" accept="image/*" style="display:none" @change="onFileSelected">
|
||||
</figure>
|
||||
|
||||
<!-- VIDEO -->
|
||||
<section
|
||||
v-else-if="slotData.type === 'video'"
|
||||
ref="target"
|
||||
class="slot-video"
|
||||
:class="{ 'slot-video--column': column }"
|
||||
>
|
||||
<iframe
|
||||
v-if="slotData.media?.type === 'youtube' && isActive && youtubeUrl"
|
||||
:src="youtubeUrl"
|
||||
title="Video slot"
|
||||
loading="lazy"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
<iframe
|
||||
v-else-if="slotData.media?.type === 'frameio' && isActive && frameIoUrl"
|
||||
:src="frameIoUrl"
|
||||
title="Video slot"
|
||||
loading="lazy"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
<div
|
||||
v-else-if="slotData.media?.type === 'bunny' && isActive && bunnyUrl"
|
||||
class="slot-video__bunny"
|
||||
>
|
||||
<iframe
|
||||
:src="bunnyUrl"
|
||||
loading="lazy"
|
||||
style="border:0;position:absolute;top:0;height:100%;width:100%;"
|
||||
allow="accelerometer;gyroscope;autoplay;encrypted-media;picture-in-picture;"
|
||||
allowfullscreen
|
||||
/>
|
||||
</div>
|
||||
<video
|
||||
v-else-if="slotData.media?.type === 'video' && isActive && slotData.media?.url"
|
||||
:autoplay="slotData.media?.autoplay === true"
|
||||
:muted="slotData.media?.muted === true"
|
||||
:loop="slotData.media?.loop === true"
|
||||
controls
|
||||
playsinline
|
||||
preload="metadata"
|
||||
>
|
||||
<source :src="slotData.media.url">
|
||||
</video>
|
||||
<div v-else class="slot-video__placeholder">Add a video URL to render this slot.</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* ---- Text ---- */
|
||||
.slot-text {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
min-height: 8rem;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.slot-text__placeholder {
|
||||
color: var(--project-muted, #6b7280);
|
||||
font-size: clamp(1.05rem, 1.8vw, 1.4rem);
|
||||
line-height: 1.75;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.slot-text__body p),
|
||||
:deep(.slot-text__body h2),
|
||||
:deep(.slot-text__body h3),
|
||||
:deep(.slot-text__body ul),
|
||||
:deep(.slot-text__body ol) {
|
||||
color: var(--project-ink, #111827);
|
||||
font-size: clamp(1.05rem, 1.8vw, 1.4rem);
|
||||
line-height: 1.75;
|
||||
margin: 0 0 0.75em;
|
||||
}
|
||||
|
||||
:deep(.slot-text__body p:last-child),
|
||||
:deep(.slot-text__body h2:last-child),
|
||||
:deep(.slot-text__body ul:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
:deep(.slot-text__body h2) {
|
||||
font-size: clamp(1.3rem, 2.2vw, 1.8rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:deep(.slot-text__body h3) {
|
||||
font-size: clamp(1.1rem, 1.9vw, 1.5rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* ---- Image ---- */
|
||||
.slot-image {
|
||||
aspect-ratio: 16 / 9;
|
||||
background: linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(148, 163, 184, 0.15));
|
||||
border-radius: 1.65rem;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
transition: outline-color 0.15s;
|
||||
}
|
||||
|
||||
.slot-image--column {
|
||||
aspect-ratio: 4 / 4;
|
||||
border-radius: 1.5rem;
|
||||
}
|
||||
|
||||
.slot-image--editable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.slot-image--over {
|
||||
outline: 2px dashed rgba(14, 116, 144, 0.7);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.slot-image img {
|
||||
display: block;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.slot-image--uploading img {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.slot-image__placeholder {
|
||||
align-items: center;
|
||||
color: var(--project-muted, #6b7280);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.slot-image__overlay {
|
||||
background: rgba(14, 116, 144, 0.15);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.slot-image__overlay--uploading {
|
||||
background: rgba(15, 23, 42, 0.3);
|
||||
}
|
||||
|
||||
/* ---- Video ---- */
|
||||
.slot-video {
|
||||
aspect-ratio: 16 / 9;
|
||||
background: linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(148, 163, 184, 0.15));
|
||||
border-radius: 1.65rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slot-video--column {
|
||||
aspect-ratio: 1 / 1;
|
||||
border-radius: 1.5rem;
|
||||
}
|
||||
|
||||
.slot-video iframe,
|
||||
.slot-video video {
|
||||
border: 0;
|
||||
display: block;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.slot-video__bunny {
|
||||
padding-top: 56.25%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.slot-video__placeholder {
|
||||
align-items: center;
|
||||
color: var(--project-muted, #6b7280);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup>
|
||||
import BlockSlot from './BlockSlot.vue';
|
||||
|
||||
defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="block-full-width">
|
||||
<BlockSlot
|
||||
:slot-data="block.slot"
|
||||
:block-id="block.id"
|
||||
slot-key="slot"
|
||||
:active-lang="activeLang"
|
||||
:column="false"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-full-width {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,111 @@
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
import { useImageUpload } from '../../composables/useImageUpload';
|
||||
|
||||
const props = defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const resolveAlt = (alt, fallback) => {
|
||||
if (!alt) return fallback;
|
||||
if (typeof alt === 'string') return alt || fallback;
|
||||
return alt[props.activeLang] || alt[Object.keys(alt)[0]] || fallback;
|
||||
};
|
||||
|
||||
const uploadUrl = inject('editorUploadUrl', null);
|
||||
const updateBlockImage = inject('editorUpdateBlockImage', null);
|
||||
|
||||
const { isDragOver, isUploading, fileInputRef, onDragOver, onDragLeave, onDrop, openPicker, onFileSelected } = useImageUpload(
|
||||
() => uploadUrl?.value ?? null,
|
||||
(url) => updateBlockImage?.(props.block.id, 'image', null, url),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="block-image-full"
|
||||
:class="{ 'block-image-full--over': isDragOver, 'block-image-full--uploading': isUploading, 'block-image-full--editable': !!uploadUrl?.value }"
|
||||
@dragover="uploadUrl?.value ? onDragOver($event) : null"
|
||||
@dragleave="onDragLeave"
|
||||
@drop="uploadUrl?.value ? onDrop($event) : null"
|
||||
@click="uploadUrl?.value ? openPicker() : null"
|
||||
>
|
||||
<img v-if="block.image?.url" :src="block.image.url" :alt="resolveAlt(block.image.alt, 'Project image')" loading="lazy">
|
||||
<div v-else class="block-image-full__placeholder">
|
||||
{{ isUploading ? 'Uploading…' : (uploadUrl?.value ? 'Drop image here or click to upload.' : 'Add a full-width image URL.') }}
|
||||
</div>
|
||||
<div v-if="isDragOver" class="block-image-full__drop-overlay">Drop to upload</div>
|
||||
<div v-if="isUploading && block.image?.url" class="block-image-full__uploading-overlay">Uploading…</div>
|
||||
</section>
|
||||
|
||||
<input ref="fileInputRef" type="file" accept="image/*" style="display:none" @change="onFileSelected">
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-image-full {
|
||||
aspect-ratio: 16 / 9;
|
||||
background: linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(148, 163, 184, 0.15));
|
||||
border-radius: 1.65rem;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
transition: outline-color 0.15s;
|
||||
}
|
||||
|
||||
.block-image-full--editable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.block-image-full--over {
|
||||
outline: 2px dashed rgba(14, 116, 144, 0.7);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block-image-full--uploading img {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.block-image-full__placeholder {
|
||||
align-items: center;
|
||||
color: var(--project-muted, #6b7280);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.block-image-full__drop-overlay,
|
||||
.block-image-full__uploading-overlay {
|
||||
align-items: center;
|
||||
background: rgba(14, 116, 144, 0.55);
|
||||
bottom: 0;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
justify-content: center;
|
||||
left: 0;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.block-image-full__uploading-overlay {
|
||||
background: rgba(15, 23, 42, 0.4);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const displayContent = computed(() => {
|
||||
const c = props.block.content;
|
||||
// Legacy: plain string
|
||||
if (typeof c === 'string') return c;
|
||||
// Object: try active lang, then first available, then empty
|
||||
if (c && typeof c === 'object') {
|
||||
return c[props.activeLang] || c[Object.keys(c)[0]] || '';
|
||||
}
|
||||
return '';
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="block-text">
|
||||
<div v-if="displayContent" class="block-text__body" v-html="displayContent"></div>
|
||||
<p v-else class="block-text__placeholder">Add narrative copy for this full-width text row.</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-text {
|
||||
margin: 0 auto;
|
||||
max-width: 56rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.block-text__placeholder {
|
||||
color: var(--project-muted, #6b7280);
|
||||
font-size: clamp(1.05rem, 1.8vw, 1.4rem);
|
||||
line-height: 1.75;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.block-text__body p),
|
||||
:deep(.block-text__body h2),
|
||||
:deep(.block-text__body h3),
|
||||
:deep(.block-text__body ul),
|
||||
:deep(.block-text__body ol) {
|
||||
color: var(--project-ink, #111827);
|
||||
font-size: clamp(1.05rem, 1.8vw, 1.4rem);
|
||||
line-height: 1.75;
|
||||
margin: 0 0 0.75em;
|
||||
}
|
||||
|
||||
:deep(.block-text__body p:last-child),
|
||||
:deep(.block-text__body h2:last-child),
|
||||
:deep(.block-text__body h3:last-child),
|
||||
:deep(.block-text__body ul:last-child),
|
||||
:deep(.block-text__body ol:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
:deep(.block-text__body h2) {
|
||||
font-size: clamp(1.3rem, 2.2vw, 1.8rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:deep(.block-text__body h3) {
|
||||
font-size: clamp(1.1rem, 1.9vw, 1.5rem);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:deep(.block-text__body ul),
|
||||
:deep(.block-text__body ol) {
|
||||
display: inline-block;
|
||||
padding-left: 1.4rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
:deep(.block-text__body a) {
|
||||
color: #0f766e;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
141
resources/js/projects-renderer/components/blocks/PublicSlot.vue
Normal file
141
resources/js/projects-renderer/components/blocks/PublicSlot.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useIntersectionActivation } from '../../composables/useIntersectionActivation';
|
||||
import { getBunnyEmbedUrl, getFrameIoEmbedUrl, getYouTubeEmbedUrl } from '../../schema/projectSchema';
|
||||
|
||||
const props = defineProps({
|
||||
slotData: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const { isActive, target } = useIntersectionActivation();
|
||||
|
||||
const youtubeUrl = computed(() => getYouTubeEmbedUrl(props.slotData?.media));
|
||||
const frameIoUrl = computed(() => getFrameIoEmbedUrl(props.slotData?.media?.url));
|
||||
const bunnyUrl = computed(() => getBunnyEmbedUrl(props.slotData?.media));
|
||||
|
||||
const displayContent = computed(() => {
|
||||
const c = props.slotData?.content;
|
||||
if (typeof c === 'string') return c;
|
||||
if (c && typeof c === 'object') {
|
||||
return c[props.activeLang] || c[Object.keys(c)[0]] || '';
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
const resolveAlt = (alt, fallback) => {
|
||||
if (!alt) return fallback;
|
||||
if (typeof alt === 'string') return alt || fallback;
|
||||
return alt[props.activeLang] || alt[Object.keys(alt)[0]] || fallback;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- TEXT -->
|
||||
<div v-if="slotData.type === 'text'" class="project-text-block" v-html="displayContent"></div>
|
||||
|
||||
<!-- IMAGE -->
|
||||
<img
|
||||
v-else-if="slotData.type === 'image' && slotData.image?.url"
|
||||
:src="slotData.image.url"
|
||||
:alt="resolveAlt(slotData.image?.alt, '')"
|
||||
loading="lazy"
|
||||
>
|
||||
|
||||
<!-- VIDEO -->
|
||||
<div v-else-if="slotData.type === 'video'" ref="target" class="project-video-wrap">
|
||||
<iframe
|
||||
v-if="slotData.media?.type === 'youtube' && isActive && youtubeUrl"
|
||||
:src="youtubeUrl"
|
||||
title="Project video"
|
||||
loading="lazy"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
<iframe
|
||||
v-else-if="slotData.media?.type === 'frameio' && isActive && frameIoUrl"
|
||||
:src="frameIoUrl"
|
||||
title="Project video"
|
||||
loading="lazy"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
<div v-else-if="slotData.media?.type === 'bunny' && bunnyUrl" class="project-video-wrap__bunny">
|
||||
<iframe
|
||||
v-if="isActive"
|
||||
:src="bunnyUrl"
|
||||
loading="lazy"
|
||||
allow="accelerometer;gyroscope;autoplay;encrypted-media;picture-in-picture;"
|
||||
allowfullscreen
|
||||
/>
|
||||
</div>
|
||||
<video
|
||||
v-else-if="slotData.media?.type === 'video' && isActive && slotData.media?.url"
|
||||
class="project-video"
|
||||
:autoplay="slotData.media?.autoplay === true"
|
||||
:muted="slotData.media?.muted === true"
|
||||
:loop="slotData.media?.loop === true"
|
||||
playsinline
|
||||
>
|
||||
<source :src="slotData.media.url" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
img {
|
||||
display: block;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.project-text-block {
|
||||
color: #f5f5f5;
|
||||
line-height: 1.6;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.project-video-wrap {
|
||||
aspect-ratio: 16 / 9;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.project-video-wrap iframe,
|
||||
.project-video-wrap video {
|
||||
border: 0;
|
||||
display: block;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.project-video-wrap__bunny {
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.project-video-wrap__bunny iframe {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
video.project-video {
|
||||
display: block;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,139 @@
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
import { useImageUpload } from '../../composables/useImageUpload';
|
||||
|
||||
const props = defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const resolveAlt = (alt, fallback) => {
|
||||
if (!alt) return fallback;
|
||||
if (typeof alt === 'string') return alt || fallback;
|
||||
return alt[props.activeLang] || alt[Object.keys(alt)[0]] || fallback;
|
||||
};
|
||||
|
||||
const uploadUrl = inject('editorUploadUrl', null);
|
||||
const updateBlockImage = inject('editorUpdateBlockImage', null);
|
||||
|
||||
const { isDragOver: isDragOver0, isUploading: isUploading0, fileInputRef: fileInputRef0, onDragOver: onDragOver0, onDragLeave: onDragLeave0, onDrop: onDrop0, openPicker: openPicker0, onFileSelected: onFileSelected0 } = useImageUpload(
|
||||
() => uploadUrl?.value ?? null,
|
||||
(url) => updateBlockImage?.(props.block.id, 'images', 0, url),
|
||||
);
|
||||
|
||||
const { isDragOver: isDragOver1, isUploading: isUploading1, fileInputRef: fileInputRef1, onDragOver: onDragOver1, onDragLeave: onDragLeave1, onDrop: onDrop1, openPicker: openPicker1, onFileSelected: onFileSelected1 } = useImageUpload(
|
||||
() => uploadUrl?.value ?? null,
|
||||
(url) => updateBlockImage?.(props.block.id, 'images', 1, url),
|
||||
);
|
||||
|
||||
const dragHandlers = [
|
||||
{ isDragOver: isDragOver0, isUploading: isUploading0, fileInputRef: fileInputRef0, onDragOver: onDragOver0, onDragLeave: onDragLeave0, onDrop: onDrop0, openPicker: openPicker0, onFileSelected: onFileSelected0 },
|
||||
{ isDragOver: isDragOver1, isUploading: isUploading1, fileInputRef: fileInputRef1, onDragOver: onDragOver1, onDragLeave: onDragLeave1, onDrop: onDrop1, openPicker: openPicker1, onFileSelected: onFileSelected1 },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="block-images-split">
|
||||
<figure
|
||||
v-for="(image, index) in block.images"
|
||||
:key="`${block.id}-${index}`"
|
||||
:class="{
|
||||
'block-images-split__figure--over': dragHandlers[index]?.isDragOver.value,
|
||||
'block-images-split__figure--uploading': dragHandlers[index]?.isUploading.value,
|
||||
'block-images-split__figure--editable': !!uploadUrl?.value,
|
||||
}"
|
||||
@dragover="uploadUrl?.value ? dragHandlers[index]?.onDragOver($event) : null"
|
||||
@dragleave="dragHandlers[index]?.onDragLeave()"
|
||||
@drop="uploadUrl?.value ? dragHandlers[index]?.onDrop($event) : null"
|
||||
@click="uploadUrl?.value ? dragHandlers[index]?.openPicker() : null"
|
||||
>
|
||||
<img v-if="image?.url" :src="image.url" :alt="resolveAlt(image.alt, `Project image ${index + 1}`)" loading="lazy">
|
||||
<div v-else class="block-images-split__placeholder">
|
||||
{{ dragHandlers[index]?.isUploading.value ? 'Uploading…' : (uploadUrl?.value ? 'Drop or click to upload.' : `Drop in image URL ${index + 1}`) }}
|
||||
</div>
|
||||
<div v-if="dragHandlers[index]?.isDragOver.value" class="block-images-split__overlay">Drop to upload</div>
|
||||
<div v-if="dragHandlers[index]?.isUploading.value && image?.url" class="block-images-split__overlay block-images-split__overlay--uploading">Uploading…</div>
|
||||
<input :ref="dragHandlers[index]?.fileInputRef" type="file" accept="image/*" style="display:none" @change="dragHandlers[index]?.onFileSelected($event)">
|
||||
</figure>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-images-split {
|
||||
display: grid;
|
||||
gap: 1.4rem;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
figure {
|
||||
aspect-ratio: 4 / 4;
|
||||
background: linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(148, 163, 184, 0.15));
|
||||
border-radius: 1.5rem;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
transition: outline-color 0.15s;
|
||||
}
|
||||
|
||||
.block-images-split__figure--editable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.block-images-split__figure--over {
|
||||
outline: 2px dashed rgba(14, 116, 144, 0.7);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block-images-split__figure--uploading img {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.block-images-split__placeholder {
|
||||
align-items: center;
|
||||
color: var(--project-muted, #6b7280);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.block-images-split__overlay {
|
||||
align-items: center;
|
||||
background: rgba(14, 116, 144, 0.55);
|
||||
bottom: 0;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 700;
|
||||
justify-content: center;
|
||||
left: 0;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.block-images-split__overlay--uploading {
|
||||
background: rgba(15, 23, 42, 0.4);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.block-images-split {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup>
|
||||
import BlockSlot from './BlockSlot.vue';
|
||||
|
||||
defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
activeLang: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="block-two-columns">
|
||||
<BlockSlot
|
||||
:slot-data="block.left"
|
||||
:block-id="block.id"
|
||||
slot-key="left"
|
||||
:active-lang="activeLang"
|
||||
:column="true"
|
||||
/>
|
||||
<BlockSlot
|
||||
:slot-data="block.right"
|
||||
:block-id="block.id"
|
||||
slot-key="right"
|
||||
:active-lang="activeLang"
|
||||
:column="true"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-two-columns {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
gap: 1.4rem;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,90 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useIntersectionActivation } from '../../composables/useIntersectionActivation';
|
||||
import { getBunnyEmbedUrl, getFrameIoEmbedUrl, getYouTubeEmbedUrl } from '../../schema/projectSchema';
|
||||
|
||||
const props = defineProps({
|
||||
block: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { isActive, target } = useIntersectionActivation();
|
||||
const youtubeUrl = computed(() => getYouTubeEmbedUrl(props.block?.media));
|
||||
const frameIoUrl = computed(() => getFrameIoEmbedUrl(props.block?.media?.url));
|
||||
const bunnyUrl = computed(() => getBunnyEmbedUrl(props.block?.media));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section ref="target" class="block-video">
|
||||
<iframe
|
||||
v-if="block.media?.type === 'youtube' && isActive && youtubeUrl"
|
||||
:src="youtubeUrl"
|
||||
title="Project video block"
|
||||
loading="lazy"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
|
||||
<iframe
|
||||
v-else-if="block.media?.type === 'frameio' && isActive && frameIoUrl"
|
||||
:src="frameIoUrl"
|
||||
title="Project video block"
|
||||
loading="lazy"
|
||||
allow="autoplay; fullscreen; picture-in-picture"
|
||||
allowfullscreen
|
||||
/>
|
||||
|
||||
<iframe
|
||||
v-else-if="block.media?.type === 'bunny' && isActive && bunnyUrl"
|
||||
:src="bunnyUrl"
|
||||
title="Project video block"
|
||||
loading="lazy"
|
||||
style="border:0;position:absolute;top:0;height:100%;width:100%;"
|
||||
allow="accelerometer;gyroscope;autoplay;encrypted-media;picture-in-picture;"
|
||||
allowfullscreen
|
||||
/>
|
||||
|
||||
<video
|
||||
v-else-if="block.media?.type === 'video' && isActive && block.media?.url"
|
||||
:autoplay="block.media?.autoplay === true"
|
||||
:muted="block.media?.muted === true"
|
||||
:loop="block.media?.loop === true"
|
||||
controls
|
||||
playsinline
|
||||
preload="metadata"
|
||||
>
|
||||
<source :src="block.media.url">
|
||||
</video>
|
||||
|
||||
<div v-else class="block-video__placeholder">Add a video block URL to render this row.</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.block-video {
|
||||
aspect-ratio: 16 / 9;
|
||||
background: linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(148, 163, 184, 0.15));
|
||||
border-radius: 1.65rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
iframe,
|
||||
video {
|
||||
border: 0;
|
||||
display: block;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block-video__placeholder {
|
||||
align-items: center;
|
||||
color: var(--project-muted, #6b7280);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user