Skip to content

Commit

Permalink
Merge branch 'main' into simon/make-area-under-traffic-lights-dragabl…
Browse files Browse the repository at this point in the history
…e-and-slightly-larger
  • Loading branch information
Simon-Laux authored Dec 13, 2024
2 parents 46c371e + d1a3f8d commit 1186332
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- avoid drafts in readonly chats #4349
- fullscreen images getting cropped a little #4402, #4385
- macOS: make area under traffic lights dragable and fix the bug that its size changed based on profile acount and window height #4408
- fix chat "scrolls up" right after switching #4404

<a id="1_49_0"></a>

Expand Down
16 changes: 13 additions & 3 deletions packages/frontend/scss/message/_message-attachment.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@
overflow: hidden;

background-color: var(--messageAttachmentIconBg);

/**
* we need a fix height for images to prevent reflow when the image loads
* till we have a better solution (more flexible) we allow a maximum height
* of 200px for all images in landscape mode and 300px for portrait mode
*
* for higher values (than 200px) we have to add media queries otherwise
* messages with images get strange paddings on small windows
*/
& > .attachment-content {
object-fit: scale-down;
object-position: center;
max-height: 600px;
height: 200px;
max-width: 100%;
min-width: 80px;
&.portrait {
height: 300px;
}

// The padding on the bottom of the bubble produces 4 extra pixels of space at the
// bottom, so this doesn't match up with the padding numbers above.
Expand Down Expand Up @@ -76,7 +86,7 @@
.message.type-sticker {
.message-attachment-media {
& > .attachment-content {
max-height: 300px;
max-height: 200px;
max-width: 80%;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import FullscreenMedia, {
import useTranslationFunction from '../../hooks/useTranslationFunction'
import useDialog from '../../hooks/dialog/useDialog'
import AudioPlayer from '../AudioPlayer'
import { T } from '@deltachat/jsonrpc-client'

type AttachmentProps = {
text?: string
Expand Down Expand Up @@ -54,6 +55,15 @@ export default function Attachment({
openAttachmentInShell(message)
}
}

const isPortrait = (
message: Pick<T.Message, 'dimensionsHeight' | 'dimensionsWidth'>
) => {
if (message.dimensionsHeight === 0 || message.dimensionsWidth === 0) {
return false
}
return message.dimensionsWidth / message.dimensionsHeight <= 3 / 4
}
const withCaption = Boolean(text)
// For attachments which aren't full-frame
const withContentBelow = withCaption
Expand Down Expand Up @@ -84,7 +94,10 @@ export default function Attachment({
)}
>
<img
className='attachment-content'
className={classNames(
'attachment-content',
isPortrait(message) ? 'portrait' : null
)}
src={runtime.transformBlobURL(message.file)}
/>
</button>
Expand Down

0 comments on commit 1186332

Please sign in to comment.