* chore: fix some lint issues * feat: refactor contact list * feat: refactor relay hint * feat: add missing commands * feat: use new cache layer for react query * feat: refactor column * feat: improve relay hint * fix: replace break with continue in parser * refactor: publish function * feat: add reply command * feat: improve editor * fix: quote * chore: update deps * refactor: note component * feat: improve repost * feat: improve cache * fix: backup screen * refactor: column manager
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
|
|
|
export function ImagePreview({ url }: { url: string }) {
|
|
const open = async (url: string) => {
|
|
const name = new URL(url).pathname
|
|
.split("/")
|
|
.pop()
|
|
.replace(/[^a-zA-Z ]/g, "");
|
|
const label = `viewer-${name}`;
|
|
const window = WebviewWindow.getByLabel(label);
|
|
|
|
if (!window) {
|
|
const newWindow = new WebviewWindow(label, {
|
|
url,
|
|
title: "Image Viewer",
|
|
width: 800,
|
|
height: 800,
|
|
titleBarStyle: "overlay",
|
|
});
|
|
|
|
return newWindow;
|
|
}
|
|
|
|
return await window.setFocus();
|
|
};
|
|
|
|
return (
|
|
<div className="relative my-1 group">
|
|
<img
|
|
src={url}
|
|
alt={url}
|
|
loading="lazy"
|
|
decoding="async"
|
|
style={{ contentVisibility: "auto" }}
|
|
className="max-h-[600px] w-auto object-cover rounded-lg outline outline-1 -outline-offset-1 outline-black/15"
|
|
onClick={() => open(url)}
|
|
onKeyDown={() => open(url)}
|
|
onError={({ currentTarget }) => {
|
|
currentTarget.onerror = null;
|
|
currentTarget.src = "/404.jpg";
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|