02YouTube lite facade — an embed that switches to a full frame once elapsed time crosses a set point
The time elapsed since the card appeared is continuously recomputed, and the instant it crosses a set threshold, the lightweight thumbnail-only card switches itself into the look of a real playback frame.
Best forCutting initial load on video-heavy listing pages, data-saving mobile blog layouts
datasetaria-livematchMedia

<main class="stage">
<section class="panel">
<div class="card" id="card" data-state="lite">
<div class="thumbWrap">
<canvas class="thumb" id="thumb" width="320" height="180" aria-hidden="true"></canvas>
<div class="playBtn" role="button" aria-label="Play">
<svg class="playIcon" viewBox="0 0 24 24" aria-hidden="true"><polygon points="7,4 20,12 7,20"></polygon></svg>
</div>
<span class="badgeLite">Lite</span>
<span class="cardTitleLite">Lightweight thumbnail card</span>
<div class="frameTop">
<span class="frameTopTitle">Ready to play</span>
</div>
<div class="frameBottom">
<div class="progressTrack">
<div class="progressFill" id="progressFill"></div>
</div>
<span class="timeLabel" id="timeLabel">0:00 / 0:12</span>
</div>
</div>
</div>
<div class="readout" id="readout" aria-live="polite">Elapsed 0.00s · switch 1.2s</div>
</section>
</main>@use "../../../../site/static/demo-tokens" as *;
@include stage($stage-yellow);
.panel {
display: flex;
flex-direction: column;
align-items: center;
gap: $sp-3;
}
.card {
position: relative;
}
.thumbWrap {
position: relative;
width: 190px;
aspect-ratio: 16 / 9;
border-radius: $r-card;
overflow: hidden;
box-shadow: $shadow-raised;
}
.thumb {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
.playBtn {
position: absolute;
inset: 0;
display: grid;
place-items: center;
transition: opacity $dur-quick $ease-out;
}
.playIcon {
width: 30px;
height: 30px;
filter: drop-shadow(0 2px 4px rgba(23, 20, 26, .4));
polygon {
fill: $subject-cream;
}
}
.badgeLite {
position: absolute;
top: $sp-2;
left: $sp-2;
padding: $sp-1 $sp-2;
border-radius: $r-pill;
background: rgba(23, 20, 26, .66);
color: $subject-cream;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 9px;
line-height: 1.3;
transition: opacity $dur-quick $ease-out;
}
.cardTitleLite {
position: absolute;
inset: auto 0 0 0;
padding: $sp-2 $sp-3;
background: rgba(23, 20, 26, .66);
color: $subject-cream;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 11px;
line-height: 1.3;
transition: opacity $dur-quick $ease-out;
}
.frameTop {
position: absolute;
inset: 0 0 auto 0;
padding: $sp-2 $sp-3;
background: rgba(23, 20, 26, .66);
opacity: 0;
transition: opacity $dur-quick $ease-out;
}
.frameTopTitle {
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 11px;
line-height: 1.3;
color: $subject-cream;
opacity: .96;
}
.frameBottom {
position: absolute;
inset: auto 0 0 0;
display: flex;
align-items: center;
gap: $sp-2;
padding: $sp-2 $sp-3;
background: rgba(23, 20, 26, .66);
opacity: 0;
transition: opacity $dur-quick $ease-out;
}
.progressTrack {
flex: 1 1 auto;
height: 4px;
border-radius: $r-xs;
background: rgba($subject-cream, .3);
overflow: hidden;
}
.progressFill {
width: 100%;
height: 100%;
transform-origin: left center;
transform: scaleX(0);
background: $subject-cream;
}
.timeLabel {
flex: 0 0 auto;
font-family: "Space Mono", ui-monospace, monospace;
font-weight: 700;
font-size: 9px;
line-height: 1.3;
color: $subject-cream;
opacity: .96;
}
.card[data-state='frame'] .badgeLite,
.card[data-state='frame'] .cardTitleLite,
.card[data-state='frame'] .playBtn {
opacity: 0;
}
.card[data-state='frame'] .frameTop,
.card[data-state='frame'] .frameBottom {
opacity: 1;
}
.readout {
display: inline-flex;
align-items: center;
padding: $sp-1 $sp-3;
border-radius: $r-pill;
background: $subject-cream;
color: $subject-ink;
font-family: "Space Mono", ui-monospace, monospace;
font-weight: 700;
font-size: 12px;
line-height: 1.3;
}
@media (max-width: 340px) {
.thumbWrap { width: 138px; }
.playIcon { width: 22px; height: 22px; }
.badgeLite { font-size: 8px; }
.cardTitleLite { font-size: 10px; }
.frameTopTitle { font-size: 10px; }
.timeLabel { font-size: 8px; }
.readout { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
.playBtn,
.badgeLite,
.cardTitleLite,
.frameTop,
.frameBottom {
transition: none;
}
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.panel {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.card {
position: relative;
}
.thumbWrap {
position: relative;
width: 190px;
aspect-ratio: 16/9;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.thumb {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
.playBtn {
position: absolute;
inset: 0;
display: grid;
place-items: center;
transition: opacity 220ms ease-out;
}
.playIcon {
width: 30px;
height: 30px;
filter: drop-shadow(0 2px 4px rgba(23, 20, 26, 0.4));
}
.playIcon polygon {
fill: #fff7e6;
}
.badgeLite {
position: absolute;
top: 8px;
left: 8px;
padding: 4px 8px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.66);
color: #fff7e6;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 9px;
line-height: 1.3;
transition: opacity 220ms ease-out;
}
.cardTitleLite {
position: absolute;
inset: auto 0 0 0;
padding: 8px 12px;
background: rgba(23, 20, 26, 0.66);
color: #fff7e6;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 11px;
line-height: 1.3;
transition: opacity 220ms ease-out;
}
.frameTop {
position: absolute;
inset: 0 0 auto 0;
padding: 8px 12px;
background: rgba(23, 20, 26, 0.66);
opacity: 0;
transition: opacity 220ms ease-out;
}
.frameTopTitle {
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
font-weight: 600;
font-size: 11px;
line-height: 1.3;
color: #fff7e6;
opacity: 0.96;
}
.frameBottom {
position: absolute;
inset: auto 0 0 0;
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: rgba(23, 20, 26, 0.66);
opacity: 0;
transition: opacity 220ms ease-out;
}
.progressTrack {
flex: 1 1 auto;
height: 4px;
border-radius: 4px;
background: rgba(255, 247, 230, 0.3);
overflow: hidden;
}
.progressFill {
width: 100%;
height: 100%;
transform-origin: left center;
transform: scaleX(0);
background: #fff7e6;
}
.timeLabel {
flex: 0 0 auto;
font-family: "Space Mono", ui-monospace, monospace;
font-weight: 700;
font-size: 9px;
line-height: 1.3;
color: #fff7e6;
opacity: 0.96;
}
.card[data-state=frame] .badgeLite,
.card[data-state=frame] .cardTitleLite,
.card[data-state=frame] .playBtn {
opacity: 0;
}
.card[data-state=frame] .frameTop,
.card[data-state=frame] .frameBottom {
opacity: 1;
}
.readout {
display: inline-flex;
align-items: center;
padding: 4px 12px;
border-radius: 999px;
background: #fff7e6;
color: #17141a;
font-family: "Space Mono", ui-monospace, monospace;
font-weight: 700;
font-size: 12px;
line-height: 1.3;
}
@media (max-width: 340px) {
.thumbWrap {
width: 138px;
}
.playIcon {
width: 22px;
height: 22px;
}
.badgeLite {
font-size: 8px;
}
.cardTitleLite {
font-size: 10px;
}
.frameTopTitle {
font-size: 10px;
}
.timeLabel {
font-size: 8px;
}
.readout {
font-size: 11px;
}
}
@media (prefers-reduced-motion: reduce) {
.playBtn,
.badgeLite,
.cardTitleLite,
.frameTop,
.frameBottom {
transition: none;
}
}// 가벼운 파사드 임베드(02) — Elapsed 시간이 임계값(FACADE_DELAY)을 넘는 순간
// data-state 를 'lite' → 'frame' 으로 바꾸는 상태 머신. 실키·실서버 요청 없음.
(function () {
function mulberry32(seed) {
var a = seed >>> 0;
return function () {
a |= 0; a = (a + 0x6D2B79F5) | 0;
var t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
function drawSeedThumb(canvas, seed) {
var ctx = canvas.getContext('2d');
if (!ctx) return;
var rnd = mulberry32(seed);
var w = canvas.width, h = canvas.height;
var hues = [216, 32, 268, 168];
ctx.fillStyle = 'hsl(' + hues[Math.floor(rnd() * hues.length)] + ', 38%, 22%)';
ctx.fillRect(0, 0, w, h);
for (var i = 0; i < 6; i++) {
var cx = rnd() * w, cy = rnd() * h, r = (0.18 + rnd() * 0.3) * Math.min(w, h);
ctx.fillStyle = 'hsla(' + hues[Math.floor(rnd() * hues.length)] + ', ' + (44 + rnd() * 22).toFixed(1) + '%, ' + (38 + rnd() * 26).toFixed(1) + '%, .5)';
ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.fill();
}
ctx.fillStyle = 'rgba(255, 247, 230, .06)';
for (var j = 0; j < h; j += 4) ctx.fillRect(0, j, w, 1);
}
var cardEl = document.getElementById('card');
var thumbEl = document.getElementById('thumb');
var progressFillEl = document.getElementById('progressFill');
var timeLabelEl = document.getElementById('timeLabel');
var readoutEl = document.getElementById('readout');
if (!cardEl || !thumbEl || !progressFillEl || !timeLabelEl || !readoutEl) return;
drawSeedThumb(thumbEl, 102);
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var CYCLE_MS = 2000;
var FACADE_DELAY = 1200;
var TOTAL_SEC = 12;
var transitionSec = (FACADE_DELAY / 1000).toFixed(1);
function apply(t) {
var isFrame = t >= FACADE_DELAY;
cardEl.dataset.state = isFrame ? 'frame' : 'lite';
var progress = isFrame ? (t - FACADE_DELAY) / (CYCLE_MS - FACADE_DELAY) : 0;
progressFillEl.style.transform = 'scaleX(' + progress.toFixed(4) + ')';
var sec = Math.floor(progress * TOTAL_SEC);
timeLabelEl.textContent = '0:' + String(sec).padStart(2, '0') + ' / 0:12';
readoutEl.textContent = 'Elapsed ' + (t / 1000).toFixed(2) + 's · switch ' + transitionSec + 's';
}
apply(0);
if (reduce) return;
var start = null;
function loop(ts) {
if (start === null) start = ts;
var t = (ts - start) % CYCLE_MS;
apply(t);
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
})();import { useEffect, useRef } from "react";
import styles from "./EmbedYoutubeLiteFacade.module.scss";
// 가벼운 파사드 임베드 — 경과 시간이 임계값(FACADE_DELAY)을 넘는 순간
// data-state 를 'lite' → 'frame' 으로 바꾸는 상태 머신. 실키·실서버 요청 없음.
const CYCLE_MS = 2000;
const FACADE_DELAY = 1200;
const TOTAL_SEC = 12;
function mulberry32(seed: number) {
let a = seed >>> 0;
return function () {
a |= 0; a = (a + 0x6D2B79F5) | 0;
let t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
function drawSeedThumb(canvas: HTMLCanvasElement, seed: number) {
const ctx = canvas.getContext("2d");
if (!ctx) return;
const rnd = mulberry32(seed);
const w = canvas.width, h = canvas.height;
const hues = [216, 32, 268, 168];
ctx.fillStyle = "hsl(" + hues[Math.floor(rnd() * hues.length)] + ", 38%, 22%)";
ctx.fillRect(0, 0, w, h);
for (let i = 0; i < 6; i++) {
const cx = rnd() * w, cy = rnd() * h, r = (0.18 + rnd() * 0.3) * Math.min(w, h);
ctx.fillStyle = "hsla(" + hues[Math.floor(rnd() * hues.length)] + ", " + (44 + rnd() * 22).toFixed(1) + "%, " + (38 + rnd() * 26).toFixed(1) + "%, .5)";
ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.fill();
}
ctx.fillStyle = "rgba(255, 247, 230, .06)";
for (let j = 0; j < h; j += 4) ctx.fillRect(0, j, w, 1);
}
export default function EmbedYoutubeLiteFacade() {
const cardRef = useRef<HTMLDivElement>(null);
const thumbRef = useRef<HTMLCanvasElement>(null);
const progressFillRef = useRef<HTMLDivElement>(null);
const timeLabelRef = useRef<HTMLSpanElement>(null);
const readoutRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const card = cardRef.current;
const thumb = thumbRef.current;
const progressFill = progressFillRef.current;
const timeLabel = timeLabelRef.current;
const readout = readoutRef.current;
if (!card || !thumb || !progressFill || !timeLabel || !readout) return;
drawSeedThumb(thumb, 102);
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const transitionSec = (FACADE_DELAY / 1000).toFixed(1);
function apply(t: number) {
const isFrame = t >= FACADE_DELAY;
card!.dataset.state = isFrame ? "frame" : "lite";
const progress = isFrame ? (t - FACADE_DELAY) / (CYCLE_MS - FACADE_DELAY) : 0;
progressFill!.style.transform = "scaleX(" + progress.toFixed(4) + ")";
const sec = Math.floor(progress * TOTAL_SEC);
timeLabel!.textContent = "0:" + String(sec).padStart(2, "0") + " / 0:12";
readout!.textContent = "경과 " + (t / 1000).toFixed(2) + "초 · 전환 " + transitionSec + "초";
}
apply(0);
if (reduce) return;
let start: number | null = null;
let raf = 0;
function loop(ts: number) {
if (start === null) start = ts;
const t = (ts - start) % CYCLE_MS;
apply(t);
raf = requestAnimationFrame(loop);
}
raf = requestAnimationFrame(loop);
return () => cancelAnimationFrame(raf);
}, []);
return (
<div className={styles.stage}>
<section className={styles.panel}>
<div className={styles.card} ref={cardRef} data-state="lite">
<div className={styles.thumbWrap}>
<canvas className={styles.thumb} ref={thumbRef} width={320} height={180} aria-hidden="true" />
<div className={styles.playBtn} role="button" aria-label="재생">
<svg className={styles.playIcon} viewBox="0 0 24 24" aria-hidden="true">
<polygon points="7,4 20,12 7,20" />
</svg>
</div>
<span className={styles.badgeLite}>라이트</span>
<span className={styles.cardTitleLite}>가벼운 썸네일 카드</span>
<div className={styles.frameTop}>
<span className={styles.frameTopTitle}>재생 준비 완료</span>
</div>
<div className={styles.frameBottom}>
<div className={styles.progressTrack}>
<div className={styles.progressFill} ref={progressFillRef} />
</div>
<span className={styles.timeLabel} ref={timeLabelRef}>0:00 / 0:12</span>
</div>
</div>
</div>
<div className={styles.readout} ref={readoutRef} aria-live="polite">경과 0.00초 · 전환 1.2초</div>
</section>
</div>
);
}02 YouTube lite facade — an embed that switches to a full frame once elapsed time crosses a set point — Measured area 7.068% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · 9 YouTube Embed Code UI Patterns (Copy-Paste)
The post this demo lives in
9 YouTube Embed Code UI Patterns (Copy-Paste)Nine embed UIs: a frame's height recomputes from its width, a lite facade times itself into a full frame after a delay, See all demos in this post
If you like this effect - similar demos
Embeds01 Copy button that says it copied9 Code Block UI Patterns — No Highlighter Library
Embeds03 Notification list that splits read from unread9 Activity Feed UI Widgets — Sidebar-Ready Lists
Embeds08 Unit toggle that converts every number on the card at onceWeather Widget Design — 9 Widgets, No Library