Skip to content

Open source CapCut alternative.

TypeScript

feat(site): the word effect picker groups by family

David Lede4290477cf8
diff --git a/site/src/cut/components/AnimationTiles.tsx b/site/src/cut/components/AnimationTiles.tsx
index f9afb19f..3dc5cdce 100644
--- a/site/src/cut/components/AnimationTiles.tsx
+++ b/site/src/cut/components/AnimationTiles.tsx
@@ -16,17 +16,18 @@ import {
OVERLAY_ANIM_STYLE_LABELS,
OVERLAY_LOOP_STYLE_IDS,
OVERLAY_LOOP_STYLE_LABELS,
- contrastText,
- wordAccent,
+ wordDrawsAt,
+ wordEffectIdsIn,
WORD_ACCENT_DEFAULT,
- WORD_ACCENT_LABELS,
- WORD_ACCENT_MODE_IDS,
+ WORD_EFFECT_LABELS,
+ WORD_FAMILIES,
type OverlayAnimStyle,
type OverlayLoopStyle,
- type WordAccentMode,
+ type OverlayWords,
} from "@donkeycut/effects-kit";
import { Tile } from "@/cut/components/PanelTile";
-import { wordAccentCss } from "@/cut/lib/textRender";
+import { SectionTitle } from "@/cut/components/SectionTitle";
+import { wordDrawCss } from "@/cut/lib/textRender";
import { fontStack } from "@/cut/lib/types";
/**
@@ -98,7 +99,7 @@ const MOVE_DEMO_SECONDS = 2.4;
const labelOf = (slot: Slot, style: string) =>
slot === "words"
- ? (WORD_ACCENT_LABELS[style as WordAccentMode] ?? style)
+ ? (WORD_EFFECT_LABELS[style] ?? style)
: slot === "move"
? (MOTION.holds[style]?.label ?? style)
: slot === "loop"
@@ -291,73 +292,80 @@ function LiveName({
);
}
-/** One turn of a word-emphasis demo, and the share of it the accent holds —
- * long enough to read the treatment arriving and leaving again. */
-const WORD_DEMO_SECONDS = 1.7;
-const WORD_DEMO_ON = 0.5;
+/** One turn of a word-effect demo, and the beat after it: long enough to read
+ * an emphasis travelling off the line again and a build finishing and holding
+ * what it assembled. */
+const WORD_DEMO_SECONDS = 1.5;
+const WORD_DEMO_HOLD = 0.7;
/** The accent reads on a light panel the way it reads over footage: with the
* same shadow the caption previews give a bright caption color. */
const WORD_DEMO_SHADOW = "0 0 2px rgba(0, 0, 0, 0.6)";
-/** A word-emphasis name: the label sits plain, then takes the accent the way
- * it will when that word is said. Written straight to the element, like every
- * other demo here. */
+/** A word-effect name, played by the engine on the name's own words — the
+ * same `wordDrawsAt` the preview and the burn-in read, so a tile can't promise
+ * a treatment the export won't draw. */
function WordName({
style,
textColor,
accentColor,
scale,
+ dim,
index = 0,
}: {
style: string;
- /** The element's own text color — what a swell keeps. */
+ /** The element's own text color — where an effect that speaks in color
+ * starts from, and what one that speaks in size keeps. */
textColor: string;
/** The accent it was given, if any. */
accentColor?: string;
/** The element's own swell, so a tile shows the size it will apply. */
scale?: number;
+ /** Its faded level, so a tile shows the transparency it will apply. */
+ dim?: number;
index?: number;
}) {
const ref = useRef<HTMLSpanElement>(null);
- const phase = index * PHASE_STEP * WORD_DEMO_SECONDS;
+ const label = labelOf("words", style);
+ const cycle = WORD_DEMO_SECONDS + WORD_DEMO_HOLD;
+ const phase = index * PHASE_STEP * cycle;
useEffect(() => {
const el = ref.current;
if (!el) return;
- const mode = style as WordAccentMode;
- const color = wordAccent({ style: mode, color: accentColor }, textColor);
- const css = wordAccentCss({
- mode,
- color,
- text: contrastText(color),
- scale,
- // The tile's name sits on one line of its own; the stage gives it room.
- lineHeight: 1,
- });
- const props = el.style as unknown as Record<string, string>;
- const rest = () => {
- for (const k of Object.keys(css)) props[k] = "";
- el.style.textShadow = "";
+ const words: OverlayWords = {
+ style,
+ ...(accentColor ? { color: accentColor } : {}),
+ ...(scale !== undefined ? { scale } : {}),
+ ...(dim !== undefined ? { dim } : {}),
};
- const accent = () => {
- Object.assign(el.style, css);
- if (mode !== "box") el.style.textShadow = WORD_DEMO_SHADOW;
+ const spans = Array.from(el.querySelectorAll<HTMLElement>("[data-word]"));
+ const rest = () => spans.forEach((sp) => (sp.style.cssText = "display:inline-block"));
+ const paint = (t: number) => {
+ const draws = wordDrawsAt(label, words, textColor, WORD_DEMO_SECONDS, t);
+ spans.forEach((sp, i) => {
+ const d = draws[i];
+ if (!d) return;
+ const css = wordDrawCss(d, 1) as Record<string, string | number>;
+ // A word still in the element's own color keeps the panel's foreground
+ // instead, which is what makes the name readable on a light card; one
+ // that has taken the accent wears it, with the shadow that carries a
+ // bright accent over any background.
+ const colored = d.color.toLowerCase() !== textColor.toLowerCase();
+ if (!colored) delete css.color;
+ sp.style.cssText = "display:inline-block";
+ Object.assign(sp.style, css);
+ if (colored && d.mark !== "box") sp.style.textShadow = WORD_DEMO_SHADOW;
+ });
};
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
- accent();
+ paint(WORD_DEMO_SECONDS);
return rest;
}
let start = 0;
let raf = 0;
- let on: boolean | null = null;
const tick = (now: number) => {
if (!start) start = now;
- const p = (((now - start) / 1000 + phase) % WORD_DEMO_SECONDS) / WORD_DEMO_SECONDS;
- const next = p < WORD_DEMO_ON;
- if (next !== on) {
- on = next;
- if (next) accent();
- else rest();
- }
+ const local = (((now - start) / 1000 + phase) % cycle + cycle) % cycle;
+ paint(Math.min(local, WORD_DEMO_SECONDS));
raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
@@ -365,10 +373,17 @@ function WordName({
cancelAnimationFrame(raf);
rest();
};
- }, [style, textColor, accentColor, scale, phase]);
+ }, [style, label, textColor, accentColor, scale, dim, cycle, phase]);
return (
<span ref={ref} className={`${WORD} text-foreground`} style={wordStyle()}>
- {labelOf("words", style)}
+ {label.split(" ").map((w, i) => (
+ <span key={i}>
+ {i > 0 && " "}
+ <span data-word style={{ display: "inline-block" }}>
+ {w}
+ </span>
+ </span>
+ ))}
</span>
);
}
@@ -380,6 +395,7 @@ function AnimName({
textColor,
accentColor,
accentScale,
+ accentDim,
...rest
}: {
slot: Slot;
@@ -395,6 +411,8 @@ function AnimName({
accentColor?: string;
/** Its swell, so the tiles show the size the pick will apply. */
accentScale?: number;
+ /** Its faded level, so the tiles show the transparency the pick will apply. */
+ accentDim?: number;
}) {
if (!playing) return <FrozenName slot={rest.slot} style={rest.style} />;
if (rest.slot === "words")
@@ -404,6 +422,7 @@ function AnimName({
textColor={textColor ?? WORD_ACCENT_DEFAULT}
accentColor={accentColor}
scale={accentScale}
+ dim={accentDim}
index={rest.index}
/>
);
@@ -437,6 +456,7 @@ function AnimTile({
textColor,
accentColor,
accentScale,
+ accentDim,
onPick,
}: {
slot: Slot;
@@ -453,6 +473,8 @@ function AnimTile({
accentColor?: string;
/** Its swell, so a words tile shows the size the pick will apply. */
accentScale?: number;
+ /** Its faded level, so a words tile shows the transparency it will apply. */
+ accentDim?: number;
onPick: () => void;
}) {
const ref = useRef<HTMLButtonElement>(null);
@@ -476,6 +498,7 @@ function AnimTile({
textColor={textColor}
accentColor={accentColor}
accentScale={accentScale}
+ accentDim={accentDim}
playing={onScreen}
/>
</span>
@@ -498,6 +521,7 @@ export function AnimationCard({
textColor,
accentColor,
accentScale,
+ accentDim,
onOpen,
onClear,
}: {
@@ -514,6 +538,8 @@ export function AnimationCard({
accentColor?: string;
/** Its swell, so the card shows the size the element is wearing. */
accentScale?: number;
+ /** Its faded level, so the card shows the transparency it is wearing. */
+ accentDim?: number;
onOpen: () => void;
onClear: () => void;
}) {
@@ -539,6 +565,7 @@ export function AnimationCard({
textColor={textColor}
accentColor={accentColor}
accentScale={accentScale}
+ accentDim={accentDim}
playing={onScreen}
/>
</span>
@@ -569,6 +596,7 @@ export function AnimationTiles({
textColor,
accentColor,
accentScale,
+ accentDim,
onPick,
}: {
slot: Slot;
@@ -590,42 +618,68 @@ export function AnimationTiles({
accentColor?: string;
/** Its swell, so the tiles show the size a pick will apply. */
accentScale?: number;
+ /** Its faded level, so the tiles show the transparency a pick will apply. */
+ accentDim?: number;
onPick: (style: string | null) => void;
}) {
+ const tile = (id: string, i: number) => (
+ <AnimTile
+ key={id}
+ slot={slot}
+ style={id}
+ isText={isText}
+ seconds={seconds}
+ speed={speed}
+ index={i}
+ textColor={textColor}
+ accentColor={accentColor}
+ accentScale={accentScale}
+ accentDim={accentDim}
+ selected={value === id}
+ onPick={() => onPick(id)}
+ />
+ );
+ const none = (
+ <Tile selected={!value && !custom} onClick={() => onPick(null)} title="None" className="p-1">
+ <span className={STAGE}>
+ <span className={`${WORD} text-muted-foreground/70`} style={wordStyle()}>
+ None
+ </span>
+ </span>
+ </Tile>
+ );
+
+ // The words grid runs long enough that one flat list stops reading as a
+ // choice: the effects fall into two kinds — a treatment that travels along
+ // the line, and a line that assembles itself — so each gets its own shelf.
+ if (slot === "words") {
+ let n = 0;
+ return (
+ <div className="flex flex-col gap-2">
+ <div className="grid grid-cols-2 gap-[9px]">{none}</div>
+ {WORD_FAMILIES.map((f) => (
+ <div key={f.id} className="flex flex-col gap-1.5">
+ <SectionTitle>{f.label}</SectionTitle>
+ <div className="grid grid-cols-2 gap-[9px]">
+ {wordEffectIdsIn(f.id).map((id) => tile(id, n++))}
+ </div>
+ </div>
+ ))}
+ </div>
+ );
+ }
+
const ids: string[] =
- slot === "words"
- ? WORD_ACCENT_MODE_IDS
- : slot === "move"
- ? HOLD_IDS
- : slot === "loop"
- ? OVERLAY_LOOP_STYLE_IDS
- : OVERLAY_ANIM_STYLE_IDS.filter((s) => s !== "typewriter" || isText);
+ slot === "move"
+ ? HOLD_IDS
+ : slot === "loop"
+ ? OVERLAY_LOOP_STYLE_IDS
+ : OVERLAY_ANIM_STYLE_IDS.filter((s) => s !== "typewriter" || isText);
return (
<div className="grid grid-cols-2 gap-[9px]">
- <Tile selected={!value && !custom} onClick={() => onPick(null)} title="None" className="p-1">
- <span className={STAGE}>
- <span className={`${WORD} text-muted-foreground/70`} style={wordStyle()}>
- None
- </span>
- </span>
- </Tile>
- {ids.map((id, i) => (
- <AnimTile
- key={id}
- slot={slot}
- style={id}
- isText={isText}
- seconds={seconds}
- speed={speed}
- index={i}
- textColor={textColor}
- accentColor={accentColor}
- accentScale={accentScale}
- selected={value === id}
- onPick={() => onPick(id)}
- />
- ))}
+ {none}
+ {ids.map(tile)}
</div>
);
}
diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsx
index 76e70b87..13c08d2c 100644
--- a/site/src/cut/components/Inspector.tsx
+++ b/site/src/cut/components/Inspector.tsx
@@ -35,6 +35,9 @@ import {
ZOOM_RAMP_MAX,
zoomRampOf,
wordAccent,
+ wordDim,
+ wordEffect,
+ wordKnobs,
WORD_ACCENT_DEFAULT,
WORD_POP_SCALE,
WORD_SWELL_MAX,
@@ -43,7 +46,7 @@ import {
type OverlayAnim,
type OverlayAnimStyle,
type OverlayLoopStyle,
- type WordAccentMode,
+ type WordEffectId,
} from "@donkeycut/effects-kit";
import { clipWindow, useEditor, type EditorState } from "@/cut/lib/store";
import { usePreviewTime } from "@/cut/lib/playhead";
@@ -1618,6 +1621,7 @@ function AnimationSection({
textColor={isTextOverlay(o) ? o.color : WORD_ACCENT_DEFAULT}
accentColor={anim.words?.color}
accentScale={anim.words?.scale}
+ accentDim={anim.words?.dim}
onOpen={onOpen}
onClear={() => clear(slot)}
/>
@@ -1628,7 +1632,7 @@ function AnimationSection({
<AnimSlotSlider overlay={o} slot="out" label="Out duration" />
<AnimSlotSlider overlay={o} slot="loop" label="Loop speed" />
<MoveStrengthRow overlay={o} />
- <WordSizeRow overlay={o} />
+ {anim.words && <WordSettings overlay={o} />}
</Section>
</div>
);
@@ -1678,37 +1682,87 @@ function MoveStrengthRow({ overlay: o }: { overlay: Overlay }) {
return <MoveStrengthSlider overlay={o} label="Move strength" />;
}
-/** How far the emphasized word swells, in the collapsed section — there only
- * once the words slot is filled. */
-function WordSizeRow({ overlay: o }: { overlay: Overlay }) {
+/** The settings the picked word effect actually has: a swell has a size, a
+ * fade has a level, anything that speaks in color has an accent. A knob the
+ * effect does not use is left out — a slider with nothing to move explains
+ * nothing. With no effect picked the rows sit greyed, so the panel floor
+ * keeps its height while the reader scrolls the grid. */
+function WordSettings({ overlay: o }: { overlay: Overlay }) {
const ck = useSliderCheckpoint();
const anim = o.anim ?? {};
const words = anim.words;
- if (!words) return null;
- const write = (v: number) => {
+ const knobs = wordKnobs(wordEffect(words?.style), words);
+ // The sliders check-point on the first frame of a drag and release on
+ // commit; the color field opens its own on pointer-down, so it writes
+ // straight through — borrowing the slider's would leave it open and swallow
+ // every checkpoint after it.
+ const write = (patch: { scale?: number; dim?: number }) => {
+ if (!words) return;
ck.begin();
- writeOverlayAnim(o, anim, { words: { ...words, scale: v } });
+ writeOverlayAnim(o, anim, { words: { ...words, ...patch } });
+ };
+ const setColor = (color: string) => {
+ if (!words) return;
+ writeOverlayAnim(o, anim, { words: { ...words, color } });
};
return (
- <Row label="Word size">
- <ValueSlider
- label="Word size"
- sliderClassName="data-horizontal:w-24"
- valueClassName="w-9 text-muted-foreground"
- value={wordSwell(words)}
- min={WORD_SWELL_MIN}
- max={WORD_SWELL_MAX}
- step={0.02}
- snap={[1, WORD_POP_SCALE]}
- format={(v) => `${v.toFixed(2)}×`}
- parse={parseSpeedInput}
- onDraft={write}
- onCommit={(v) => {
- write(v);
- ck.end();
- }}
- />
- </Row>
+ <>
+ {knobs.size && (
+ <Row label="Word size">
+ <ValueSlider
+ label="Word size"
+ sliderClassName="data-horizontal:w-24"
+ valueClassName="w-9 text-muted-foreground"
+ value={wordSwell(words)}
+ min={WORD_SWELL_MIN}
+ max={WORD_SWELL_MAX}
+ step={0.02}
+ snap={[1, WORD_POP_SCALE]}
+ format={(v) => `${v.toFixed(2)}×`}
+ parse={parseSpeedInput}
+ disabled={!words}
+ onDraft={(v) => write({ scale: v })}
+ onCommit={(v) => {
+ write({ scale: v });
+ ck.end();
+ }}
+ />
+ </Row>
+ )}
+ {knobs.dim && (
+ <Row label="Faded to">
+ <ValueSlider
+ label="Faded to"
+ sliderClassName="data-horizontal:w-24"
+ valueClassName="w-9 text-muted-foreground"
+ value={wordDim(words)}
+ min={0}
+ max={1}
+ step={0.01}
+ snap={[wordDim({ style: words?.style })]}
+ format={(v) => `${Math.round(v * 100)}%`}
+ parse={parsePercentInput}
+ disabled={!words}
+ onDraft={(v) => write({ dim: v })}
+ onCommit={(v) => {
+ write({ dim: v });
+ ck.end();
+ }}
+ />
+ </Row>
+ )}
+ {knobs.color && (
+ <Row label="Word color">
+ <ColorField
+ value={wordAccent(words, isTextOverlay(o) ? o.color : WORD_ACCENT_DEFAULT)}
+ label="Word color"
+ onBegin={() => useEditor.getState().pushHistory()}
+ onLive={setColor}
+ onCommit={setColor}
+ />
+ </Row>
+ )}
+ </>
);
}
@@ -1742,9 +1796,10 @@ function AnimationPanel({ overlay: o, onBack }: { overlay: Overlay; onBack: () =
const patch: Partial<OverlayAnim> = {
words: style
? {
- style: style as WordAccentMode,
+ style: style as WordEffectId,
...(anim.words?.color ? { color: anim.words.color } : {}),
...(anim.words?.scale !== undefined ? { scale: anim.words.scale } : {}),
+ ...(anim.words?.dim !== undefined ? { dim: anim.words.dim } : {}),
}
: undefined,
};
@@ -1861,6 +1916,7 @@ function AnimationPanel({ overlay: o, onBack }: { overlay: Overlay; onBack: () =
textColor={isTextOverlay(o) ? o.color : WORD_ACCENT_DEFAULT}
accentColor={anim.words?.color}
accentScale={anim.words?.scale}
+ accentDim={anim.words?.dim}
onPick={pick}
/>
</ScrollArea>
@@ -1887,49 +1943,7 @@ function AnimationToolbar({ overlay: o, slot }: { overlay: Overlay; slot: AnimSl
if (slot === "move") return bar(<MoveStrengthSlider overlay={o} label="Strength" />);
- if (slot === "words") {
- // The words tab's two settings: how far the word swells while it is said,
- // and the accent it wears.
- const words = anim.words;
- const size = (v: number) => {
- if (!words) return;
- ck.begin();
- writeOverlayAnim(o, anim, { words: { ...words, scale: v } });
- };
- return bar(
- <>
- <Row label="Word size">
- <ValueSlider
- label="Word size"
- sliderClassName="data-horizontal:w-24"
- valueClassName="w-9 text-muted-foreground"
- value={wordSwell(words)}
- min={WORD_SWELL_MIN}
- max={WORD_SWELL_MAX}
- step={0.02}
- snap={[1, WORD_POP_SCALE]}
- format={(v) => `${v.toFixed(2)}×`}
- parse={parseSpeedInput}
- disabled={!words}
- onDraft={size}
- onCommit={(v) => {
- size(v);
- ck.end();
- }}
- />
- </Row>
- <Row label="Word color">
- <ColorField
- value={wordAccent(words, isTextOverlay(o) ? o.color : WORD_ACCENT_DEFAULT)}
- label="Word color"
- onBegin={() => useEditor.getState().pushHistory()}
- onLive={(c) => words && writeOverlayAnim(o, anim, { words: { ...words, color: c } })}
- onCommit={(c) => words && writeOverlayAnim(o, anim, { words: { ...words, color: c } })}
- />
- </Row>
- </>
- );
- }
+ if (slot === "words") return bar(<WordSettings overlay={o} />);
if (slot === "loop") {
const write = (speed: number) => {
diff --git a/site/src/cut/components/SubtitlesPanel.tsx b/site/src/cut/components/SubtitlesPanel.tsx
index c6dc0d7b..cee7cf8c 100644
--- a/site/src/cut/components/SubtitlesPanel.tsx
+++ b/site/src/cut/components/SubtitlesPanel.tsx
@@ -6,18 +6,17 @@ import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import { ColorField } from "@/cut/components/ColorField";
import { FontPicker } from "@/cut/components/FontPicker";
-import { parseNumberInput } from "@/cut/components/ScrubValue";
+import { parseNumberInput, parsePercentInput, parseSpeedInput } from "@/cut/components/ScrubValue";
import { ValueSlider } from "@/cut/components/ValueSlider";
import { GenerateSubtitlesAudio } from "@/cut/components/VoicePicker";
import {
CAPTION_STYLES,
+ captionWords,
captionStyle,
fmtCueTime,
- karaokeLook,
laneCues,
subtitleLaneCount,
trackLocale,
- WORD_ACCENT_MODES,
} from "@/cut/lib/subtitles";
import { useElapsed } from "@/cut/hooks/useElapsed";
import { useCutCaps } from "@/cut/lib/backend/hooks";
@@ -32,6 +31,18 @@ import {
} from "@/cut/lib/types";
import { cn } from "@/lib/utils";
import { ScrollArea } from "@/components/ui/scroll-area";
+import { PillSelect } from "@/cut/components/PillSelect";
+import {
+ wordAccent,
+ wordDim,
+ wordEffect,
+ wordKnobs,
+ wordSwell,
+ WORD_EFFECT_MENU,
+ WORD_POP_SCALE,
+ WORD_SWELL_MAX,
+ WORD_SWELL_MIN,
+} from "@donkeycut/effects-kit";
const LOCALES = [
["en-US", "English (US)"],
@@ -183,19 +194,23 @@ export function SubtitlesPanel() {
);
}
-/** The Options tab: caption visibility, the karaoke word highlight with its
- * treatment and color, position reset for a dragged caption, and the
- * subtitle-voiceover generator. */
+/** The Options tab: caption visibility, the word effect the track plays with
+ * its color, position reset for a dragged caption, and the subtitle-voiceover
+ * generator. */
function OptionsTab() {
const subtitles = useEditor((s) => s.subtitles);
const moved =
subtitles.x !== undefined ||
subtitles.y !== undefined ||
!!subtitles.tracks?.some((t) => t.x !== undefined || t.y !== undefined);
- // Effective word treatment: the caption style's defaults with the user's
+ // Effective word effect: the caption style's defaults with the user's
// overrides on top, so the controls always show what's on the video.
- const look = karaokeLook(captionStyle(subtitles.style), subtitles);
+ const words = captionWords(captionStyle(subtitles.style), subtitles);
const on = !!subtitles.wordHighlight;
+ const knobs = wordKnobs(wordEffect(words.style), {
+ scale: subtitles.accentScale,
+ dim: subtitles.accentDim,
+ });
return (
<ScrollArea
@@ -244,44 +259,74 @@ function OptionsTab() {
/>
</div>
</div>
- <div className="flex flex-col gap-1.5 text-xs font-medium">
- Emphasize the spoken word
- <div className="sub-word-highlight flex rounded-lg border border-input p-0.5">
- <button
- className={cn(
- "flex-1 rounded-md px-1.5 py-1 text-[11.5px] font-medium transition-colors",
- on ? "text-muted-foreground hover:text-foreground" : "bg-neutral-900 text-white"
- )}
- aria-pressed={!on}
- onClick={() => useEditor.getState().setSubtitlesView({ wordHighlight: undefined })}
- >
- Off
- </button>
- {WORD_ACCENT_MODES.map((m) => (
- <button
- key={m.id}
- className={cn(
- "sub-accent-mode flex-1 rounded-md px-1.5 py-1 text-[11.5px] font-medium transition-colors",
- on && look.mode === m.id
- ? "bg-neutral-900 text-white"
- : "text-muted-foreground hover:text-foreground"
- )}
- aria-pressed={on && look.mode === m.id}
- onClick={() =>
- useEditor.getState().setSubtitlesView({ wordHighlight: true, accentMode: m.id })
- }
- >
- {m.label}
- </button>
- ))}
- </div>
+ <div className="flex min-h-8 items-center justify-between text-xs font-medium">
+ Word effect
+ <PillSelect
+ className="sub-word-highlight w-36"
+ title="Word effect"
+ value={on ? words.style : "none"}
+ display={on ? wordEffect(words.style).label : "None"}
+ options={[
+ { value: "none", label: "None" },
+ ...WORD_EFFECT_MENU.map((m) => ({ value: m.id, label: m.label })),
+ ]}
+ onChange={(v) =>
+ useEditor.getState().setSubtitlesView(
+ v === "none"
+ ? { wordHighlight: undefined }
+ : { wordHighlight: true, accentMode: v }
+ )
+ }
+ />
</div>
- {on && (
+ {on && knobs.size && (
+ <div className="flex min-h-8 items-center justify-between text-xs font-medium">
+ Word size
+ <div className="sub-accent-scale flex items-center gap-2">
+ <ValueSlider
+ label="Word size"
+ sliderClassName="data-horizontal:w-24"
+ valueClassName="w-9 text-muted-foreground"
+ value={wordSwell(words)}
+ min={WORD_SWELL_MIN}
+ max={WORD_SWELL_MAX}
+ step={0.02}
+ snap={[1, WORD_POP_SCALE]}
+ format={(v) => `${v.toFixed(2)}×`}
+ parse={parseSpeedInput}
+ onDraft={(v) => useEditor.getState().setSubtitlesView({ accentScale: v })}
+ onCommit={(v) => useEditor.getState().setSubtitlesView({ accentScale: v })}
+ />
+ </div>
+ </div>
+ )}
+ {on && knobs.dim && (
+ <div className="flex min-h-8 items-center justify-between text-xs font-medium">
+ Faded to
+ <div className="sub-accent-dim flex items-center gap-2">
+ <ValueSlider
+ label="Faded to"
+ sliderClassName="data-horizontal:w-24"
+ valueClassName="w-9 text-muted-foreground"
+ value={wordDim(words)}
+ min={0}
+ max={1}
+ step={0.01}
+ snap={[wordDim({ style: words.style })]}
+ format={(v) => `${Math.round(v * 100)}%`}
+ parse={parsePercentInput}
+ onDraft={(v) => useEditor.getState().setSubtitlesView({ accentDim: v })}
+ onCommit={(v) => useEditor.getState().setSubtitlesView({ accentDim: v })}
+ />
+ </div>
+ </div>
+ )}
+ {on && knobs.color && (
<div className="flex min-h-8 items-center justify-between text-xs font-medium">
Word color
<div className="sub-accent-color flex items-center">
<ColorField
- value={look.color}
+ value={wordAccent(words, captionStyle(subtitles.style).color)}
label="Word color"
onBegin={() => useEditor.getState().pushHistory()}
onLive={(c) => useEditor.getState().setSubtitlesView({ accentColor: c })}