From 5f70ed73b94f6aacf03398dbb361cae8df1c9785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Mon, 18 Mar 2024 11:04:28 +0100 Subject: [PATCH] Fix page cover display (#291) * Fix page cover display Make it always looks good with the recommended size of 1990x480. * Take maximum size on mobile * Stabilize visual testing --- e2e/pages.spec.ts | 6 +++++ src/components/PageBody/PageCover.tsx | 30 ++++++++++++++-------- src/components/primitives/DateRelative.tsx | 7 ++++- src/components/utils/Image.tsx | 2 +- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/e2e/pages.spec.ts b/e2e/pages.spec.ts index 56d1f9998..035e7ede8 100644 --- a/e2e/pages.spec.ts +++ b/e2e/pages.spec.ts @@ -404,6 +404,12 @@ for (const testCase of testCases) { } await argosScreenshot(page, `${testCase.name} - ${testEntry.name}`, { viewports: ['macbook-13', 'iphone-x', 'ipad-2'], + argosCSS: ` + /* Hide Intercom */ + .intercom-lightweight-app { + display: none !important; + } + `, }); }); } diff --git a/src/components/PageBody/PageCover.tsx b/src/components/PageBody/PageCover.tsx index 6ed1b3605..7d1acf18d 100644 --- a/src/components/PageBody/PageCover.tsx +++ b/src/components/PageBody/PageCover.tsx @@ -1,12 +1,14 @@ import { RevisionPageDocument, RevisionPageDocumentCover } from '@gitbook/api'; -import { Image } from '@/components/utils'; +import { Image, ImageSize } from '@/components/utils'; import { ContentRefContext, resolveContentRef } from '@/lib/references'; import { tcls } from '@/lib/tailwind'; import defaultPageCover from './default-page-cover.svg'; import { PAGE_COVER_HEIGHT } from '../layout'; +const PAGE_COVER_SIZE: ImageSize = { width: 1990, height: 480 }; + /** * Cover for the page. */ @@ -22,23 +24,29 @@ export async function PageCover(props: { return (
Page cover image
); diff --git a/src/components/primitives/DateRelative.tsx b/src/components/primitives/DateRelative.tsx index 9544720f6..dc6f87417 100644 --- a/src/components/primitives/DateRelative.tsx +++ b/src/components/primitives/DateRelative.tsx @@ -28,7 +28,12 @@ export function DateRelative(props: { value: string }) { const date = new Date(value); const diff = now - date.getTime(); return ( -