From 02638c2374f2cb40e67d6086ffe2659be52e10fe Mon Sep 17 00:00:00 2001 From: luctra02 <64017398+luctra02@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:56:13 +0200 Subject: [PATCH] =?UTF-8?q?style(frontend):=20:lipstick:=20Wrap=20div=20ar?= =?UTF-8?q?ound=20blocksrenderer=20component=20=E2=80=A6=20(#241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style(frontend): :lipstick: Wrap div around blocksrenderer component and add typography tailwind styling for all blocksrendered content * refactor(frontend): :recycle: Run prettier --- .../src/app/projects/[projectSlug]/page.tsx | 2 +- .../src/components/BlockRendererClient.tsx | 142 +++++++++--------- 2 files changed, 73 insertions(+), 71 deletions(-) diff --git a/frontend/src/app/projects/[projectSlug]/page.tsx b/frontend/src/app/projects/[projectSlug]/page.tsx index 0870ef1..e009fd3 100644 --- a/frontend/src/app/projects/[projectSlug]/page.tsx +++ b/frontend/src/app/projects/[projectSlug]/page.tsx @@ -75,7 +75,7 @@ export default async function Page({ } return (
-
+
{graphqlData.data.projects?.data[0].attributes?.satellites?.data diff --git a/frontend/src/components/BlockRendererClient.tsx b/frontend/src/components/BlockRendererClient.tsx index c455f11..7817767 100644 --- a/frontend/src/components/BlockRendererClient.tsx +++ b/frontend/src/components/BlockRendererClient.tsx @@ -13,78 +13,80 @@ export default function BlockRendererClient({ }) { if (!content) return null; return ( - { - return ( - - ); - }, - heading: ({ children, level }) => { - switch (level) { - case 1: - return

{children}

; - case 2: - return

{children}

; - case 3: - return

{children}

; - case 4: - return

{children}

; - case 5: - return
{children}
; - default: - return

{children}

; - } - }, +
+ { + return ( + + ); + }, + heading: ({ children, level }) => { + switch (level) { + case 1: + return

{children}

; + case 2: + return

{children}

; + case 3: + return

{children}

; + case 4: + return

{children}

; + case 5: + return
{children}
; + default: + return

{children}

; + } + }, - paragraph: ({ children }) => { - const child = children as { - props: { - type: "text"; - text: string; - italic: boolean; - }; - }[]; + paragraph: ({ children }) => { + const child = children as { + props: { + type: "text"; + text: string; + italic: boolean; + }; + }[]; - const italic = child[0]?.props.italic; - if (italic) { - return

{children}

; - } - return

{children}

; - }, + const italic = child[0]?.props.italic; + if (italic) { + return

{children}

; + } + return

{children}

; + }, - link: ({ url, children }) => { - // Check if the URL is a valid YouTube video link - const isYouTubeVideo = url.includes("youtube.com"); - // Render the iframe only if it's a YouTube video link - if (isYouTubeVideo) { - return ( -
- -
- ); - } else { - // If it's not a video link, return an anchor with the href - return ( - - {children} - - ); - } - }, - }} - /> + link: ({ url, children }) => { + // Check if the URL is a valid YouTube video link + const isYouTubeVideo = url.includes("youtube.com"); + // Render the iframe only if it's a YouTube video link + if (isYouTubeVideo) { + return ( +
+ +
+ ); + } else { + // If it's not a video link, return an anchor with the href + return ( + + {children} + + ); + } + }, + }} + /> +
); }