From f1fcdd1372c2329db37992dbc68d77ffb9e6775b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Alexander=20Str=C3=B8mseng?= Date: Wed, 10 Apr 2024 16:00:55 +0200 Subject: [PATCH] 209 add headingstitles to blog satellite page also add common marginspaddin around most pages (#236) * feat(frontend): :sparkles: padding and pageheader components, add to all layouts * utilize pageHeader and subtitle * wip blog posts refactor * finally fix grid responsiveness * add blocksrenderer back to blogcard * blogs styling and refactoring * fix(frontend): fix key prop warning * run prettier * refactor(frontend): :recycle: Refactor code in satellite page and move to satelliteCard component * refactor(frontend): :recycle: Run prettier --------- Co-authored-by: Lucas Tran --- frontend/src/app/blog/blogDataCards.tsx | 59 ++++++------ frontend/src/app/blog/layout.tsx | 5 + frontend/src/app/blog/page.tsx | 24 ++++- frontend/src/app/projects/layout.tsx | 5 + frontend/src/app/projects/page.tsx | 17 +++- frontend/src/app/satellites/layout.tsx | 5 + frontend/src/app/satellites/page.tsx | 61 ++++++++---- frontend/src/components/BlogpageButtons.tsx | 16 +++- frontend/src/components/PageHeader.tsx | 20 ++++ frontend/src/components/PagePadding.tsx | 19 ++++ frontend/src/components/fullBlogCard.tsx | 95 ++++++++++--------- .../components/homeComponents/homeGlobe.tsx | 3 +- frontend/src/components/ui/blogCard.tsx | 27 +----- frontend/src/components/ui/satelliteCard.tsx | 23 ++--- 14 files changed, 231 insertions(+), 148 deletions(-) create mode 100644 frontend/src/app/blog/layout.tsx create mode 100644 frontend/src/app/projects/layout.tsx create mode 100644 frontend/src/app/satellites/layout.tsx create mode 100644 frontend/src/components/PageHeader.tsx create mode 100644 frontend/src/components/PagePadding.tsx diff --git a/frontend/src/app/blog/blogDataCards.tsx b/frontend/src/app/blog/blogDataCards.tsx index 9b7bebd..c9d38f9 100644 --- a/frontend/src/app/blog/blogDataCards.tsx +++ b/frontend/src/app/blog/blogDataCards.tsx @@ -1,6 +1,7 @@ import FullBlogCard from "@/components/fullBlogCard"; import BlogpageButtons from "@/components/BlogpageButtons"; import { BlogPost } from "./page"; +import React from "react"; export default async function BlogDataCards({ articles, @@ -16,34 +17,34 @@ export default async function BlogDataCards({ } return ( -
- {articles.map((article: any) => { - return ( -
- {" "} - {article.firstArticle ? : null} -
- ); - })} -
+ <> +
+ + {/* Only map fist article */} + {articles.map((article: BlogPost) => { + if (article.firstArticle) { + return ( + + + + ); + } + })} + + {articles.map((article: BlogPost) => { + if (article.firstArticle) { + return; + } + return ( + + + + ); + })} +
+ ); } diff --git a/frontend/src/app/blog/layout.tsx b/frontend/src/app/blog/layout.tsx new file mode 100644 index 0000000..3eab227 --- /dev/null +++ b/frontend/src/app/blog/layout.tsx @@ -0,0 +1,5 @@ +import { PagePadding } from "@/components/PagePadding"; +import React from "react"; +export default function Layout({ children }: { children: React.ReactNode }) { + return {children}; +} diff --git a/frontend/src/app/blog/page.tsx b/frontend/src/app/blog/page.tsx index 9b5422b..f09dca9 100644 --- a/frontend/src/app/blog/page.tsx +++ b/frontend/src/app/blog/page.tsx @@ -3,6 +3,11 @@ import BlogDataCards from "./blogDataCards"; import { BlocksContent } from "@strapi/blocks-react-renderer"; import { Enum_Article_Tag } from "@/__generated__/graphql"; import fetchArticlePages from "@/lib/data/fetchArticleInfo"; +import { + PageHeaderAndSubtitle, + PageSubtitle, + PageHeader, +} from "@/components/PageHeader"; export interface BlogPost { key: string | null | undefined; @@ -41,10 +46,19 @@ export default async function BlogPage({ const { articleList, totalArticles } = result; return ( -
- {/* */} - - -
+ <> + + Blog + + Welcome to the blog! Here you can find all of the articles + we have written. + + +
+ {/* */} + + +
+ ); } diff --git a/frontend/src/app/projects/layout.tsx b/frontend/src/app/projects/layout.tsx new file mode 100644 index 0000000..3eab227 --- /dev/null +++ b/frontend/src/app/projects/layout.tsx @@ -0,0 +1,5 @@ +import { PagePadding } from "@/components/PagePadding"; +import React from "react"; +export default function Layout({ children }: { children: React.ReactNode }) { + return {children}; +} diff --git a/frontend/src/app/projects/page.tsx b/frontend/src/app/projects/page.tsx index 422b108..be85fd6 100644 --- a/frontend/src/app/projects/page.tsx +++ b/frontend/src/app/projects/page.tsx @@ -4,6 +4,11 @@ import { getClient } from "@/lib/ApolloClient"; import Link from "next/link"; import Image from "next/image"; import { SlicePreviewText } from "@/components/SlicePreviewText"; +import { + PageHeader, + PageHeaderAndSubtitle, + PageSubtitle, +} from "@/components/PageHeader"; import { OuiImage } from "@/components/fullBlogCard"; const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; @@ -52,13 +57,15 @@ export default async function ProjectsPage() { return (
-

Our Projects

-

- Information about our various projects are shown here. -

+ + Our Projects + + Information about our various projects are shown here. + +
-
+
{graphqlData.data.projects.data.map((project) => { let previewImage = project?.attributes?.previewImage?.data?.attributes diff --git a/frontend/src/app/satellites/layout.tsx b/frontend/src/app/satellites/layout.tsx new file mode 100644 index 0000000..3eab227 --- /dev/null +++ b/frontend/src/app/satellites/layout.tsx @@ -0,0 +1,5 @@ +import { PagePadding } from "@/components/PagePadding"; +import React from "react"; +export default function Layout({ children }: { children: React.ReactNode }) { + return {children}; +} diff --git a/frontend/src/app/satellites/page.tsx b/frontend/src/app/satellites/page.tsx index 0454403..8b342fe 100644 --- a/frontend/src/app/satellites/page.tsx +++ b/frontend/src/app/satellites/page.tsx @@ -1,6 +1,11 @@ import { gql } from "@/__generated__/gql"; import { getClient } from "@/lib/ApolloClient"; import SatelliteCard from "@/components/ui/satelliteCard"; +import { + PageHeader, + PageHeaderAndSubtitle, + PageSubtitle, +} from "@/components/PageHeader"; const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; const GET_SATELLITES = gql(` @@ -33,26 +38,42 @@ export default async function Satellites() { }); return ( -
- {graphqlData?.data?.satellites?.data?.map((satellite: any) => { - let previewImage = - satellite?.attributes?.previewImage?.data?.attributes - ?.url; - if (OUTSIDE_STRAPI_URL && previewImage != undefined) { - previewImage = OUTSIDE_STRAPI_URL + previewImage; - } - let satelliteName = satellite?.attributes?.name ?? ""; - let missionStatus = - satellite?.attributes?.missionStatus ?? ""; - return ( - // eslint-disable-next-line react/jsx-key - - ); - })} +
+ + Satellites + + Theese are all the satellites we have worked on. + + +
+ {graphqlData?.data?.satellites?.data?.map( + (satellite: any) => { + let previewImage = + satellite?.attributes?.previewImage?.data + ?.attributes?.url; + if ( + OUTSIDE_STRAPI_URL && + previewImage != undefined + ) { + previewImage = + OUTSIDE_STRAPI_URL + previewImage; + } + let satelliteName = + satellite?.attributes?.name ?? ""; + let missionStatus = + satellite?.attributes?.missionStatus ?? ""; + return ( + // eslint-disable-next-line react/jsx-key + + ); + }, + )} +
); } catch (error) { diff --git a/frontend/src/components/BlogpageButtons.tsx b/frontend/src/components/BlogpageButtons.tsx index ddb342d..ca5010d 100644 --- a/frontend/src/components/BlogpageButtons.tsx +++ b/frontend/src/components/BlogpageButtons.tsx @@ -2,8 +2,9 @@ import { useState } from "react"; import { Button } from "./ui/button"; import { useRouter, useSearchParams } from "next/navigation"; +import { cn } from "@/lib/utils"; -export default function BlogpageButtons() { +export default function BlogpageButtons({ className }: { className?: string }) { const [activeButton, setActiveButton] = useState("All Posts"); const router = useRouter(); const page = useSearchParams().get("currentPage"); @@ -18,21 +19,26 @@ export default function BlogpageButtons() { }; return ( -
+