/**
* Glass quick search / חיפוש מהיר בזכוכית (student motion library, id "mac-spotlight")
* Use: copy this file into your Remotion project and register it in your Root:
*
* Render transparent: npx remotion render src/index.ts LibMacSpotlight out.webm --codec=vp9 --pixel-format=yuva420p --image-format=png --props=props.json
* Change the words / colours / side in props.json (same keys as macSpotlightDefaults). A vertical video: width 1080, height 1920.
*/
// ---------------------------------------------------------------- helpers (shared by every library scene)
// Conventions: 1920x1080, 30 fps, transparent background. Sizes follow the frame's short side, so 1080x1920 works too.
// Common props: duration (s), side 'right' | 'left' | 'center', x / y (centre in % of the frame, override side),
// scale, font (a CSS font-family; default Heebo). Time is in seconds; the first and last frames are empty.
import React from 'react';
import {AbsoluteFill, Easing, useCurrentFrame, useVideoConfig} from 'remotion';
import {loadFont as loadHeebo} from '@remotion/google-fonts/Heebo';
const heebo = loadHeebo('normal', {weights: ['400', '500', '700', '800', '900'], subsets: ['hebrew', 'latin']});
/** Hebrew + Latin font (Google "Heebo"). props.font overrides it per scene. */
export const HEEBO = `${heebo.fontFamily}, "Helvetica Neue", Arial, sans-serif`;
export const MONO = 'ui-monospace, "SF Mono", Menlo, Consolas, monospace';
export type Side = 'right' | 'left' | 'center';
export type Base = {duration?: number; side?: Side; x?: number; y?: number; scale?: number; font?: string};
export const clamp01 = (x: number) => Math.min(1, Math.max(0, x));
/** 0..1 progress of t between a and b (seconds) */
export const p01 = (t: number, a: number, b: number) => clamp01((t - a) / (b - a));
export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
export const outE = Easing.bezier(0.16, 1, 0.3, 1); // fast out, long settle
export const inOut = Easing.bezier(0.65, 0, 0.35, 1);
export const inE = Easing.bezier(0.55, 0, 0.9, 0.45);
export const backOut = (x: number, s = 1.7) => (x <= 0 ? 0 : x >= 1 ? 1 : 1 + (s + 1) * Math.pow(x - 1, 3) + s * Math.pow(x - 1, 2));
/** Damped spring 0 -> 1 starting at t0 (closed form, so any frame computes on its own). */
export const spr = (t: number, t0: number, freq = 16, damp = 9) => {
const x = t - t0;
return x <= 0 ? 0 : 1 - Math.exp(-damp * x) * Math.cos(freq * x);
};
/** Deterministic pseudo random 0..1 */
export const rnd = (i: number, seed = 1) => {
const v = Math.sin(i * 127.1 + seed * 311.7) * 43758.5453;
return v - Math.floor(v);
};
export const isHe = (s: string) => /[-]/.test(s);
export const dirOf = (s: string): 'rtl' | 'ltr' => (isHe(s) ? 'rtl' : 'ltr');
/** "#a1b2c3" / "#abc" + alpha -> rgba() */
export const rgba = (hex: string, a = 1) => {
let h = hex.replace('#', '');
if (h.length === 3) h = h.split('').map((ch) => ch + ch).join('');
const n = parseInt(h.slice(0, 6), 16);
return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})`;
};
export const useT = () => {
const f = useCurrentFrame();
const {fps} = useVideoConfig();
return f / fps;
};
/** 12345 -> "12,345" */
export const fmt = (n: number, sep = ',') => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, sep);
/** Arrive (scale up out of a blur) and leave (shrink into a blur) for a whole group. */
export const life = (t: number, total: number, inDur = 0.45, outDur = 0.35) => {
const a = p01(t, 0, inDur);
const z = inOut(p01(t, total - outDur, total));
return {
opacity: clamp01(a * 2.2) * (1 - z),
scale: lerp(0.82, 1, backOut(a, 1.4)) * (1 - 0.08 * z),
blur: (1 - outE(a)) * 12 + z * 10,
style: {} as React.CSSProperties,
};
};
export const lifeStyle = (t: number, total: number, inDur = 0.45, outDur = 0.35): React.CSSProperties => {
const l = life(t, total, inDur, outDur);
return {opacity: l.opacity, transform: `scale(${l.scale})`, filter: l.blur > 0.2 ? `blur(${l.blur}px)` : undefined};
};
/**
* Places a w x h box (design pixels of a 1080-high frame) on its side of the frame and scales it with the frame's
* short side and props.scale. Children are positioned inside the box.
*/
export const Stage: React.FC<{p: Base; w: number; h: number; children: React.ReactNode; style?: React.CSSProperties; defSide?: Side}> = ({p, w, h, children, style, defSide = 'center'}) => {
const {width: W, height: H} = useVideoConfig();
const u = (Math.min(W, H) / 1080) * (p.scale ?? 1);
const side = p.side ?? defSide;
const cx = ((p.x ?? (side === 'right' ? 73 : side === 'left' ? 27 : 50)) / 100) * W;
const cy = ((p.y ?? 50) / 100) * H;
return (
{children}
);
};
/** Soft two-layer drop shadow for cards on any footage */
export const SHADOW = '0 22px 48px rgba(12,12,20,0.22), 0 4px 12px rgba(12,12,20,0.14)';
/** The classic arrow cursor; (x, y) = its tip; press 0..1 = mouse down. */
export const Cursor: React.FC<{x: number; y: number; press?: number; size?: number; fill?: string; stroke?: string}> = ({x, y, press = 0, size = 1.6, fill = '#111', stroke = '#fff'}) => {
const s = size * (1 - 0.12 * press);
return (
);
};
/** A four-point sparkle centred on (0,0) in a -50..50 box. */
export const SPARK_PATH = 'M0 -50 C 6 -14 14 -6 50 0 C 14 6 6 14 0 50 C -6 14 -14 6 -50 0 C -14 -6 -6 -14 0 -50 Z';
export const Spark: React.FC<{x: number; y: number; size: number; color: string; rotate?: number; opacity?: number; glow?: boolean}> = ({x, y, size, color, rotate = 0, opacity = 1, glow = false}) => (
);
// ---------------------------------------------------------------- Mac-style parts (all drawn in code)
import {loadFont as loadInter} from '@remotion/google-fonts/Inter';
const inter = loadInter('normal', {weights: ['400', '500', '600', '700', '800'], subsets: ['latin']});
/** Latin text: Inter (closest free cousin of the system font), Hebrew falls through to Heebo. */
export const INTER = `${inter.fontFamily}, "Heebo", "Helvetica Neue", Arial, sans-serif`;
export const macFont = (s: string, own?: string) => own ?? (isHe(s) ? '"Heebo", "Helvetica Neue", Arial, sans-serif' : INTER);
/** Tight tracking for big Latin type, none for Hebrew. */
export const macTrack = (s: string, size: number) => (isHe(s) ? 0 : size >= 90 ? '-0.035em' : size >= 48 ? '-0.022em' : size >= 28 ? '-0.01em' : 0);
/** The system blue (selection, links). */
export const MAC_BLUE = '#0A84FF';
/** A smooth "spring" like the system animations: response (s) and damping ratio, closed form, starts at t0. */
export const macSpring = (t: number, t0: number, response = 0.5, damping = 0.82) => {
const x = t - t0;
if (x <= 0) return 0;
const w0 = (2 * Math.PI) / response;
if (damping >= 1) return 1 - (1 + w0 * x) * Math.exp(-w0 * x);
const wd = w0 * Math.sqrt(1 - damping * damping);
return 1 - Math.exp(-damping * w0 * x) * (Math.cos(wd * x) + ((damping * w0) / wd) * Math.sin(wd * x));
};
// ------------------------------------------------------------------------------------------------ glass
/**
* A liquid-glass plate. On a transparent render there is nothing behind it to blur, so the look comes from a soft
* milky fill, a bright rim and a sheen; inside Remotion, over your footage, `backdrop-filter` also blurs what's behind.
* dark = smoked glass (for light footage).
*/
export const Glass: React.FC<{w: number; h: number; r?: number; dark?: boolean; frost?: boolean; opacity?: number; style?: React.CSSProperties; children?: React.ReactNode; shadow?: number}> = ({w, h, r = 32, dark = false, frost = false, opacity = 1, style, children, shadow = 1}) => (
{/* the sheen: light caught on the upper left of the glass */}
{/* the rim: bright on top, a thin line all round */}
{children}
);
// ------------------------------------------------------------------------------------------------ icons
/** A generic blue folder (our own drawing): back with its tab, a lighter front. */
export const FolderIcon: React.FC<{size: number; color?: string; dim?: number}> = ({size, color = '#3BA6F5', dim = 0}) => {
const id = `fd${color.replace('#', '')}`;
return (
);
};
/** A document with a folded corner and a coloured label for its type ("MP4", "PDF"...). */
export const FileIcon: React.FC<{size: number; ext?: string; color?: string; dim?: number}> = ({size, ext = 'MP4', color = '#7C5CFF', dim = 0}) => (
);
/** A glassy trash can with ribs (our own drawing). fill 0..1 = papers inside; lid lifts with `open`. */
export const TrashIcon: React.FC<{size: number; fill?: number; open?: number}> = ({size, fill = 0, open = 0}) => (
);
/** The kinds of generic app tiles (no real app's logo). */
export type TileKind = 'files' | 'photos' | 'video' | 'music' | 'chat' | 'mail' | 'notes' | 'calendar' | 'camera' | 'ai' | 'settings' | 'design' | 'browser' | 'maps';
const TILE_BG: Record = {
files: 'linear-gradient(180deg, #5ac8fa, #1e7cf2)',
photos: 'linear-gradient(160deg, #ffd25e, #ff7a59 55%, #ff4f8b)',
video: 'linear-gradient(160deg, #8f6bff, #4b2fd6)',
music: 'linear-gradient(160deg, #ff6a88, #ff2d55)',
chat: 'linear-gradient(180deg, #67e37b, #22b845)',
mail: 'linear-gradient(180deg, #4fc3ff, #1475f5)',
notes: 'linear-gradient(180deg, #fff6c9 0%, #fff6c9 26%, #ffffff 26%)',
calendar: '#ffffff',
camera: 'linear-gradient(180deg, #e9ebef, #b9bec8)',
ai: 'linear-gradient(150deg, #1b1b22, #2c2a3a)',
settings: 'linear-gradient(180deg, #d7dae0, #9aa0ab)',
design: 'linear-gradient(160deg, #ffb340, #ff6a2c)',
browser: 'linear-gradient(180deg, #ffffff, #e6ecf5)',
maps: 'linear-gradient(150deg, #8ee08a 0%, #8ee08a 45%, #f4e7c5 45%)',
};
const glyph = (k: TileKind, day: string): React.ReactNode => {
const w = {stroke: '#fff', strokeWidth: 5, fill: 'none', strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const};
switch (k) {
case 'files': return ;
case 'photos': return ;
case 'video': return ;
case 'music': return ;
case 'chat': return ;
case 'mail': return ;
case 'notes': return {[44, 56, 68].map((y) => )};
case 'calendar': return {'MON'}{day};
case 'camera': return ;
case 'ai': return ;
case 'settings': return ;
case 'design': return ;
case 'browser': return ;
case 'maps': return ;
}
};
/** A rounded app tile in that squircle shape, with a simple glyph. */
export const Tile: React.FC<{kind: TileKind; size: number; day?: string; style?: React.CSSProperties}> = ({kind, size, day = '10', style}) => (
);
/** A file / folder name under an icon; selected = white on blue, like a desktop selection. */
export const IconLabel: React.FC<{text: string; selected?: boolean; size?: number; font?: string; maxW?: number}> = ({text, selected = false, size = 22, font, maxW = 220}) => (
{text}
);
/**
* A dock: glass shelf, tiles left to right, a thin divider, the trash can last. `cx`/`cy` = centre of the shelf.
* grow = how much the trash swells (1 = none), magnify = index of a tile under the cursor (-1 = none).
*/
export const dockWidth = (n: number, size: number) => (n + 1) * size + (n + 1) * size * 0.2 + size * 0.5;
export const Dock: React.FC<{apps: TileKind[]; cx: number; cy: number; size?: number; grow?: number; trashFill?: number; dark?: boolean; lift?: number[]}> = ({apps, cx, cy, size = 84, grow = 1, trashFill = 0, dark = false, lift = []}) => {
const gap = size * 0.2;
const w = dockWidth(apps.length, size);
const h = size + gap * 1.6;
const x0 = cx - w / 2;
return (
{apps.map((k, i) => (
))}
);
};
/** Centre x of the trash can in a dock of n apps centred on cx. */
export const dockTrashX = (n: number, cx: number, size = 84) => {
const gap = size * 0.2;
const x0 = cx - dockWidth(n, size) / 2;
return x0 + gap + n * (size + gap) + gap * 0.5 + size / 2;
};
/** Centre x of app i. */
export const dockAppX = (i: number, n: number, cx: number, size = 84) => cx - dockWidth(n, size) / 2 + size * 0.2 + i * size * 1.2 + size / 2;
// ------------------------------------------------------------------------------------------------ colour
/** Lighten (k > 0) or darken (k < 0) a hex colour. */
export function shade(hex: string, k: number) {
const m = rgba(hex, 1).match(/\d+/g)!.slice(0, 3).map(Number);
const f = (c: number) => Math.round(k >= 0 ? c + (255 - c) * k : c * (1 + k));
return `rgb(${m.map(f).join(',')})`;
}
// ------------------------------------------------------------------------------------------------ frosted windows (the "Mac glass" edit style)
/** Pop in (spring up out of a blur) and out (shrink into a blur): the way every frosted window arrives and leaves. */
export const pop = (t: number, total: number, t0 = 0.05, outDur = 0.38): React.CSSProperties & {k: number} => {
const k = macSpring(t, t0, 0.5, 0.74);
const o = Math.min(1, Math.max(0, (t - (total - outDur)) / outDur));
const oe = o * o;
const blur = Math.max(0, (1 - k) * 14) + oe * 12;
return {k, opacity: Math.min(1, Math.max(0, k * 1.8)) * (1 - oe), transform: `scale(${(0.82 + 0.18 * k) * (1 - 0.1 * oe)}) translateY(${(1 - k) * 24}px)`,
filter: blur > 0.3 ? `blur(${blur}px)` : undefined};
};
/** The three window dots. */
export const Lights: React.FC<{size?: number}> = ({size = 15}) => (
{['#FF5F57', '#FEBC2E', '#28C840'].map((c) => )}
);
/** A frosted window: dots on the left, a small grey title in the middle, then the content. dark = terminal glass. */
export const Win: React.FC<{w: number; h: number; title: string; dark?: boolean; font?: string; children?: React.ReactNode; style?: React.CSSProperties}> = ({w, h, title, dark = false, font, children, style}) => (
{title}
{children}
);
/** A frosted pill with text (an emoji / icon before it is fine). */
export const Pill: React.FC<{text: React.ReactNode; size?: number; w?: number; font?: string; rtl?: boolean; style?: React.CSSProperties}> = ({text, size = 34, w, font, rtl = true, style}) => (
{text}
);
/** Dark ink for text on frosted glass. */
export const INK = '#1f1f24';
export const INK2 = 'rgba(31,31,36,0.45)';
// ---------------------------------------------------------------- the scene
/**
* Mac style: the search bar. A glass search bar springs open in the middle of the frame, your words type in, results
* drop in under it one by one, the top one is highlighted, then it "opens": the bar pulses and everything folds away.
* 4.6 s. Design: the desktop's quick search, drawn in code.
*/
export type MacSpotlightProps = Base & {
query: string;
results: {kind: TileKind; name: string; sub: string}[];
dark: boolean; // smoked glass (for light footage)
placeholder: string;
};
export const macSpotlightDefaults: MacSpotlightProps = {
duration: 4.6,
side: 'center',
y: 42,
query: 'עורך וידאו',
placeholder: 'חיפוש',
results: [
{kind: 'video', name: 'עורך וידאו AI', sub: 'אפליקציה'},
{kind: 'files', name: 'טיוטות לסרטון', sub: 'תיקייה'},
{kind: 'notes', name: 'רעיונות לרילס', sub: 'פתק'},
],
dark: false,
};
const W = 1000;
const BAR = 112;
const ROW = 96;
export const MacSpotlight: React.FC = (props) => {
const p = {...macSpotlightDefaults, ...props};
const t = useT();
const total = p.duration!;
const rtl = dirOf(p.query + p.placeholder) === 'rtl';
const font = macFont(p.query, p.font);
const n = Math.min(4, p.results.length);
const H = BAR + 30 + n * ROW + 30;
const ink = p.dark ? '#fff' : '#1c1c1e';
const sub = p.dark ? 'rgba(255,255,255,0.55)' : 'rgba(28,28,30,0.5)';
const open = macSpring(t, 0.05, 0.5, 0.72);
const typeA = 0.6;
const typeB = typeA + Math.min(1.1, p.query.length * 0.075);
const chars = Math.round(p.query.length * p01(t, typeA, typeB));
const listAt = typeB + 0.1;
const list = macSpring(t, listAt, 0.5, 0.85);
const pick = total - 1.0; // the top result opens
const pulse = macSpring(t, pick, 0.25, 0.5) - macSpring(t, pick + 0.12, 0.35, 0.9);
const fold = macSpring(t, pick + 0.25, 0.45, 1);
const leave = p01(t, total - 0.3, total);
const op = clamp01(open * 2) * (1 - fold * 0.9) * (1 - leave);
const panelH = lerp(BAR, H, clamp01(list) * (1 - fold));
const caret = t > typeA - 0.3 && Math.floor(t * 2.2) % 2 === 0 && t < listAt ? 1 : t < typeA ? 0.9 : 0;
return (