성능
주의프레임 속도: 평균 60 fps, p5 59.9 · 긴 작업: 0개, 총 0 ms, 최장 0 ms · 소스 gzip 10 KB · 런타임 285 KB
Upload dropzoneMIT폼Bencho
Lorenzo Cabra가 만든 폼 React 컴포넌트입니다. MIT 라이선스에 따라 Bencho에서 수정 없이 수집했으며 여기서 실시간으로 보여 줍니다.
품질 보고
등급과 점수는 빌드 또는 테스트 때 실행한 자동 검사에서 나옵니다. 실행하지 않은 항목은 '미검사'로 표시하며, 숫자를 지어내지 않습니다.
프레임 속도: 평균 60 fps, p5 59.9 · 긴 작업: 0개, 총 0 ms, 최장 0 ms · 소스 gzip 10 KB · 런타임 285 KB
문제 2 · 스크린 리더: 주의
지속 움직임 없음
넘침 없음
프레임 속도와 긴 작업 수치는 헤드리스 Chromium에서 소프트웨어 WebGL로 측정했습니다. 이 사이트의 컴포넌트끼리만 비교해야 하며, 실제 기기의 성능이 아닙니다.
해당 없음: 정지 상태에서 보이는 애니메이션이 없습니다. 호버로 시작되는 애니메이션은 검사하지 않았습니다.

검사일 2026년 11월 15일 · 수치는 자동 스크립트에서 오며, 손으로 쓴 예시가 아닙니다.
실제 크기로 보여 줍니다.
복사한 내용은 라이선스 고지로 시작합니다. 코드를 쓸 때 남겨 두세요.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* Upload.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ══ Upload dropzone ═════════════════════════════════════ */
.upl {
display: flex;
flex-direction: column;
gap: 12px;
width: 300px;
font-family: var(--font-ui);
color: var(--fill-on, var(--ink));
user-select: none;
-webkit-user-select: none;}
/* a slot of fixed size, so the box can close in round an upload
without moving anything below it */
.upl-zone-wrap {
flex: none;
display: flex;
align-items: center;
justify-content: center;
height: 176px;}
.upl-zone {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
width: 100%;
/* 176, up from 128: the drop target is the block, and a short
one read as a banner rather than a place to put something */
height: 176px;
padding: 0 16px;
overflow: hidden;
border-radius: var(--upl-r);
background: var(--fill-slab, var(--card));
/* a file over it and it grows, with a bounce; an upload and it
closes in round it */
transition:
scale 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
width 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
height 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
background-color 220ms ease;}
.upl-zone[data-over] { scale: 1.02; }
/* the gulp: in a little as the file goes down, out past its size,
and settle */
.upl-zone[data-gulp] { animation: upl-gulp 460ms cubic-bezier(0.3, 1.2, 0.4, 1); }
.upl-zone[data-gulp] .upl-icon { animation: upl-open 460ms cubic-bezier(0.3, 1.4, 0.4, 1); }
[data-stroke="on"] .upl-zone { box-shadow: 0 0 0 1px var(--pane-edge); }
.upl-icon {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border-radius: 10px;
/* a light grey tile, no edge — the fill's own ink walked most
of the way to its slab, so it is a pale grey on the light fill
and a lifted grey on the dark one */
background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));
color: color-mix(in srgb, var(--fill-on, #17181a) 72%, var(--fill-slab, #ffffff));
transition: translate 420ms cubic-bezier(0.24, 1.34, 0.38, 1), background-color 220ms ease, color 220ms ease;}
/* over the box the tile only lifts, and its arrow goes to full
ink — no colour of its own */
.upl-zone[data-over] .upl-icon {
translate: 0 -4px;
color: var(--fill-on, var(--ink));}
.upl-say {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
font-size: 13px;
text-align: center;
letter-spacing: 0em;}
.upl-say b { font-weight: 500; }
.upl-say span {
font-size: 12px;
color: color-mix(in srgb, var(--fill-on, #17181a) 52%, var(--fill-slab, #ffffff));
letter-spacing: 0em;}
.upl-zone[data-refuse] .upl-say b { color: #e5484d; }
/* the file, arrived in the box */
.upl-now {
display: flex;
align-items: center;
gap: 12px;
width: max-content;
flex: none;
animation: upl-land 420ms var(--upl-spring) both;}
.upl-text {
display: flex;
flex-direction: column;
gap: 4px;
width: 150px;}
.upl-name {
overflow: hidden;
font-size: 13px;
font-weight: 500;
white-space: nowrap;
text-overflow: ellipsis;
letter-spacing: 0em;}
.upl-meta {
display: flex;
align-items: center;
gap: 4px;
height: 14px;
font-size: 12px;
font-variant-numeric: tabular-nums;
color: color-mix(in srgb, var(--fill-on, #17181a) 52%, var(--fill-slab, #ffffff));
letter-spacing: 0em;}
.upl-track {
position: relative;
height: 4px;
margin-top: 4px;
overflow: hidden;
border-radius: 2px;
background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));}
.upl-bar {
position: absolute;
inset: 0;
border-radius: inherit;
background: var(--signal, #2231dd);
transform-origin: left center;}
.upl-roll { display: inline-flex; line-height: 1em; height: 1em; overflow: hidden; }
.upl-roll-col { display: inline-block; height: 1em; overflow: hidden; }
.upl-roll-strip {
display: flex;
flex-direction: column;
transition: transform 220ms cubic-bezier(0.24, 1.34, 0.38, 1);}
.upl-roll-strip > span { height: 1em; }
.upl-end {
display: grid;
place-items: center;
flex: none;
width: 22px;
height: 22px;}
.upl-tick {
display: grid;
place-items: center;
flex: none;
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--ok, #15803d);
color: #fff;
animation: upl-pop 380ms cubic-bezier(0.3, 1.6, 0.4, 1) both;}
/* the tray: three files lying under the box */
.upl-tray {
display: flex;
justify-content: center;
gap: 20px;}
.upl-slot {
position: relative;
width: 76px;
height: 75px;}
.upl-file {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding-top: 4px;
cursor: grab;
touch-action: none;
outline: none;
/* home is a spring; the Bounce knob sets its overshoot */
transition: transform 420ms var(--upl-spring), opacity 220ms ease;}
.upl-file[data-held] {
z-index: 5;
cursor: grabbing;
transition: none;}
.upl-file[data-gone] { opacity: 0; pointer-events: none; transition: none; }
.upl-file:not([data-gone]) { animation: upl-back 360ms var(--upl-spring) both; }
.upl-file:focus-visible .upl-page { outline: 2px solid var(--signal, #2231dd); outline-offset: 3px; border-radius: 6px; }
.upl-page { overflow: visible; }
.upl-page-line {
stroke: color-mix(in srgb, var(--fill-on, #17181a) 32%, var(--fill-slab, #ffffff));
stroke-width: 1.5;
/* outline only: the page is drawn, not filled */
fill: none;}
.upl-page-ext {
fill: #fff;
font-family: var(--font-ui);
/* size is the <text>'s own fontSize, in the icon's units */
font-weight: 500;
letter-spacing: 0em;}
.upl-label {
max-width: 76px;
overflow: hidden;
font-size: 11px;
white-space: nowrap;
text-overflow: ellipsis;
color: color-mix(in srgb, var(--fill-on, #17181a) 72%, var(--fill-slab, #ffffff));
letter-spacing: 0em;}
/* the tray sits on the STAGE, not on the block, so when Fill
takes the block the other way from the page its names would be
coloured for the wrong ground — light grey on a light stage.
Across that split they take the page's own ink instead. */
/* the page's outline goes with its name, the same colour */
:root:not([data-theme="dark"]) [data-fill="dark"] .upl-label { color: color-mix(in srgb, var(--fill-on, var(--ink)) 70%, #ffffff); }
:root:not([data-theme="dark"]) [data-fill="dark"] .upl-page-line { stroke: color-mix(in srgb, var(--fill-on, var(--ink)) 70%, #ffffff); }
:root[data-theme="dark"] [data-fill="light"] .upl-label { color: color-mix(in srgb, #f4f3f1 70%, var(--fill-on, var(--ink))); }
:root[data-theme="dark"] [data-fill="light"] .upl-page-line { stroke: color-mix(in srgb, #f4f3f1 70%, var(--fill-on, var(--ink))); }
@keyframes upl-gulp {
0% { scale: 1.02; }
35% { scale: 0.985; }
70% { scale: 1.006; }
100% { scale: 1; }}
@keyframes upl-open { 40% { scale: 1.08; } }
@keyframes upl-land { from { opacity: 0; scale: 0.85; translate: 0 10px; } }
@keyframes upl-pop { from { scale: 0; } }
@keyframes upl-back { from { scale: 0.7; opacity: 0; } }
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/upload-dropzone/Upload.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/upload-dropzone/Upload.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { motion, useAnimationControls } from "motion/react";
import { IconCheck as Check, IconUpload as UpIcon } from "@tabler/icons-react";
/* ══ Upload dropzone ══════════════════════════════════════
A drop box, and three files lying on a tray under it. Pick
one up and carry it into the box: it uploads there — name,
a rolling percentage, a bar — ticks, and goes back to the
tray so you can do it again.
── NO REAL FILES ───────────────────────────────────────
The files are part of the block. Nothing is read from the
desktop and nothing is sent anywhere; the drag is an ordinary
pointer drag inside the block, which is also what lets the
wall's scripted cursor demonstrate it.
── THE BOX INHALES, AND SWALLOWS ───────────────────────
A plain filled box, no edge. A file carried over it is
answered before it is let go: the box grows with a small
bounce and the arrow lifts toward the hand. Let go and the
file is SUCKED in — it accelerates toward the box's middle,
shrinking and drawing out long as it goes — and the box gives
a little gulp before the upload appears in it. Let go
anywhere else and the file springs home.
── ONE OF THEM IS TOO BIG ──────────────────────────────
The limit is fixed at 5 MB and the video is always over it,
so dropping it shakes the box, says so in red and the file
springs home. The picture always goes. */
/* ── inlined from lab/spring ──────────────────────── */
/* ── one spring, for everything that settles ───────────────
The maths was already on this bench twice, copied by hand:
Humidity's wheel and Brightness's column both accumulate
velocity toward a target, damp it, and snap when both the
delta and the velocity fall under 0.02. Two copies is a
coincidence; five would be a policy, so it comes out here
before the elastic blocks are written against it.
The two shipped copies are deliberately NOT refactored onto
this. They work, they are tuned, and rewriting the innards
of two live components to prove a point about duplication
is how a good afternoon becomes a bad one. This is the one
new code uses.
Frames, not milliseconds. `dt` is expressed in sixtieths of
a second and the damping is RAISED to it rather than
multiplied by it, so a dropped frame decays the same amount
of energy as the two frames it replaced. Multiplying is the
version that makes a spring behave differently on a busy
page, which is the hardest kind of bug to see.
The loop parks itself the moment the value has settled.
CLAUDE.md is not complimentary about the one permanent
requestAnimationFrame already on this bench and there is no
case for five more. */
/* Read once, the way the wheel and the pill nav do. A
preference, not a live input. */
const stillness = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
const MAX = 5;
/* what it says the second time, and after */
const SNARK = [
"Still 12.6 MB. It didn't shrink.",
"Pushing harder won't help",
"Have you tried compressing it?",
"The box is full of excuses now",
"No.",
];
type F = { id: string; name: string; ext: string; size: number; tint: string };
const FILES: F[] = [
{ id: "img", name: "mood.png", ext: "PNG", size: 2.4e6, tint: "#079455" },
{ id: "vid", name: "demo.mp4", ext: "MP4", size: 12.6e6, tint: "#155EEF" },
];
const fmt = (b: number) => (b >= 1e6 ? `${(b / 1e6).toFixed(1)} MB` : `${Math.round(b / 1e3)} KB`);
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
/* ── the file icon ─────────────────────────────────────────
After Untitled UI's: a rounded page on a 40 grid with a thin
grey outline and a folded corner, and the extension on a
coloured label that sticks out past the page's left edge —
the colour carries the kind before the word is read. */
function Page({ f, size = 40 }: { f: F; size?: number }) {
return (
<svg className="upl-page" width={size} height={size} viewBox="0 0 40 40" fill="none" aria-hidden="true">
<path
className="upl-page-line"
d="M7.75 4A3.25 3.25 0 0 1 11 .75h16c.121 0 .238.048.323.134l10.793 10.793a.46.46 0 0 1 .134.323v24A3.25 3.25 0 0 1 35 39.25H11A3.25 3.25 0 0 1 7.75 36z"
/>
<path className="upl-page-line" d="M27 .5V8a4 4 0 0 0 4 4h7.5" />
<rect width="29" height="16" x="1" y="18" rx="8" fill={f.tint} />
{/* 9 units on the 40 grid: the mark is part of the drawing and
scales with it, so its size lives here, not in the stylesheet */}
<text x="15.5" y="29.1" textAnchor="middle" fontSize="9" className="upl-page-ext">{f.ext}</text>
</svg>
);
}
function Roll({ value }: { value: number }) {
const s = String(Math.round(value));
return (
<span className="upl-roll" aria-label={`${s}%`}>
{s.split("").map((d, i) => (
<span key={s.length - i} className="upl-roll-col">
<span className="upl-roll-strip" style={{ transform: `translateY(${-Number(d)}em)` }}>
{"0123456789".split("").map((n) => <span key={n}>{n}</span>)}
</span>
</span>
))}
%
</span>
);
}
type Phase = { kind: "idle" } | { kind: "up"; f: F; p: number } | { kind: "done"; f: F };
export function Upload({
/* how fast a file sends, 0..100 */
speed = 50,
/* how springy a file flies home, 0..100 */
bounce = 40,
corner = 20,
}: {
speed?: number;
bounce?: number;
corner?: number;
} = {}) {
const still = stillness();
const [phase, setPhase] = useState<Phase>({ kind: "idle" });
const [inBox, setInBox] = useState<string | null>(null);
const [held, setHeld] = useState<string | null>(null);
const [over, setOver] = useState(false);
/* what the box says when it refuses — null while it is not */
const [refuse, setRefuse] = useState<string | null>(null);
const tries = useRef(0);
const cool = useRef(0);
const [gulp, setGulp] = useState(false);
const zone = useRef<HTMLDivElement>(null);
const now = useRef<HTMLSpanElement>(null);
const tiles = useRef<Record<string, HTMLDivElement | null>>({});
const shake = useAnimationControls();
const raf = useRef(0);
const timers = useRef<number[]>([]);
const knobs = useRef({ speed });
knobs.current = { speed };
useEffect(() => () => {
cancelAnimationFrame(raf.current);
raf.current = 0;
timers.current.forEach(clearTimeout);
clearTimeout(cool.current);
}, []);
const later = (fn: () => void, ms: number) => { timers.current.push(window.setTimeout(fn, ms)); };
/* ── the pretend wire ──────────────────────────────────── */
const send = (f: F) => {
setInBox(f.id);
if (still) { finish(f); return; }
setPhase({ kind: "up", f, p: 0 });
let p = 0;
let prev = 0;
const secs = (4 - (clamp(knobs.current.speed, 0, 100) / 100) * 3.2) * (0.7 + Math.min(1, f.size / 5e6) * 0.6);
const tick = (t: number) => {
const dt = prev ? Math.min(0.05, (t - prev) / 1000) : 0;
prev = t;
/* uneven on purpose: a steady climb reads as a timer */
p = Math.min(1, p + (dt / secs) * (0.4 + Math.random() * 1.2));
if (p >= 1) { raf.current = 0; finish(f); return; }
setPhase({ kind: "up", f, p });
raf.current = requestAnimationFrame(tick);
};
raf.current = requestAnimationFrame(tick);
};
const finish = (f: F) => {
tries.current = 0;
setPhase({ kind: "done", f });
/* the file goes back to the tray, ready to go again */
later(() => { setPhase({ kind: "idle" }); setInBox(null); }, 1500);
};
/* ── trying again ─────────────────────────────────────────
The first refusal is plain. Try the same file again and the
box starts to answer back, a new line each time, the last one
repeating — until a file that fits goes through, which puts it
back to being polite. */
const refuseIt = () => {
const n = tries.current++;
setRefuse(n === 0 ? `Too big — up to ${MAX} MB` : SNARK[Math.min(n - 1, SNARK.length - 1)]);
shake.start({ x: [0, -7, 6, -4, 2, 0], transition: { duration: 0.42 } });
later(() => setRefuse(null), 1800);
/* "in a row" means close together: leave it alone a while and
the next refusal is the polite one again */
clearTimeout(cool.current);
cool.current = window.setTimeout(() => { tries.current = 0; }, 8000);
};
/* ── carrying a file ───────────────────────────────────── */
const drag = useRef<null | { id: string; x0: number; y0: number; k: number }>(null);
const place = (id: string, dx: number, dy: number, lift: boolean) => {
const el = tiles.current[id];
if (!el) return;
el.style.transform = `translate(${dx}px, ${dy}px) scale(${lift ? 1.08 : 1}) rotate(${lift ? clamp(dx * 0.04, -6, 6) : 0}deg)`;
};
const hits = (e: React.PointerEvent) => {
const r = zone.current?.getBoundingClientRect();
return !!r && e.clientX > r.left && e.clientX < r.right && e.clientY > r.top && e.clientY < r.bottom;
};
const onDown = (f: F) => (e: React.PointerEvent<HTMLDivElement>) => {
if (inBox === f.id) return;
try { e.currentTarget.setPointerCapture(e.pointerId); } catch { /* a scripted pointer */ }
const k = e.currentTarget.getBoundingClientRect().width / e.currentTarget.offsetWidth || 1;
drag.current = { id: f.id, x0: e.clientX, y0: e.clientY, k };
setHeld(f.id);
place(f.id, 0, 0, true);
};
const onMove = (e: React.PointerEvent) => {
const g = drag.current;
if (!g) return;
place(g.id, (e.clientX - g.x0) / g.k, (e.clientY - g.y0) / g.k, true);
const on = hits(e) && phase.kind === "idle";
if (on !== over) {
setOver(on);
}
};
const onUp = (f: F) => (e: React.PointerEvent<HTMLDivElement>) => {
const g = drag.current;
drag.current = null;
try { e.currentTarget.releasePointerCapture(e.pointerId); } catch { /* never captured */ }
setHeld(null);
setOver(false);
if (!g) return;
const inside = hits(e);
if (inside && phase.kind === "idle") {
if (f.size > MAX * 1e6) refuseIt();
else {
suck(f, (e.clientX - g.x0) / g.k, (e.clientY - g.y0) / g.k, g.k);
return;
}
}
/* springs home */
place(f.id, 0, 0, false);
};
/* ── the suction ──────────────────────────────────────────
From where it was let go to the box's middle, on an ease-IN:
slow to leave and faster the nearer it gets, which is what
reads as being pulled rather than as flying. It shrinks as it
goes and draws out long in the direction of travel, then the
box gulps and the upload takes its place. */
const suck = (f: F, dx: number, dy: number, k: number) => {
const el = tiles.current[f.id];
const z = zone.current;
if (!el || !z || still) { place(f.id, 0, 0, false); send(f); return; }
const a = el.getBoundingClientRect();
const b = z.getBoundingClientRect();
const tx = dx + (b.left + b.width / 2 - (a.left + a.width / 2)) / k;
const ty = dy + (b.top + b.height / 2 - (a.top + a.height / 2)) / k;
/* drawn out along the pull, never turned: a tile rotated to
face its travel went upside down on the way up and spun on
a short pull. Up or down it goes tall, sideways it goes
wide, and a pull too short to have a direction only shrinks */
const ux = Math.abs(tx - dx);
const uy = Math.abs(ty - dy);
const squeeze = Math.hypot(ux, uy) < 24 ? "scale(0.16)" : uy >= ux ? "scale(0.14, 0.34)" : "scale(0.34, 0.14)";
el.style.transition = "transform 380ms cubic-bezier(0.55, 0, 0.85, 0.3), opacity 300ms ease-in 80ms";
el.style.transform = `translate(${tx}px, ${ty}px) ${squeeze}`;
el.style.opacity = "0";
/* the upload starts as the tile goes down the hole, not after
it has finished vanishing: waiting out the whole pull left a
beat where the box sat empty, reading as a freeze */
later(() => { setGulp(true); later(() => setGulp(false), 460); }, 200);
later(() => send(f), 220);
later(() => {
/* put the tile home unseen, ready to pop back later */
el.style.transition = "none";
el.style.transform = "";
el.style.opacity = "";
}, 390);
};
/* ── the box hugs the upload ─────────────────────────────
While a file is in it the box closes in round the upload row
— measured, because the row is as wide as its name — and
grows a little when the tick arrives; back to idle it opens
out to the full drop box again. Width and height, never a
scale, so its corner stays the corner. It shrinks inside a
slot of fixed size, so nothing below it moves. */
useLayoutEffect(() => {
const z = zone.current;
const n = now.current;
if (!z) return;
if (phase.kind === "idle" || !n) {
z.style.width = "";
z.style.height = "";
return;
}
z.style.width = `${n.offsetWidth + 32}px`;
z.style.height = `${n.offsetHeight + 28}px`;
}, [phase.kind]);
const r = Math.max(0, corner);
const up = phase.kind !== "idle";
const f = phase.kind !== "idle" ? phase.f : null;
return (
<div
className="upl"
data-held={held ? true : undefined}
style={{ "--upl-r": `${r}px`, "--upl-spring": `cubic-bezier(0.3, ${1 + (bounce / 100) * 0.9}, 0.4, 1)` } as React.CSSProperties}
>
<motion.div animate={shake} className="upl-zone-wrap">
<div
ref={zone}
className="upl-zone"
data-over={over || undefined}
data-refuse={refuse ? true : undefined}
data-busy={up || undefined}
data-gulp={gulp || undefined}
aria-live="polite"
>
{!f ? (
<>
<span className="upl-icon"><UpIcon size={18} strokeWidth={2} /></span>
<span className="upl-say">
<b>{refuse ?? (over ? "Drop to upload" : "Drag a file here")}</b>
<span>Up to {MAX} MB</span>
</span>
</>
) : (
<span className="upl-now" key={f.id} ref={now}>
<Page f={f} size={36} />
<span className="upl-text">
<span className="upl-name">{f.name}</span>
<span className="upl-meta">
{fmt(f.size)} · {phase.kind === "done" ? "Uploaded" : <Roll value={phase.kind === "up" ? phase.p * 100 : 0} />}
</span>
<span className="upl-track">
<span className="upl-bar" style={{ transform: `scaleX(${phase.kind === "up" ? phase.p : 1})` }} />
</span>
</span>
{/* the tick's room is kept from the start, so the box
is its final size before the tick arrives */}
<span className="upl-end">
{phase.kind === "done" && <span className="upl-tick"><Check size={14} strokeWidth={2} /></span>}
</span>
</span>
)}
</div>
</motion.div>
<div className="upl-tray">
{FILES.map((file) => (
<div key={file.id} className="upl-slot" data-empty={inBox === file.id || undefined}>
<div
ref={(el) => { tiles.current[file.id] = el; }}
className="upl-file"
data-held={held === file.id || undefined}
data-gone={inBox === file.id || undefined}
role="button"
tabIndex={0}
aria-label={`${file.name}, ${fmt(file.size)}. Drag into the box to upload, or press Enter.`}
onPointerDown={onDown(file)}
onPointerMove={onMove}
onPointerUp={onUp(file)}
onPointerCancel={onUp(file)}
onKeyDown={(e) => {
if ((e.key === "Enter" || e.key === " ") && phase.kind === "idle" && inBox !== file.id) {
e.preventDefault();
if (file.size > MAX * 1e6) refuseIt();
else send(file);
}
}}
>
<Page f={file} />
<span className="upl-label">{file.name}</span>
</div>
</div>
))}
</div>
</div>
);
}컨트롤 · HTML · CSS · JS
코드를 고치고 컨트롤로 다듬어 보세요. 입력하는 대로 미리보기가 바뀝니다.

이 컴포넌트는 번들된 빌드로 실행되므로 여기서는 스크립트를 읽기만 할 수 있습니다. HTML과 CSS는 수정할 수 있고 전체 소스는 코드 탭에 있습니다.
모든 컴포넌트를 바로 편집하고, 컨트롤로 다듬고, 전체 소스를 내려받고, 고급 프롬프트를 복사하세요.
1회 결제 $49임시 가격
테스트 모드: 실제 결제는 이루어지지 않습니다.
무료: 미리보기, 복사 버튼, 레슨 설명.
묶인 입력칸과 주 버튼 하나로 다음 단계가 분명해집니다.
가입, 문의, 결제 단계.
칸 사이 간격, 버튼 색, 오류 표시를 조정합니다.
Bencho (github.com/cabralorenzo/bencho)(MIT)의 "Upload dropzone" 컴포넌트를 내 React + Tailwind CSS 앱에 추가해 줘. 소스 파일: https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/upload-dropzone/Upload.tsx. 묶인 입력칸과 주 버튼 하나로 다음 단계가 분명해집니다. 사용처: 가입, 문의, 결제 단계. 조정할 설정: 칸 사이 간격, 버튼 색, 오류 표시를 조정합니다. 라이트와 다크 테마를 지원하고 prefers-reduced-motion을 존중해 줘. MIT 라이선스 고지는 유지해 줘.
조정, 접근성, 연동 단계까지 담은 긴 프롬프트입니다.