import React from "react"; import { ImageResource } from "../../types"; import { CropState } from "./useCrop"; type Ratio = number | null; interface ToolbarProps { cropState: CropState, image: ImageResource, setAspect: (Ratio) => void, toggleCrop: (evt: Event) => void, toggleFocal: (evt: Event) => void } export default function Toolbar(props: ToolbarProps) { const { cropping } = props.cropState; const aspectRatios = [ ["Free", null], ["1:1", 1], ["3:2", 3/2], ["2:3", 2/3], ["4:3", 4/3], ["3:4", 3/4], ["5:4", 5/4], ["4:5", 4/5], ["16:9", 16/9] ]; const updateAspect = (ratio: Ratio) => (evt: Event) => { evt.preventDefault(); props.setAspect(ratio); }; const width = Math.ceil(props.cropState.crop_width); const height = Math.ceil(props.cropState.crop_height); const format = props.image.content_type.split("/")[1].toUpperCase(); return (