mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 16:42:27 +00:00
Timeline UI - Highlight clips visible at the playhead in the primary color; others share one neutral color - Minimalist rounded clips, single-color track rows, no gutter icons or superscript labels - Per-track eye toggle and a per-element hide button in the design panel - Ruler zoom fixes: sub-second tick intervals and correct label formatting at high zoom - Sticky gutter so track controls stay visible while scrolling WYSIWYG visibility (data-hidden) - Runtime honors data-hidden (display:none), so hiding affects the render, not just the preview - HTML stays the source of truth; hide state persists and round-trips on reload Split several studio files to stay under the 600-line cap; pure relocations, no behavior change.
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { createContext, useContext, useMemo, type ReactNode } from "react";
|
|
import type { TimelineEditCallbacks } from "../player/components/timelineCallbacks";
|
|
|
|
const TimelineEditContext = createContext<TimelineEditCallbacks | null>(null);
|
|
|
|
export function useTimelineEditContext(): TimelineEditCallbacks {
|
|
const ctx = useContext(TimelineEditContext);
|
|
if (!ctx) throw new Error("useTimelineEditContext must be used within TimelineEditProvider");
|
|
return ctx;
|
|
}
|
|
|
|
/**
|
|
* Optional access — returns an empty object when outside a provider.
|
|
* Useful in components that can render both inside and outside the NLE.
|
|
*/
|
|
export function useTimelineEditContextOptional(): TimelineEditCallbacks {
|
|
return useContext(TimelineEditContext) ?? {};
|
|
}
|
|
|
|
export function TimelineEditProvider({
|
|
value,
|
|
children,
|
|
}: {
|
|
value: TimelineEditCallbacks;
|
|
children: ReactNode;
|
|
}) {
|
|
const memoized = useMemo(
|
|
() => value,
|
|
// Each callback is a stable reference from the parent — memoize the bag
|
|
// so consumers don't re-render when unrelated parent state changes.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[
|
|
value.onMoveElement,
|
|
value.onResizeElement,
|
|
value.onToggleTrackHidden,
|
|
value.onBlockedEditAttempt,
|
|
value.onSplitElement,
|
|
value.onRazorSplit,
|
|
value.onRazorSplitAll,
|
|
value.onDeleteKeyframe,
|
|
value.onDeleteAllKeyframes,
|
|
value.onChangeKeyframeEase,
|
|
value.onMoveKeyframeToPlayhead,
|
|
value.onMoveKeyframe,
|
|
value.onToggleKeyframeAtPlayhead,
|
|
],
|
|
);
|
|
return <TimelineEditContext.Provider value={memoized}>{children}</TimelineEditContext.Provider>;
|
|
}
|