fix: align proof, treatment, metrics and site videos with PDF
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s

This commit is contained in:
Cauê Faleiros
2026-11-06 15:27:48 -03:00
parent f4cd1842ca
commit a712c69aca
30 changed files with 631 additions and 110 deletions

View File

@@ -1,9 +1,4 @@
/* Site DTF — vídeos da categoria DTF e o vídeo flutuante por produto (frente 4).
O espaço e o player ficam prontos agora; os seis arquivos entram quando a
Dropstar gravar. Para publicar um vídeo, coloque o MP4/WebM em web/videos/
e preencha `src` (e, se houver, `captions`) abaixo. `product` liga o vídeo
ao modo do produto: file, avulsa, uvfile ou uv. */
/* Site DTF — the public catalog is filled by videos published in Gestão. */
const VIDEOS = [
{id: 'subindo', title: 'Subindo a arte pelo celular',
desc: 'Do primeiro toque ao preço, sem instalar nada.', product: null,
@@ -32,6 +27,7 @@ function videoElement(video, {controls = false} = {}) {
el.playsInline = true;
el.preload = 'metadata';
if (controls) el.controls = true;
if (controls) el.tabIndex = 0;
if (video.captions) {
const track = document.createElement('track');
track.kind = 'captions';
@@ -44,54 +40,68 @@ function videoElement(video, {controls = false} = {}) {
return el;
}
// The category strip: six cards. A card without a file says it is being made
// instead of opening a broken player.
(function videosSection() {
// The category shows only videos with a published file.
function videosSection() {
const grid = document.getElementById('videosGrid');
if (!grid) return;
for (const video of VIDEOS) {
const published=VIDEOS.filter(video=>video.src);
document.getElementById('videos').hidden=!published.length;
grid.replaceChildren();
for (const video of published) {
const card = document.createElement('button');
card.type = 'button';
card.className = 'videoCard';
card.dataset.video = video.id;
if (!video.src) card.dataset.soon = '1';
const play = document.createElement('span');
play.className = 'vcPlay';
play.textContent = video.src ? '▶' : '…';
play.textContent = '▶';
const title = document.createElement('b');
title.textContent = video.title;
const desc = document.createElement('span');
desc.textContent = video.desc;
const note = document.createElement('em');
note.textContent = video.src ? 'Assistir · 30 s' : 'Em produção';
note.textContent = 'Assistir · 30 s';
card.append(play, title, desc, note);
if (!video.src) {
card.setAttribute('aria-disabled', 'true');
} else {
card.addEventListener('click', () => openVideo(video));
}
card.addEventListener('click', () => openVideo(video, card));
grid.append(card);
}
})();
}
videosSection();
// The category player, opened from a card.
let videoModal = null;
function openVideo(video) {
let videoReturnFocus = null;
function openVideo(video, trigger=document.activeElement) {
videoReturnFocus = trigger;
if (!videoModal) {
videoModal = document.createElement('div');
videoModal.className = 'videoModal';
videoModal.setAttribute('role', 'dialog');
videoModal.setAttribute('aria-modal', 'true');
videoModal.setAttribute('aria-label', 'Vídeo: '+video.title);
videoModal.hidden = true;
videoModal.innerHTML = '<div class="vmBox"><button type="button" class="vmClose" aria-label="Fechar vídeo">×</button></div>';
videoModal.addEventListener('click', event => {
if (event.target === videoModal || event.target.closest('.vmClose')) closeVideo();
});
videoModal.addEventListener('keydown', event => {
if (event.key === 'Escape') { event.preventDefault(); closeVideo(); return; }
if (event.key !== 'Tab') return;
const focusable = [...videoModal.querySelectorAll('button,video[controls]')];
const first=focusable[0], last=focusable[focusable.length-1];
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
});
document.body.append(videoModal);
}
const box = videoModal.querySelector('.vmBox');
box.querySelectorAll('video').forEach(el => el.remove());
const player = videoElement(video, {controls: true});
player.addEventListener('timeupdate', () => { if (player.currentTime >= 30) player.pause(); });
box.append(player);
videoModal.hidden = false;
videoModal.setAttribute('aria-label', 'Vídeo: '+video.title);
videoModal.querySelector('.vmClose').focus();
player.play().catch(() => {});
document.documentElement.classList.add('videoAberto');
}
@@ -100,6 +110,8 @@ function closeVideo() {
videoModal.querySelectorAll('video').forEach(el => { el.pause(); el.removeAttribute('src'); el.load(); });
videoModal.hidden = true;
document.documentElement.classList.remove('videoAberto');
videoReturnFocus?.focus();
videoReturnFocus = null;
}
// A floating, muted 30 s video on each product page. It only appears when the
@@ -136,7 +148,7 @@ function syncFloatingVideo() {
const title = document.createElement('b');
title.textContent = video.title;
const desc = document.createElement('span');
desc.textContent = 'Mudo · com legenda · 30 s';
desc.textContent = video.captions ? 'Mudo · com legenda · 30 s' : 'Mudo · 30 s';
label.append(title, desc);
floating.append(player, close, label);
document.body.append(floating);
@@ -145,3 +157,11 @@ function syncFloatingVideo() {
addEventListener('dtf-page-changed', syncFloatingVideo);
syncFloatingVideo();
window.siteVideosReady=fetch('/api/site/videos').then(response=>response.ok?response.json():null).then(data=>{
for(const published of data?.videos||[]){
const video=VIDEOS.find(item=>item.id===published.id);
if(video){video.src=published.src;video.captions=published.captions;video.product=published.product;}
}
videosSection();
syncFloatingVideo();
}).catch(()=>{});