import './assets.less'; import React, { useRef } from 'react'; import cx from 'classnames'; import { imageFiles, formatBytes } from './assetClient.js'; // Button in der Snippet-Bar (ADR 0004 §5): Dateiauswahl, Fortschritt und Fehlertexte direkt am Button. // Sichtbar nur bei Git-verknüpften Brews (assetUpload.available). const AssetUploadButton = ({ assetUpload })=>{ const input = useRef(null); if(!assetUpload?.available) return null; const { cfg, busy, percent, name, errors, done, upload, dismiss } = assetUpload; const accept = cfg.types.map((t)=>`image/${t}`).join(','); return (
{ const files = imageFiles(e.target.files); e.target.value = ''; upload(files); }} /> {(busy || errors.length > 0 || done > 0) && (
0 })} role='status'> {busy && „{name}“ wird hochgeladen{percent != null ? ` (${percent} %)` : ''} …} {!busy && done > 0 && errors.length === 0 && {done === 1 ? 'Bild eingefügt.' : `${done} Bilder eingefügt.`} Hinweis: Fotos können Metadaten (z. B. GPS) enthalten und sind über den Teilen-Link öffentlich.} {!busy && errors.map((msg, i)=>{msg})} {!busy && }
)}
); }; export default AssetUploadButton;