import 'cropperjs/dist/cropper.css' import { UploadFile } from '@solid-primitives/upload' import Cropper from 'cropperjs' import { createSignal, onMount, Show } from 'solid-js' import { useLocalize } from '../../../context/localize' import { Button } from '../Button' import styles from './ImageCropper.module.scss' interface CropperProps { uploadFile: UploadFile onSave: (any) => void onDecline?: () => void } export const ImageCropper = (props: CropperProps) => { const { t } = useLocalize() const imageTagRef: { current: HTMLImageElement } = { current: null, } const [cropper, setCropper] = createSignal(null) onMount(() => { if (imageTagRef.current) { setCropper( new Cropper(imageTagRef.current, { viewMode: 1, aspectRatio: 1, guides: false, background: false, rotatable: false, autoCropArea: 1, modal: true, }), ) } }) return (
(imageTagRef.current = el)} src={props.uploadFile.source} alt="image crop panel" />
) }