feat: the Site has a videos area and a floating product video (front 4)
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 4m18s
Build and deploy / Publish images (push) Successful in 1m5s

The home lists the six DTF videos with their titles and state; a card opens
a modal player. A product page gets a muted, captioned 30 s floating video
when its file is configured. The files themselves are still to be recorded;
until then the cards say "Em produção".
This commit is contained in:
Cauê Faleiros
2026-11-06 12:44:33 -03:00
parent b10eeead6e
commit 7e22262280
4 changed files with 187 additions and 3 deletions

View File

@@ -116,6 +116,8 @@ try{
await call('Emulation.setDeviceMetricsOverride',{width:1440,height:1100,deviceScaleFactor:1,mobile:false});
await call('Page.navigate',{url:`http://127.0.0.1:${server.address().port}/`});
await waitFor(()=>evaluate(`typeof sel==='function' && typeof pintaEntrega==='function'`),'Site scripts');
assert.equal(await evaluate(`document.querySelectorAll('#videosGrid .videoCard').length`),6);
assert.equal(await evaluate(`document.querySelector('#videosGrid').textContent.includes('Subindo a arte pelo celular')`),true);
// Observe the actual engine, without replacing its placement or rendering.
await evaluate(`(()=>{
const original=encaixar;

View File

@@ -750,6 +750,15 @@ h2 em{font-style:normal;color:var(--laranja)}
<div><span>4</span><div><b>Acompanhe</b><p>Em Minha conta, com aviso no WhatsApp quando ficar pronto.</p></div></div>
</div></section>
<!-- VÍDEOS -->
<section id="videos" class="videos2"><div class="w">
<div class="videosCab">
<div><div class="et">Vídeos</div><h2>A DTF por dentro</h2></div>
<p>Do upload à retirada: o que acontece com a sua arte, sem letra miúda.</p>
</div>
<div class="videosGrid" id="videosGrid"></div>
</div></section>
<!-- ENVIO -->
<section id="envio">
<nav class="passos" id="passos" aria-label="Etapas do pedido" hidden>
@@ -1182,6 +1191,7 @@ h2 em{font-style:normal;color:var(--laranja)}
they share one global scope and run in this order, which is exactly how the
single inline script this replaces behaved. Order is therefore significant. -->
<script src="/site-config.js"></script>
<script src="/site-videos.js"></script>
<script src="/site-modes.js"></script>
<script src="/site-upload.js"></script>
<script src="/site-sheet.js"></script>

View File

@@ -14,9 +14,9 @@ h1,h2,h3,h4{font-family:"Inter",sans-serif}
/* Pages (site-pages.js): the home, a product page and the cart show only their own parts. */
html[data-rota="inicio"] :is(#passos,#foco,#qual,#prev,#carr,.checkout,#carrVazio),
html[data-rota="produto"] :is(.hero2,.etapas2,#cards,#carr,.checkout,#carrVazio,#info),
html[data-rota="carrinho"] :is(.hero2,.etapas2,#cards,#foco,#qual,#prev,#info,.pagCab,.pagResumo){display:none!important}
html:is([data-rota="pagamento"],[data-rota="pix"]) :is(.hero2,.etapas2,#cards,#foco,#qual,#prev,#info,#carr,#carrVazio,#desfazer){display:none!important}
html[data-rota="produto"] :is(.hero2,.etapas2,#videos,#cards,#carr,.checkout,#carrVazio,#info),
html[data-rota="carrinho"] :is(.hero2,.etapas2,#videos,#cards,#foco,#qual,#prev,#info,.pagCab,.pagResumo){display:none!important}
html:is([data-rota="pagamento"],[data-rota="pix"]) :is(.hero2,.etapas2,#videos,#cards,#foco,#qual,#prev,#info,#carr,#carrVazio,#desfazer){display:none!important}
html[data-sem-itens] #carr{display:none!important}
html:not([data-rota="inicio"]) #envio{padding-top:0;padding-bottom:64px;min-height:70vh}
#envio,#foco,#qual,#prev,#checkoutStatus{scroll-margin-top:var(--topo-passos,128px)}
@@ -58,6 +58,31 @@ html:not([data-rota="inicio"]) #envio{padding-top:0;padding-bottom:64px;min-heig
.etapas2 b{font-family:"Inter",sans-serif;font-size:17px}
.etapas2 p{margin-top:3px;font-size:16px;color:var(--fraco)}
section+section{border-top:0}
/* Videos (front 4) */
.videos2{padding:52px 0;border-bottom:1px solid var(--linha);background:#fff}
.videosCab{display:flex;align-items:flex-end;gap:24px;flex-wrap:wrap;margin-bottom:22px}
.videosCab h2{margin-top:8px;font-size:clamp(28px,3vw,38px);font-weight:800;letter-spacing:-.02em}
.videosCab p{margin-left:auto;max-width:440px;font-size:16.5px;color:var(--fraco)}
.videosGrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
.videoCard{position:relative;display:flex;flex-direction:column;align-items:flex-start;gap:8px;min-height:170px;padding:20px;border:1px solid var(--linha);border-radius:14px;background:var(--cinza);color:var(--preto);text-align:left;font:inherit;cursor:pointer}
.videoCard:hover{border-color:var(--laranja)}
.videoCard .vcPlay{display:flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:999px;background:var(--laranja);color:var(--preto);font-size:16px;font-weight:900}
.videoCard b{font-family:"Inter",sans-serif;font-size:17px;line-height:1.25}
.videoCard span{font-size:14.5px;line-height:1.4;color:var(--fraco)}
.videoCard em{margin-top:auto;font-style:normal;font-size:12.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--laranja-escuro)}
.videoCard[data-soon="1"]{cursor:default;opacity:.72}
.videoFloat{position:fixed;right:22px;bottom:22px;z-index:70;width:min(280px,calc(100vw - 32px));border-radius:14px;overflow:hidden;background:var(--preto);box-shadow:0 14px 40px rgba(3,6,11,.35)}
.videoFloat video{display:block;width:100%;height:auto;aspect-ratio:16/9;background:#000}
.videoFloat .vfClose{position:absolute;top:8px;right:8px;width:30px;height:30px;border:0;border-radius:999px;background:rgba(0,0,0,.62);color:#fff;font-size:18px;line-height:1;cursor:pointer}
.videoFloat .vfLabel{padding:8px 12px;color:#fff;font-size:13px;line-height:1.3}
.videoFloat .vfLabel b{display:block;font-family:"Inter",sans-serif;font-size:14px}
.videoModal{position:fixed;inset:0;z-index:120;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(3,6,11,.78)}
.videoModal[hidden]{display:none}
.videoModal .vmBox{position:relative;width:min(920px,100%);border-radius:16px;overflow:hidden;background:#000}
.videoModal video{display:block;width:100%;height:auto;max-height:82vh;background:#000}
.videoModal .vmClose{position:absolute;top:10px;right:10px;width:34px;height:34px;border:0;border-radius:999px;background:rgba(0,0,0,.65);color:#fff;font-size:20px;cursor:pointer}
@media(max-width:900px){.videosGrid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.videosGrid{grid-template-columns:1fr}.videos2{padding:36px 0}}
/* Product chooser */
#envio{padding-top:56px}

147
web/site-videos.js Normal file
View File

@@ -0,0 +1,147 @@
/* 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. */
const VIDEOS = [
{id: 'subindo', title: 'Subindo a arte pelo celular',
desc: 'Do primeiro toque ao preço, sem instalar nada.', product: null,
src: null, captions: null},
{id: 'nota', title: 'O que é a nota da arte — e o que ela não é',
desc: 'A nota explica o arquivo; ela não muda o preço.', product: 'file',
src: null, captions: null},
{id: 'png', title: 'Por que PNG com fundo transparente',
desc: 'O que acontece com JPG e por que o branco sai no filme.', product: 'uvfile',
src: null, captions: null},
{id: 'avulsas', title: 'Montando artes avulsas e vendo a folha ao vivo',
desc: 'A montagem peça por peça, com o encaixe e a metragem.', product: 'avulsa',
src: null, captions: null},
{id: 'retirada', title: 'Retirada em Franca em 24 h',
desc: 'O balcão, o recibo e o que levar.', product: null,
src: null, captions: null},
{id: 'sala', title: 'A sala às 3 da manhã',
desc: 'Por onde o pedido passa até virar filme.', product: null,
src: null, captions: null},
];
function videoElement(video, {controls = false} = {}) {
const el = document.createElement('video');
el.src = video.src;
el.muted = true;
el.playsInline = true;
el.preload = 'metadata';
if (controls) el.controls = true;
if (video.captions) {
const track = document.createElement('track');
track.kind = 'captions';
track.label = 'Português';
track.srclang = 'pt';
track.src = video.captions;
track.default = true;
el.append(track);
}
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() {
const grid = document.getElementById('videosGrid');
if (!grid) return;
for (const video of VIDEOS) {
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 ? '▶' : '…';
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';
card.append(play, title, desc, note);
if (!video.src) {
card.setAttribute('aria-disabled', 'true');
} else {
card.addEventListener('click', () => openVideo(video));
}
grid.append(card);
}
})();
// The category player, opened from a card.
let videoModal = null;
function openVideo(video) {
if (!videoModal) {
videoModal = document.createElement('div');
videoModal.className = 'videoModal';
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();
});
document.body.append(videoModal);
}
const box = videoModal.querySelector('.vmBox');
box.querySelectorAll('video').forEach(el => el.remove());
const player = videoElement(video, {controls: true});
box.append(player);
videoModal.hidden = false;
player.play().catch(() => {});
document.documentElement.classList.add('videoAberto');
}
function closeVideo() {
if (!videoModal) return;
videoModal.querySelectorAll('video').forEach(el => { el.pause(); el.removeAttribute('src'); el.load(); });
videoModal.hidden = true;
document.documentElement.classList.remove('videoAberto');
}
// A floating, muted 30 s video on each product page. It only appears when the
// product has a recorded video; until then the page stays clean.
let floating = null, floatingId = null;
function videoForProduct() {
if (document.documentElement.dataset.rota !== 'produto') return null;
return VIDEOS.find(video => video.src && video.product === modo) || null;
}
function syncFloatingVideo() {
const video = videoForProduct();
if (!video) {
if (floating) { floating.remove(); floating = null; floatingId = null; }
return;
}
if (floating && floatingId === video.id) return;
if (floating) { floating.remove(); floating = null; }
floatingId = video.id;
floating = document.createElement('div');
floating.className = 'videoFloat';
const close = document.createElement('button');
close.type = 'button';
close.className = 'vfClose';
close.setAttribute('aria-label', 'Fechar vídeo');
close.textContent = '×';
close.addEventListener('click', () => { floating.remove(); floating = null; floatingId = null; });
const player = videoElement(video);
player.autoplay = true;
player.loop = false;
// 30 segundos no máximo, como o PDF pede.
player.addEventListener('timeupdate', () => { if (player.currentTime >= 30) player.pause(); });
const label = document.createElement('div');
label.className = 'vfLabel';
const title = document.createElement('b');
title.textContent = video.title;
const desc = document.createElement('span');
desc.textContent = 'Mudo · com legenda · 30 s';
label.append(title, desc);
floating.append(player, close, label);
document.body.append(floating);
player.play().catch(() => {});
}
addEventListener('dtf-page-changed', syncFloatingVideo);
syncFloatingVideo();