Skip to content
Snippets Groups Projects
Commit 56b509a1 authored by insert's avatar insert
Browse files

Merge branch 'master' of https://gitlab.insrt.uk/revolt/revite

parents 57ef8408 d829deba
No related merge requests found
...@@ -95,3 +95,39 @@ ...@@ -95,3 +95,39 @@
} }
} }
} }
// TODO: unified actions css (see attachment.module.scss for other actions css)
.actions {
display: grid;
grid-template:
"name open" auto
"size open" auto
/ minmax(20px, 1fr) min-content;
align-items: center;
column-gap: 8px;
width: 100%;
padding: 8px;
overflow: none;
color: var(--foreground);
background: var(--secondary-background);
span {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.filesize {
grid-area: size;
font-size: 10px;
color: var(--secondary-foreground);
}
.openIcon {
grid-area: open;
}
}
...@@ -14,13 +14,11 @@ export default function EmbedMediaActions({ embed }: Props) { ...@@ -14,13 +14,11 @@ export default function EmbedMediaActions({ embed }: Props) {
return ( return (
<div className={styles.actions}> <div className={styles.actions}>
<div className={styles.info}> <span className={styles.filename}>{filename}</span>
<span className={styles.filename}>{filename}</span> <span className={styles.filesize}>
<span className={styles.filesize}> {embed.width + "x" + embed.height}
{embed.width + "x" + embed.height} </span>
</span> <a href={embed.url} class={styles.openIcon} target="_blank">
</div>
<a href={embed.url} target="_blank">
<IconButton> <IconButton>
<LinkExternal size={24} /> <LinkExternal size={24} />
</IconButton> </IconButton>
......
import { Attachment, EmbedImage } from "revolt.js/dist/api/objects"; import {
Attachment,
AttachmentMetadata,
EmbedImage,
} from "revolt.js/dist/api/objects";
import styles from "./ImageViewer.module.scss"; import styles from "./ImageViewer.module.scss";
import { useContext, useEffect } from "preact/hooks"; import { useContext, useEffect } from "preact/hooks";
...@@ -15,6 +19,8 @@ interface Props { ...@@ -15,6 +19,8 @@ interface Props {
attachment?: Attachment; attachment?: Attachment;
} }
type ImageMetadata = AttachmentMetadata & { type: "Image" };
export function ImageViewer({ attachment, embed, onClose }: Props) { export function ImageViewer({ attachment, embed, onClose }: Props) {
// ! FIXME: temp code // ! FIXME: temp code
// ! add proxy function to client // ! add proxy function to client
...@@ -22,7 +28,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) { ...@@ -22,7 +28,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
return "https://jan.revolt.chat/proxy?url=" + encodeURIComponent(url); return "https://jan.revolt.chat/proxy?url=" + encodeURIComponent(url);
} }
if (attachment?.metadata.type !== "Image") { if (attachment && attachment.metadata.type !== "Image") {
console.warn(
`Attempted to use a non valid attatchment type in the image viewer: ${attachment.metadata.type}`,
);
return null; return null;
} }
...@@ -35,8 +44,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) { ...@@ -35,8 +44,10 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
<> <>
<img <img
src={client.generateFileURL(attachment)} src={client.generateFileURL(attachment)}
width={attachment.metadata.width} width={(attachment.metadata as ImageMetadata).width}
height={attachment.metadata.height} height={
(attachment.metadata as ImageMetadata).height
}
/> />
<AttachmentActions attachment={attachment} /> <AttachmentActions attachment={attachment} />
</> </>
...@@ -45,8 +56,8 @@ export function ImageViewer({ attachment, embed, onClose }: Props) { ...@@ -45,8 +56,8 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
<> <>
<img <img
src={proxyImage(embed.url)} src={proxyImage(embed.url)}
width={attachment.metadata.width} width={embed.width}
height={attachment.metadata.height} height={embed.height}
/> />
<EmbedMediaActions embed={embed} /> <EmbedMediaActions embed={embed} />
</> </>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment