plazbot
Version:
Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.
37 lines (36 loc) • 1.53 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { usePlazbotContext } from '../../context/PlazbotContext';
import { resolveIcon } from '../../styles/icons';
function isImage(file) {
const ext = file.name.toLowerCase();
return (ext.endsWith('.png') ||
ext.endsWith('.jpg') ||
ext.endsWith('.jpeg') ||
ext.endsWith('.gif') ||
ext.endsWith('.webp') ||
file.type.startsWith('image/'));
}
export function FilePreview({ file, style }) {
const { theme, iconMode } = usePlazbotContext();
if (isImage(file)) {
return (_jsx("img", { src: file.url, alt: file.name, style: {
maxWidth: '200px',
maxHeight: '200px',
borderRadius: theme.borderRadius,
objectFit: 'cover',
...style,
} }));
}
return (_jsxs("div", { style: {
display: 'flex',
alignItems: 'center',
gap: '8px',
padding: '8px 12px',
backgroundColor: theme.surfaceColor,
borderRadius: theme.borderRadius,
border: `1px solid ${theme.borderColor}`,
fontSize: theme.fontSizeSm,
color: theme.textSecondary,
...style,
}, children: [resolveIcon('file', iconMode) && _jsx("span", { style: { fontSize: '16px' }, children: resolveIcon('file', iconMode) }), _jsx("span", { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: file.name })] }));
}