Skip to content

Commit

Permalink
4:5 thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM committed Dec 11, 2024
1 parent 64cf504 commit 84a34fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
18 changes: 9 additions & 9 deletions fronts-client/src/components/card/article/ArticleBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { getMaybeDimensionsFromWidthAndHeight } from 'util/validateImageSrc';
import { Criteria } from 'types/Grid';
import {
landscape5To4CardImageCriteria,
portraitCardImageCriteria,
squareImageCriteria,
} from 'constants/image';

Expand Down Expand Up @@ -197,14 +198,6 @@ const articleBodyDefault = React.memo(
const now = Date.now();
const paths = urlPath ? getPaths(urlPath) : undefined;

const thumbnailDims = getMaybeDimensionsFromWidthAndHeight(
imageSrcWidth,
imageSrcHeight,
);
const thumbnailIsPortrait =
!!imageReplace &&
thumbnailDims &&
thumbnailDims.height > thumbnailDims.width;
const showThumbnailInLandscape54 =
imageCriteria &&
imageCriteria.widthAspectRatio ===
Expand All @@ -215,6 +208,13 @@ const articleBodyDefault = React.memo(
imageCriteria &&
imageCriteria.widthAspectRatio === squareImageCriteria.widthAspectRatio &&
imageCriteria.heightAspectRatio === squareImageCriteria.heightAspectRatio;
const showPortraitThumbnail =
imageCriteria &&
imageCriteria.widthAspectRatio ===
portraitCardImageCriteria.widthAspectRatio &&
imageCriteria.heightAspectRatio ===
portraitCardImageCriteria.heightAspectRatio


return (
<>
Expand Down Expand Up @@ -331,7 +331,7 @@ const articleBodyDefault = React.memo(
imageHide={imageHide}
url={thumbnail}
isDraggingImageOver={isDraggingImageOver}
isPortrait={thumbnailIsPortrait}
showPortrait={showPortraitThumbnail}
showLandscape54={showThumbnailInLandscape54}
showSquareThumbnail={showSquareThumbnail}
>
Expand Down
15 changes: 8 additions & 7 deletions fronts-client/src/components/image/Thumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ThumbnailSmall = styled(ThumbnailBase)<{
url?: string | void;
isDraggingImageOver?: boolean;
imageHide?: boolean;
isPortrait?: boolean;
showPortrait?: boolean;
showLandscape54?: boolean;
showSquareThumbnail?: boolean;
}>`
Expand All @@ -22,12 +22,13 @@ const ThumbnailSmall = styled(ThumbnailBase)<{
opacity: ${({ imageHide }) => (imageHide && imageHide ? '0.5' : '1')};
background-image: ${({ url }) => `url('${url}')`};
${({ isPortrait }) =>
isPortrait &&
`
background-size: contain;
background-repeat: no-repeat;
background-position-x: center;
${({ showPortrait }) =>
showPortrait &&
`aspect-ratio: 4/5;
background-position-x: center;
width: ${theme.thumbnailImagePortrait.width};
min-width: ${theme.thumbnailImagePortrait.width};
height: ${theme.thumbnailImagePortrait.height}
`}
${({ showLandscape54 }) =>
showLandscape54
Expand Down
6 changes: 6 additions & 0 deletions fronts-client/src/constants/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ const thumbnailImageSquare = {
height: '80px',
};

const thumbnailImagePortrait = {
width: '68px',
height: '85px',
};

export const theme = {
base,
front,
Expand All @@ -173,6 +178,7 @@ export const theme = {
collection,
thumbnailImage,
thumbnailImageSquare,
thumbnailImagePortrait
};

export type Theme = typeof theme;
Expand Down

0 comments on commit 84a34fa

Please sign in to comment.