Skip to content

Commit

Permalink
Attempt to fix attachments not showing up on Samsung Internet.
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Aug 16, 2021
1 parent dcb038f commit 72e9cda
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion external/lang
Submodule lang updated from 1c7f5e to 76f335
45 changes: 29 additions & 16 deletions src/components/common/messaging/attachments/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@ import styled from "styled-components";

import { Children } from "../../../../types/Preact";

const Grid = styled.div`
const Grid = styled.div<{ width: number; height: number }>`
display: grid;
aspect-ratio: ${(props) => props.width} / ${(props) => props.height};
aspect-ratio: var(--aspect-ratio);
max-width: min(
100%,
${(props) => props.width}px,
var(--attachment-max-width)
);
max-height: min(${(props) => props.height}px, var(--attachment-max-height));
@supports not (
aspect-ratio: ${(props) => props.width} / ${(props) => props.height}
) {
div::before {
float: left;
padding-top: ${(props) => (props.height / props.width) * 100}%;
content: "";
}
max-width: min(100%, var(--width), var(--attachment-max-width));
max-height: min(var(--height), var(--attachment-max-height));
div::after {
display: block;
content: "";
clear: both;
}
}
img, video {
img,
video {
grid-area: 1 / 1;
display: block;
max-width: 100%;
Expand Down Expand Up @@ -44,24 +65,16 @@ type Props = Omit<
JSX.HTMLAttributes<HTMLDivElement>,
"children" | "as" | "style"
> & {
style?: JSX.CSSProperties;
children?: Children;
width: number;
height: number;
};

export function SizedGrid(props: Props) {
const { width, height, children, style, ...divProps } = props;
const { width, height, children, ...divProps } = props;

return (
<Grid
{...divProps}
style={{
...style,
"--width": `${width}px`,
"--height": `${height}px`,
"--aspect-ratio": `${width} / ${height}`,
}}>
<Grid {...divProps} width={width} height={height}>
{children}
</Grid>
);
Expand Down

0 comments on commit 72e9cda

Please sign in to comment.