"use client"; import { Dropdown } from "antd"; import { RectangleHorizontal, RectangleVertical } from "lucide-react"; import { AspectRatioOptions } from "./types"; export type AspectRatioValue = | "VIDEO_ASPECT_RATIO_LANDSCAPE" | "VIDEO_ASPECT_RATIO_PORTRAIT"; interface AspectRatioSelectorProps { /** Current selected aspect ratio value */ value: AspectRatioValue; /** Change handler when an option is selected */ onChange: (value: AspectRatioValue) => void; /** Optional className to customize the trigger button */ className?: string; /** Optional dropdown placement, defaults to top */ placement?: "top" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight"; /** data-alt tag for analytics/testing */ dataAlt?: string; } /** * A reusable aspect ratio selector (landscape/portrait) using Antd Dropdown. * Shows an icon and label, and calls onChange when a new ratio is chosen. * @param {AspectRatioValue} value - current selected value * @param {(v: AspectRatioValue) => void} onChange - change handler * @param {string} [className] - optional className for trigger button * @param {string} [placement] - Dropdown placement, default is top * @param {string} [dataAlt] - data-alt attribute for the trigger * @returns {JSX.Element} */ export const AspectRatioSelector = ({ value, onChange, className, placement = "top", dataAlt = "config-aspect-ratio", }: AspectRatioSelectorProps) => { return ( ({ key: option.value, label: (
{option.value === "VIDEO_ASPECT_RATIO_LANDSCAPE" ? ( ) : ( )} {option.label}
), })), onClick: ({ key }) => onChange(key as AspectRatioValue), }} trigger={["click"]} placement={placement} >
); }; export default AspectRatioSelector;