Skip to content

Commit a76c9a5

Browse files
authored
Flip card logic (#2835)
1 parent eaad0d4 commit a76c9a5

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Diff for: packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx

+12-14
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export async function RecordCard(
2828
: null;
2929
const target = targetRef ? await context.resolveContentRef(targetRef) : null;
3030

31-
const coverIsLandscape =
31+
const coverIsSquareOrPortrait =
3232
cover?.file?.dimensions &&
33-
cover.file?.dimensions?.width / cover.file?.dimensions?.height > 1;
33+
cover.file?.dimensions?.width / cover.file?.dimensions?.height <= 1;
3434

3535
const body = (
3636
<div
@@ -54,15 +54,13 @@ export async function RecordCard(
5454
// On mobile, check if we can display the cover responsively or not:
5555
// - If the file has a landscape aspect ratio, we display it normally
5656
// - If the file is square or portrait, we display it left with 40% of the card width
57-
cover
58-
? coverIsLandscape
59-
? 'grid-rows-[auto,1fr]'
60-
: [
61-
'grid-cols-[40%,_1fr]',
62-
'min-[432px]:grid-cols-none',
63-
'min-[432px]:grid-rows-[auto,1fr]',
64-
]
65-
: null,
57+
coverIsSquareOrPortrait
58+
? [
59+
'grid-cols-[40%,_1fr]',
60+
'min-[432px]:grid-cols-none',
61+
'min-[432px]:grid-rows-[auto,1fr]',
62+
]
63+
: 'grid-rows-[auto,1fr]',
6664
)}
6765
>
6866
{cover ? (
@@ -84,9 +82,9 @@ export async function RecordCard(
8482
'w-full',
8583
'h-full',
8684
'object-cover',
87-
coverIsLandscape
88-
? ['h-auto', 'aspect-video']
89-
: ['min-[432px]:h-auto', 'min-[432px]:aspect-video'],
85+
coverIsSquareOrPortrait
86+
? ['min-[432px]:h-auto', 'min-[432px]:aspect-video']
87+
: ['h-auto', 'aspect-video'],
9088
)}
9189
priority={isOffscreen ? 'lazy' : 'high'}
9290
preload

0 commit comments

Comments
 (0)