diff --git a/app.py b/app.py index 710b40c..b7f4efb 100644 --- a/app.py +++ b/app.py @@ -4926,7 +4926,7 @@ class HookRequest(BaseModel): position: Optional[str] = "top" # top, center, bottom size: Optional[str] = "M" # S, M, L duration_seconds: Optional[float] = None # None = hook visible for the whole clip - style: Optional[str] = "classic" # classic/dark/yellow/red/outline/outline_yellow + style: Optional[str] = "pill" # pill/classic/dark/yellow/red/outline/outline_yellow remove: Optional[bool] = False # strip the burned hook instead of adding one @app.post("/api/hook") diff --git a/dashboard/public/fonts/Montserrat-ExtraBold.ttf b/dashboard/public/fonts/Montserrat-ExtraBold.ttf new file mode 100644 index 0000000..c7cb411 Binary files /dev/null and b/dashboard/public/fonts/Montserrat-ExtraBold.ttf differ diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 07c608b..f6d2feb 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -542,7 +542,7 @@ function App() { border_width: options.borderWidth, bg_color: options.bgColor, bg_opacity: options.bgOpacity, - style: options.style || 'classic', + style: options.style || 'pill', highlight_color: options.highlightColor || '#FFD700', effect: options.effect || 'none', base_opacity: options.baseOpacity ?? 1.0, @@ -984,7 +984,7 @@ function App() { // Sent explicitly both ways: absent means off for raw API callers, // but the dashboard always states the user's choice. auto_hook: data.autoHook ? '1' : '0', - auto_hook_style: data.autoHook ? (data.autoHookStyle || 'classic') : null, + auto_hook_style: data.autoHook ? (data.autoHookStyle || 'pill') : null, // 'auto' is the server default, so only a deliberate choice travels. layouts: data.layout && data.layout !== 'auto' ? data.layout : null, // Set when the user took the quota wall's "clip the first N minutes" diff --git a/dashboard/src/components/HookModal.jsx b/dashboard/src/components/HookModal.jsx index 827a8a5..5c53509 100644 --- a/dashboard/src/components/HookModal.jsx +++ b/dashboard/src/components/HookModal.jsx @@ -13,6 +13,7 @@ const ENTRANCE_OPTIONS = [ // Must mirror hooks.py HOOK_STYLES. const HOOK_STYLES = [ + { value: 'pill', label: 'Pills', box: 'rgba(255,255,255,0.98)', text: '#000', sans: true }, { value: 'classic', label: 'Classic', box: 'rgba(255,255,255,0.94)', text: '#000' }, { value: 'dark', label: 'Dark', box: 'rgba(18,18,20,0.92)', text: '#fff' }, { value: 'yellow', label: 'Yellow', box: 'rgba(255,214,0,0.96)', text: '#000' }, @@ -44,7 +45,7 @@ export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isPro const [text, setText] = useState(initialText || 'POV: You are using the viral hook feature'); const [position, setPosition] = useState(prefs.position || 'top'); const [size, setSize] = useState(prefs.size || 'M'); - const [style, setStyle] = useState(prefs.style || 'classic'); + const [style, setStyle] = useState(prefs.style || 'pill'); const [entranceAnimation, setEntranceAnimation] = useState(prefs.entranceAnimation || 'spring'); const [displayDuration, setDisplayDuration] = useState(5); @@ -79,8 +80,11 @@ export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isPro } }; + const pillFontFace = "@font-face{font-family:'Montserrat-ExtraBold';src:url('/fonts/Montserrat-ExtraBold.ttf') format('truetype');font-weight:800;}"; + return ( +
{/* Left: Preview */}
@@ -125,8 +129,7 @@ export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isPro value={text} onChange={(e) => setText(e.target.value)} rows={4} - className="input-field resize-none font-serif" - style={{ fontFamily: 'Noto Serif, serif' }} + className="input-field resize-none" placeholder="Enter text that will stop the scroll..." />
@@ -148,6 +151,7 @@ export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isPro style={{ backgroundColor: s.box, color: s.text, + fontFamily: s.sans ? "'Montserrat-ExtraBold', 'Montserrat', sans-serif" : undefined, textShadow: s.outline ? '-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000' : 'none', }} >Aa diff --git a/dashboard/src/components/MediaInput.jsx b/dashboard/src/components/MediaInput.jsx index 6b67e2d..c982ae1 100644 --- a/dashboard/src/components/MediaInput.jsx +++ b/dashboard/src/components/MediaInput.jsx @@ -52,7 +52,8 @@ export default function MediaInput({ onProcess, isProcessing }) { try { return localStorage.getItem('os_auto_hook') !== '0'; } catch { return true; } }); const [autoHookStyle, setAutoHookStyle] = useState(() => { - try { return localStorage.getItem('os_auto_hook_style') || 'classic'; } catch { return 'classic'; } + // v2 key: the default became 'pill'; an old saved 'classic' was just the old default. + try { return localStorage.getItem('os_auto_hook_style_v2') || 'pill'; } catch { return 'pill'; } }); // Layout: 'auto' lets the AI pick per video (server default); the others // force one on so a podcast host who knows what they uploaded doesn't @@ -126,7 +127,7 @@ export default function MediaInput({ onProcess, isProcessing }) { }; try { localStorage.setItem('os_auto_hook', autoHook ? '1' : '0'); - localStorage.setItem('os_auto_hook_style', autoHookStyle); + localStorage.setItem('os_auto_hook_style_v2', autoHookStyle); localStorage.setItem('os_layout', layout); } catch { /* ignore */ } if (mode === 'url' && url) { @@ -370,6 +371,7 @@ export default function MediaInput({ onProcess, isProcessing }) { onChange={(e) => setAutoHookStyle(e.target.value)} className="input-field !w-auto text-xs py-1.5" > + @@ -378,6 +380,12 @@ export default function MediaInput({ onProcess, isProcessing }) { )} + {autoHook && ( +

+ You can change each clip's hook text, style, position and size + afterwards with its hook button. +

+ )}
)} diff --git a/dashboard/src/remotion/compositions/HookOverlay.tsx b/dashboard/src/remotion/compositions/HookOverlay.tsx index 5b0c457..d1bc14e 100644 --- a/dashboard/src/remotion/compositions/HookOverlay.tsx +++ b/dashboard/src/remotion/compositions/HookOverlay.tsx @@ -8,7 +8,12 @@ import { interpolate, } from "remotion"; import type { HookConfig } from "../lib/types"; -import { notoSerifFontFace, NOTO_SERIF_FONT_FAMILY } from "../lib/fonts"; +import { + notoSerifFontFace, + NOTO_SERIF_FONT_FAMILY, + montserratFontFace, + MONTSERRAT_FONT_FAMILY, +} from "../lib/fonts"; interface HookOverlayProps { config: HookConfig; @@ -34,9 +39,12 @@ interface HookLook { text: string; outlinePx: number; shadow: boolean; + /** One rounded box per line (hooks.py _draw_pills) instead of one card. */ + pills?: boolean; } const HOOK_LOOKS: Record = { + pill: { box: "rgba(255, 255, 255, 0.98)", text: "#000000", outlinePx: 0, shadow: false, pills: true }, classic: { box: "rgba(255, 255, 255, 0.94)", text: "#000000", outlinePx: 0, shadow: true }, dark: { box: "rgba(18, 18, 20, 0.92)", text: "#FFFFFF", outlinePx: 0, shadow: true }, yellow: { box: "rgba(255, 214, 0, 0.96)", text: "#000000", outlinePx: 0, shadow: true }, @@ -51,7 +59,7 @@ export const HookOverlay: React.FC = ({ config }) => { return ( - + @@ -117,13 +125,57 @@ const HookBox: React.FC = ({ config, displayFrames }) => { } const positionStyle = POSITION_STYLE[config.position] ?? POSITION_STYLE.top; - const look = HOOK_LOOKS[config.style ?? "classic"] ?? HOOK_LOOKS.classic; + const look = HOOK_LOOKS[config.style ?? "pill"] ?? HOOK_LOOKS.pill; - // Base font size: 5% of 1080 width (matches hooks.py logic) - const baseFontSize = 1080 * 0.05; + // Base font size: 5% (serif) / 6.4% (pill sans) of the 90% box, as hooks.py. + const baseFontSize = 1080 * 0.9 * (look.pills ? 0.064 : 0.05 / 0.9); const fontSize = Math.round(baseFontSize * scale); const outlinePx = Math.round(look.outlinePx * scale); + if (look.pills) { + // box-decoration-break: clone gives every wrapped line its own padded, + // rounded box, the same stack hooks.py draws for the FFmpeg path. + return ( +
+
+ + {config.text} + +
+
+ ); + } + return (
0 and h > 0 + + +def test_pill_hook_image_stacks_one_box_per_line(tmp_path): + """Two lines of text -> two rows of box pixels with a boxless column + beside the shorter one (it is its own pill, not one shared card).""" + from hooks import create_hook_image + from PIL import Image + out = tmp_path / "pill.png" + path, w, h = create_hook_image("una frase bastante larga para partirse en dos lineas", + 600, str(out), style="pill") + img = Image.open(path).convert("RGBA") + assert (img.width, img.height) == (w, h) + alpha_rows = [any(img.getpixel((x, y))[3] > 200 for x in range(0, img.width, 4)) + for y in range(img.height)] + assert sum(alpha_rows) > 0