From 7ae3e093a4ce5bba030ffc798e54596d4d8c0254 Mon Sep 17 00:00:00 2001
From: DrMint <29893320+DrMint@users.noreply.github.com>
Date: Sat, 9 Mar 2024 23:48:29 +0100
Subject: [PATCH] Improve file preview
---
.../Previews/CollectiblePreview.astro | 66 ++-------
src/components/Previews/GenericPreview.astro | 132 ++++++++++++++++++
src/components/Previews/PagePreview.astro | 65 ++-------
.../ContentsSection/InlineTagGroups.astro | 52 +++++++
4 files changed, 205 insertions(+), 110 deletions(-)
create mode 100644 src/components/Previews/GenericPreview.astro
create mode 100644 src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro
diff --git a/src/components/Previews/CollectiblePreview.astro b/src/components/Previews/CollectiblePreview.astro
index 35d4022..bb892fa 100644
--- a/src/components/Previews/CollectiblePreview.astro
+++ b/src/components/Previews/CollectiblePreview.astro
@@ -1,4 +1,5 @@
---
+import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n";
import type { EndpointCollectiblePreview } from "src/shared/payload/payload-sdk";
@@ -9,7 +10,7 @@ interface Props {
const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
const {
- collectible: { slug, translations, thumbnail },
+ collectible: { slug, translations, thumbnail, tagGroups },
} = Astro.props;
const { title, pretitle, subtitle } = getLocalizedMatch(translations);
@@ -17,57 +18,12 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations);
{/* ------------------------------------------- HTML ------------------------------------------- */}
-
- {
- thumbnail && (
-
- )
- }
-
-
- {pretitle && {pretitle} }
- {title}
- {subtitle && {subtitle}}
-
-
-
-{/* ------------------------------------------- CSS -------------------------------------------- */}
-
-
+
diff --git a/src/components/Previews/GenericPreview.astro b/src/components/Previews/GenericPreview.astro
new file mode 100644
index 0000000..15865b3
--- /dev/null
+++ b/src/components/Previews/GenericPreview.astro
@@ -0,0 +1,132 @@
+---
+import type { EndpointTagsGroup, PayloadImage } from "src/shared/payload/payload-sdk";
+import ConditionalWrapper from "../ConditionalWrapper.astro";
+import Link from "../Link.astro";
+import InlineTagGroups from "pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro";
+
+interface Props {
+ thumbnail?: PayloadImage | undefined;
+ pretitle?: string | undefined;
+ title: string;
+ subtitle?: string | undefined;
+ href?: string | undefined;
+ tagGroups?: EndpointTagsGroup[];
+ disableRoundedTop?: boolean;
+}
+
+const {
+ thumbnail,
+ title,
+ pretitle,
+ subtitle,
+ href,
+ tagGroups = [],
+ disableRoundedTop = false,
+} = Astro.props;
+---
+
+
+
+ {
+ thumbnail && (
+
+ )
+ }
+
+
+
+ {pretitle && {pretitle} }
+ {title}
+ {subtitle && {subtitle}}
+
+
+ {
+ tagGroups.length > 0 && (
+ <>
+ {subtitle &&
}
+
+
+
+ >
+ )
+ }
+
+
+
+
+
diff --git a/src/components/Previews/PagePreview.astro b/src/components/Previews/PagePreview.astro
index 929a8c2..0bc8518 100644
--- a/src/components/Previews/PagePreview.astro
+++ b/src/components/Previews/PagePreview.astro
@@ -1,4 +1,5 @@
---
+import GenericPreview from "components/Previews/GenericPreview.astro";
import { getI18n } from "src/i18n/i18n";
import type { EndpointPagePreview } from "src/shared/payload/payload-sdk";
@@ -9,7 +10,7 @@ interface Props {
const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
const {
- page: { slug, translations, thumbnail },
+ page: { slug, translations, thumbnail, tagGroups },
} = Astro.props;
const { title, pretitle, subtitle } = getLocalizedMatch(translations);
@@ -17,57 +18,11 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations);
{/* ------------------------------------------- HTML ------------------------------------------- */}
-
- {
- thumbnail && (
-
- )
- }
-
-
- {pretitle && {pretitle} }
- {title}
- {subtitle && {subtitle}}
-
-
-
-{/* ------------------------------------------- CSS -------------------------------------------- */}
-
-
+
diff --git a/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro b/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro
new file mode 100644
index 0000000..edb73d1
--- /dev/null
+++ b/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro
@@ -0,0 +1,52 @@
+---
+import { Icon } from "astro-icon/components";
+import { getI18n } from "src/i18n/i18n";
+import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk";
+
+interface Props {
+ tagGroups: EndpointTagsGroup[];
+}
+
+const { tagGroups } = Astro.props;
+const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
+---
+
+{/* ------------------------------------------- HTML ------------------------------------------- */}
+
+
+
+{/* ------------------------------------------- CSS -------------------------------------------- */}
+
+