mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 17:35:28 +00:00
Fix: image attachments not having minimum width
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
max-width: min(480px, 100%, var(--width-px));
|
max-width: min(480px, 100%, var(--width-px));
|
||||||
|
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
object-position: top left;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.image {
|
&.image {
|
||||||
@@ -37,6 +38,10 @@
|
|||||||
&.tall {
|
&.tall {
|
||||||
height: min(100%, var(--height-px));
|
height: min(100%, var(--height-px));
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
&.loaded {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export default function Attachment({ attachment, hasContent }: Props) {
|
|||||||
const { openScreen } = useIntermediate();
|
const { openScreen } = useIntermediate();
|
||||||
const { filename, metadata } = attachment;
|
const { filename, metadata } = attachment;
|
||||||
const [spoiler, setSpoiler] = useState(filename.startsWith("SPOILER_"));
|
const [spoiler, setSpoiler] = useState(filename.startsWith("SPOILER_"));
|
||||||
|
const [loaded, setLoaded] = useState(false);
|
||||||
|
|
||||||
const url = client.generateFileURL(
|
const url = client.generateFileURL(
|
||||||
attachment,
|
attachment,
|
||||||
@@ -55,6 +56,7 @@ export default function Attachment({ attachment, hasContent }: Props) {
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
styles.attachment,
|
styles.attachment,
|
||||||
styles.image,
|
styles.image,
|
||||||
|
loaded && styles.loaded,
|
||||||
metadata.width > metadata.height
|
metadata.width > metadata.height
|
||||||
? styles.long
|
? styles.long
|
||||||
: styles.tall,
|
: styles.tall,
|
||||||
@@ -68,6 +70,7 @@ export default function Attachment({ attachment, hasContent }: Props) {
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
openScreen({ id: "image_viewer", attachment })
|
openScreen({ id: "image_viewer", attachment })
|
||||||
}
|
}
|
||||||
|
onLoad={() => setLoaded(true)}
|
||||||
onMouseDown={(ev) =>
|
onMouseDown={(ev) =>
|
||||||
ev.button === 1 && window.open(url, "_blank")
|
ev.button === 1 && window.open(url, "_blank")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user