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

검사일 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;
}
}
/* VoiceNote.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.
*/
/* ══ Voice note ═══════════════════════════════════════════ */
/* a fixed frame, so opening the pill never rescales the block */
.vn-frame {
position: relative;
width: 300px;
height: 156px;
display: grid;
place-items: center;}
.vn {
--red: #e5484d;
position: relative;
width: var(--w);
height: 56px;
border-radius: var(--r);
overflow: hidden;
background: var(--fill-slab, var(--card));
color: var(--fill-on, var(--ink));
font-family: var(--font-ui);
font-size: 16px;
font-weight: 500;
user-select: none;
-webkit-user-select: none;
touch-action: none;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
/* y1 past 1 is the overshoot; Bounce sets it */
transition:
width 420ms cubic-bezier(0.3, var(--ov), 0.4, 1),
scale 220ms cubic-bezier(0.22, 1, 0.36, 1);
letter-spacing: -0.01em;}
[data-stroke="on"] .vn { box-shadow: inset 0 0 0 1px var(--pane-edge); }
.vn[data-phase="clip"] { cursor: default; }
.vn:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--fill-slab, #fff), 0 0 0 4px var(--signal, #2231dd);}
.vn-in {
position: absolute;
inset: 0;
display: flex;
align-items: center;
white-space: nowrap;
animation: vn-in 240ms ease 80ms both;}
.vn-idle { justify-content: center; gap: 12px; }
.vn-rec { gap: 12px; padding: 0 24px; }
.vn-clip { gap: 12px; padding: 0 12px 0 8px; }
.vn-time {
font-variant-numeric: tabular-nums;
min-width: 38px;
opacity: 0.6;}
.vn-rec .vn-time { opacity: 1; }
.vn-dot {
width: 9px;
height: 9px;
flex: none;
border-radius: 50%;
background: var(--red);
animation: vn-blink 1s ease-in-out infinite;}
.vn-wave {
flex: 1;
height: 32px;
display: flex;
align-items: center;
justify-content: space-between;
/* the wave goes quiet as you drag toward throwing it away */
opacity: calc(1 - var(--pull) * 0.7);}
.vn-bar {
width: 3px;
flex: none;
height: calc(4px + var(--l) * 28px);
border-radius: 2px;
background: currentColor;
transition: height 160ms linear;}
/* each new sample grows in from the middle */
.vn-rec .vn-bar { animation: vn-grow 200ms cubic-bezier(0.3, 1.5, 0.4, 1) both; }
/* the playhead: a bar is lit once progress has passed it */
.vn-scrub { cursor: ew-resize; }
.vn-scrub .vn-bar {
transition: none;
opacity: clamp(0.3, calc((var(--prog) * var(--n) - var(--i)) * 99), 1);}
/* thrown away: the bars fold to nothing before the pill closes */
.vn[data-phase="cancel"] .vn-in { animation: none; }
.vn[data-phase="cancel"] .vn-bar {
scale: 1 0;
opacity: 0;
transition: scale 220ms ease, opacity 220ms ease;}
.vn[data-phase="cancel"] .vn-dot,
.vn[data-phase="cancel"] .vn-time,
.vn[data-phase="cancel"] button { opacity: 0; transition: opacity 160ms ease; }
.vn-play, .vn-x {
display: grid;
place-items: center;
flex: none;
padding: 0;
border: 0;
cursor: pointer;
font: inherit;
-webkit-tap-highlight-color: transparent;
transition: scale 160ms cubic-bezier(0.22, 1, 0.36, 1), color 160ms ease;}
.vn-play {
width: 44px;
height: 44px;
border-radius: var(--inner);
background: var(--fill-on, var(--ink));
color: var(--fill-slab, var(--card));}
.vn-x {
width: 32px;
height: 32px;
border-radius: 50%;
background: none;
color: color-mix(in srgb, var(--fill-on, var(--ink)) 50%, var(--fill-slab, var(--card)));}
.vn-x:hover { color: var(--fill-on, var(--ink)); }
.vn-play:active, .vn-x:active { scale: 0.96; }
.vn-play:focus-visible, .vn-x:focus-visible {
outline: 2px solid var(--signal, #2231dd);
outline-offset: 2px;}
.vn-hint {
position: absolute;
left: 0;
right: 0;
top: calc(50% + 42px);
text-align: center;
font-family: var(--font-ui);
font-size: 13px;
color: var(--ink-3);
opacity: 0;
pointer-events: none;
transition: opacity 220ms ease;
letter-spacing: 0em;}
.vn-hint[data-on] { opacity: calc(1 - var(--pull, 0)); }
.vn-hint[data-armed] { opacity: 1; color: var(--red, #e5484d); }
/* the row fades as it slides, so the cancel mark has the left
end of the pill to itself when it arrives */
.vn-rec { opacity: calc(1 - var(--pull) * 0.55); }
/* the dot and the clock are gone before the mark lands on them */
.vn-rec .vn-dot, .vn-rec .vn-time { opacity: max(0, 1 - var(--pull) * 1.6); }
.vn-cancel {
position: absolute;
left: 14px;
top: 50%;
width: 28px;
height: 28px;
margin-top: -14px;
display: grid;
place-items: center;
border-radius: 50%;
background: #e5484d;
color: #fff;
opacity: 0;
scale: 0.4;
pointer-events: none;
transition: opacity 160ms ease, scale 160ms ease;}
.vn-cancel[data-on] {
opacity: 1;
scale: 1;
transition: opacity 160ms ease, scale 420ms cubic-bezier(0.24, 1.34, 0.38, 1);}
.vn[data-phase="cancel"] .vn-cancel { opacity: 0; scale: 0.6; transition: opacity 220ms ease, scale 220ms ease; }
@keyframes vn-in { from { opacity: 0; } }
@keyframes vn-blink { 50% { opacity: 0.25; } }
@keyframes vn-grow { from { scale: 1 0.2; } }
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/voice-note/VoiceNote.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/voice-note/VoiceNote.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, useRef, useState } from "react";
import { IconX as X } from "@tabler/icons-react";
/* ══ Voice note ═══════════════════════════════════════════
Hold to record. The pill opens into a bar and the level
rises in it as bars, newest on the right. Let go and the
recording becomes a clip: press play and the bars light up
as the playhead passes them, drag across them to scrub.
Slide left while holding and it is thrown away — the bars
collapse and the pill closes back to where it started.
── A CONCEPT, NOT A RECORDER ───────────────────────
Nothing listens. The level is a stand-in shaped like speech —
syllables inside phrases, with pauses — so the block is about
the gesture and the shapes, and asks nobody for a microphone.
── THE PLAYHEAD IS A NUMBER, NOT A RENDER ──────────────
Progress is one CSS variable on the wave, and each bar
decides its own brightness from it and its index in calc().
Playing costs no React renders at all. */
/* 56 tall and 17px type, the Slide to confirm pill's size, so the
pills on the wall read as one family */
const H = 56;
const IDLE_W = 216;
const OPEN_W = 300;
/* one bar per sample while recording */
const SAMPLE = 70;
/* pointer travel, in px, that throws the recording away */
const CANCEL = 90;
/* shorter than this is a tap, not a recording */
const MIN_MS = 500;
const MAX_MS = 30000;
type Phase = "idle" | "rec" | "cancel" | "clip";
type Clip = { raw: number[]; ms: number };
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
/* speech, roughly: syllables inside phrases, and gaps between */
function standIn(t: number) {
const syll = Math.abs(Math.sin(t * 6.1) * Math.sin(t * 1.9 + 0.7));
const phrase = Math.sin(t * 0.9 + 0.4) > -0.55 ? 1 : 0.1;
return Math.min(1, 0.06 + syll * phrase * (0.5 + Math.random() * 0.5));
}
/* n bars from however many samples, each the loudest it covers */
function resample(src: number[], n: number) {
if (!src.length) return Array(n).fill(0);
return Array.from({ length: n }, (_, i) => {
const a = Math.floor((i * src.length) / n);
const b = Math.max(a + 1, Math.floor(((i + 1) * src.length) / n));
let m = 0;
for (let k = a; k < b && k < src.length; k++) m = Math.max(m, src[k]);
return m;
});
}
const fmt = (ms: number) => {
const s = Math.floor(ms / 1000);
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
};
/* ── play into pause, drawn ─────────────────────────────────
The same two quadrilaterals, wound the same way: the pause's
bars, and the play triangle split down its own axis. */
const PLAY = [[7, 4, 13, 7.6, 13, 16.4, 7, 20], [13, 7.6, 19, 12, 19, 12, 13, 16.4]];
const PAUSE = [[7, 5, 10.5, 5, 10.5, 19, 7, 19], [13.5, 5, 17, 5, 17, 19, 13.5, 19]];
function PlayMark({ on }: { on: boolean }) {
const [t, setT] = useState(on ? 1 : 0);
const now = useRef(t);
now.current = t;
useEffect(() => {
const from = now.current;
const to = on ? 1 : 0;
const t0 = performance.now();
let raf = 0;
const step = (ts: number) => {
const u = Math.min(1, (ts - t0) / 220);
setT(from + (to - from) * (1 - Math.pow(1 - u, 4)));
if (u < 1) raf = requestAnimationFrame(step);
};
raf = requestAnimationFrame(step);
return () => cancelAnimationFrame(raf);
}, [on]);
const d = PLAY.map((q, k) => {
const p = q.map((v, i) => (v + (PAUSE[k][i] - v) * t).toFixed(2));
return `M${p[0]} ${p[1]}L${p[2]} ${p[3]}L${p[4]} ${p[5]}L${p[6]} ${p[7]}Z`;
}).join("");
return (
<svg width="20" height="20" viewBox="0 0 24 24" aria-hidden="true">
<path d={d} fill="currentColor" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" />
</svg>
);
}
/* the capsule filled, the stand drawn: solid like the play
mark it becomes a clip beside, rather than lucide's outline */
function MicMark() {
return (
<svg width="21" height="21" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" aria-hidden="true">
<rect x="8.5" y="2" width="7" height="12.5" rx="3.5" fill="currentColor" stroke="none" />
<path d="M5 11.5a7 7 0 0 0 14 0" />
<path d="M12 18.5V22" />
</svg>
);
}
export function VoiceNote({
/* how many bars the wave is drawn with */
bars = 28,
/* how tall a given level draws, 0..100 */
gain = 60,
/* how far the pill overshoots as it opens and closes, 0..100 */
bounce = 40,
corner = H / 2,
}: {
bars?: number;
gain?: number;
bounce?: number;
corner?: number;
} = {}) {
const [phase, setPhase] = useState<Phase>("idle");
const [levels, setLevels] = useState<number[]>([]);
const [ms, setMs] = useState(0);
const [clip, setClip] = useState<Clip | null>(null);
const [playing, setPlaying] = useState(false);
const [pull, setPull] = useState(0);
const pullRef = useRef(0);
const ph = useRef<Phase>("idle");
const raw = useRef<number[]>([]);
const t0 = useRef(0);
const timer = useRef(0);
const later = useRef(0);
const x0 = useRef(0);
const wave = useRef<HTMLDivElement>(null);
const time = useRef<HTMLSpanElement>(null);
const prog = useRef(0);
const praf = useRef(0);
const scrub = useRef(false);
const clipRef = useRef<Clip | null>(null);
clipRef.current = clip;
const go = (p: Phase) => {
ph.current = p;
setPhase(p);
};
const n = Math.round(clamp(bars, 12, 48));
const g = 0.4 + (clamp(gain, 0, 100) / 100) * 1.2;
const r = clamp(corner, 0, H / 2);
/* the play disc sits 6 inside: concentric once there is a
curve to follow, square with the pill when there is not */
const inner = Math.max(0, r - 6 * Math.min(1, r / 12));
useEffect(() => () => {
clearInterval(timer.current);
clearTimeout(later.current);
cancelAnimationFrame(praf.current);
}, []);
const paintProg = () => {
wave.current?.style.setProperty("--prog", prog.current.toFixed(4));
const c = clipRef.current;
if (time.current && c) {
const p = prog.current;
time.current.textContent = fmt(p > 0 && p < 1 ? p * c.ms : c.ms);
}
};
const stopPlay = () => {
cancelAnimationFrame(praf.current);
praf.current = 0;
setPlaying(false);
};
const close = (_how: "whisk" | "tock") => {
go("cancel");
clearTimeout(later.current);
later.current = window.setTimeout(() => {
setClip(null);
pullRef.current = 0;
setPull(0);
go("idle");
}, 360);
};
const end = (cancel: boolean) => {
if (ph.current !== "rec") return;
clearInterval(timer.current);
const took = performance.now() - t0.current;
const keep = !cancel && took >= MIN_MS;
if (!keep) {
close(cancel ? "whisk" : "tock");
return;
}
prog.current = 0;
setClip({ raw: raw.current.slice(), ms: took });
pullRef.current = 0;
setPull(0);
go("clip");
};
const begin = () => {
if (ph.current !== "idle") return;
raw.current = [];
setLevels([]);
setMs(0);
pullRef.current = 0;
setPull(0);
t0.current = performance.now();
go("rec");
clearInterval(timer.current);
timer.current = window.setInterval(() => {
const took = performance.now() - t0.current;
raw.current.push(standIn(took / 1000));
setLevels(raw.current.slice(-64));
setMs(took);
if (took >= MAX_MS) end(false);
}, SAMPLE);
};
const toggle = () => {
const c = clipRef.current;
if (!c) return;
if (praf.current) {
stopPlay();
return;
}
if (prog.current >= 1) prog.current = 0;
setPlaying(true);
let prev = performance.now();
const step = (ts: number) => {
if (!scrub.current) prog.current = Math.min(1, prog.current + (ts - prev) / c.ms);
prev = ts;
paintProg();
if (prog.current >= 1) {
stopPlay();
return;
}
praf.current = requestAnimationFrame(step);
};
praf.current = requestAnimationFrame(step);
};
const seek = (clientX: number) => {
const el = wave.current;
const c = clipRef.current;
if (!el || !c) return;
const b = el.getBoundingClientRect();
prog.current = clamp((clientX - b.left) / b.width, 0, 1);
paintProg();
};
const discard = () => {
stopPlay();
close("whisk");
};
/* ── the bars ─────────────────────────────────────────── */
const bar = (v: number, i: number, key: string | number) => (
<i
key={key}
className="vn-bar"
style={{ "--l": clamp(v * g, 0, 1).toFixed(3), "--i": i } as React.CSSProperties}
/>
);
/* recording: the last n samples, right-aligned, and the rest
of the row the resting dot a bar starts from */
const recBars = () => {
const start = raw.current.length - levels.length;
const out = [];
for (let j = 0; j < n; j++) {
const k = levels.length - n + j;
out.push(k >= 0 ? bar(levels[k], j, start + k) : bar(0, j, `e${j}`));
}
return out;
};
const shift = -pull * CANCEL * 0.5;
const armed = pull >= 1;
const open = phase !== "idle";
const showClip = clip && (phase === "clip" || phase === "cancel");
return (
<div className="vn-frame">
<div
className="vn"
data-phase={phase}
role={phase === "idle" || phase === "rec" ? "button" : undefined}
tabIndex={phase === "idle" || phase === "rec" ? 0 : -1}
aria-label={phase === "rec" ? "Recording. Release to keep, Escape to discard." : phase === "idle" ? "Hold to record a voice note" : undefined}
style={{
"--w": `${open ? OPEN_W : IDLE_W}px`,
"--r": `${r}px`,
"--inner": `${inner}px`,
"--ov": (1 + (clamp(bounce, 0, 100) / 100) * 0.7).toFixed(3),
"--pull": pull.toFixed(3),
} as React.CSSProperties}
onPointerDown={(e) => {
if (ph.current !== "idle") return;
try { e.currentTarget.setPointerCapture(e.pointerId); } catch { /* a scripted pointer */ }
x0.current = e.clientX;
begin();
}}
onPointerMove={(e) => {
if (ph.current !== "rec") return;
const p = clamp((x0.current - e.clientX) / CANCEL, 0, 1);
/* all the way arms it — a tick as it catches — and
sliding back disarms; letting go is what decides */
pullRef.current = p;
setPull(p);
}}
onPointerUp={(e) => {
try { e.currentTarget.releasePointerCapture(e.pointerId); } catch { /* never captured */ }
end(pullRef.current >= 1);
}}
onPointerCancel={() => end(false)}
onKeyDown={(e) => {
if ((e.key === " " || e.key === "Enter") && !e.repeat && ph.current === "idle") {
e.preventDefault();
begin();
} else if (e.key === "Escape" && ph.current === "rec") {
end(true);
}
}}
onKeyUp={(e) => {
/* only while recording: the play and discard buttons
inside act on keyup, and this would swallow it */
if ((e.key === " " || e.key === "Enter") && ph.current === "rec") {
e.preventDefault();
end(false);
}
}}
onBlur={() => { if (ph.current === "rec") end(false); }}
onContextMenu={(e) => e.preventDefault()}
>
{phase === "idle" && (
<span key="idle" className="vn-in vn-idle">
<MicMark />
Hold to record
</span>
)}
{(phase === "rec" || (phase === "cancel" && !clip)) && (
<span key="rec" className="vn-in vn-rec" style={{ translate: `${shift}px 0` }}>
<span className="vn-dot" />
<span className="vn-time">{fmt(ms)}</span>
<span className="vn-wave" style={{ "--n": n } as React.CSSProperties}>{recBars()}</span>
</span>
)}
{/* slid all the way: the cancel mark takes the dot's
place. It sits on the pill rather than in the sliding
row, which by now has gone half out of the left edge */}
{(phase === "rec" || (phase === "cancel" && !clip)) && (
<span className="vn-cancel" data-on={armed || undefined} aria-hidden="true">
<X size={16} strokeWidth={2} />
</span>
)}
{showClip && (
<span key="clip" className="vn-in vn-clip">
<button
type="button"
className="vn-play"
aria-label={playing ? "Pause" : "Play"}
onClick={toggle}
>
<PlayMark on={playing} />
</button>
<span
ref={wave}
className="vn-wave vn-scrub"
style={{ "--n": n, "--prog": prog.current } as React.CSSProperties}
onPointerDown={(e) => {
try { e.currentTarget.setPointerCapture(e.pointerId); } catch { /* a scripted pointer */ }
scrub.current = true;
seek(e.clientX);
}}
onPointerMove={(e) => { if (scrub.current) seek(e.clientX); }}
onPointerUp={(e) => {
try { e.currentTarget.releasePointerCapture(e.pointerId); } catch { /* never captured */ }
scrub.current = false;
}}
onPointerCancel={() => { scrub.current = false; }}
>
{resample(clip.raw, n).map((v, i) => bar(v, i, i))}
</span>
<span ref={time} className="vn-time">{fmt(clip.ms)}</span>
<button type="button" className="vn-x" aria-label="Discard" onClick={discard}>
<X size={18} strokeWidth={2} />
</button>
</span>
)}
</div>
<span
className="vn-hint"
data-on={phase === "rec" || undefined}
data-armed={(phase === "rec" && armed) || undefined}
style={{ "--pull": pull.toFixed(3) } as React.CSSProperties}
aria-hidden="true"
>
{phase === "rec" && armed ? "Release to cancel" : "‹ Slide to cancel"}
</span>
</div>
);
}컨트롤 · HTML · CSS · JS
코드를 고치고 컨트롤로 다듬어 보세요. 입력하는 대로 미리보기가 바뀝니다.

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