programmatic video rendering framework that is actually fast
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Cx from "rescript-classnames/src/Cx.bs.js";
import * as Curry from "rescript/lib/es6/curry.js";
import * as Hooks from "../../hooks/Hooks.bs.js";
import * as React from "react";
import * as Tooltip from "../components/Tooltip.bs.js";
import * as ZoomUtils from "../../utils/ZoomUtils.bs.js";
import * as IconButton from "../components/IconButton.bs.js";
import * as EditorContext from "../../EditorContext.bs.js";
import * as Icon from "@openai/apps-sdk-ui/components/Icon";
function ZoomControls(Props) {
var editorContext = EditorContext.useEditorContext(undefined);
var match = Curry._1(editorContext.usePlayer, undefined);
var dispatch = match[1];
var player = match[0];
var handleZoomIn = Hooks.useEvent(function (param) {
var zoomFactor = ZoomUtils.calculateZoomFactorFromDelta(-1.0, player.zoom, 1.0, undefined);
var newZoom = player.zoom * zoomFactor;
return Curry._1(dispatch, {
TAG: /* SetZoom */3,
_0: newZoom
});
});
var handleZoomOut = Hooks.useEvent(function (param) {
var zoomFactor = ZoomUtils.calculateZoomFactorFromDelta(1.0, player.zoom, 1.0, undefined);
var newZoom = player.zoom * zoomFactor;
if (newZoom <= 1.0) {
return Curry._1(dispatch, {
TAG: /* BatchZoomUpdate */5,
_0: newZoom,
_1: 0.0
});
} else {
return Curry._1(dispatch, {
TAG: /* SetZoom */3,
_0: newZoom
});
}
});
var handleZoomReset = Hooks.useEvent(function (param) {
return Curry._1(dispatch, {
TAG: /* BatchZoomUpdate */5,
_0: 1,
_1: 0.0
});
});
return React.createElement("div", {
"aria-label": "Timeline zoom",
className: "flex items-center",
role: "group"
}, React.createElement(IconButton.make, {
label: "Zoom out",
onClick: handleZoomOut,
children: React.createElement(Icon.Minus, {}),
shortcut: "Scroll"
}), React.createElement(Tooltip.make, {
children: React.createElement("button", {
className: Cx.cx([
"h-9 min-w-[3.25rem] rounded-full px-2 text-xs font-medium text-secondary tabular transition-colors duration-150 hover:bg-primary-ghost-hover hover:text-default",
IconButton.focusRing
]),
type: "button",
onClick: handleZoomReset
}, (player.zoom * 100.0).toFixed(0) + "%"),
content: "Fit timeline"
}), React.createElement(IconButton.make, {
label: "Zoom in",
onClick: handleZoomIn,
children: React.createElement(Icon.Plus, {}),
shortcut: "Scroll"
}));
}
var make = ZoomControls;
export {
make ,
}
/* Hooks Not a pure module */