Skip to content

Commit

Permalink
feat(frontend): ✨ Add OuiImage component to replace missing preview i…
Browse files Browse the repository at this point in the history
…mages (#239)
  • Loading branch information
Mads Hermansen authored and GitHub committed Apr 8, 2024
1 parent fb97ce4 commit daaadee
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
7 changes: 6 additions & 1 deletion frontend/src/app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getClient } from "@/lib/ApolloClient";
import Link from "next/link";
import Image from "next/image";
import { SlicePreviewText } from "@/components/SlicePreviewText";
import { OuiImage } from "@/components/fullBlogCard";
const HOST_URL = process.env.HOST_URL;

const GET_PROJECTS = gql(`
Expand Down Expand Up @@ -77,14 +78,18 @@ export default async function ProjectsPage() {
<CardHeader></CardHeader>
<CardContent>
<div className="h-64">
{previewImage && (
{previewImage ? (
<Image
className="max-h-full max-w-full object-contain"
src={previewImage}
alt={previewImage}
width={500}
height={0}
/>
) : (
<div className="m-0 flex aspect-video max-h-full max-w-full items-center justify-center object-contain">
<OuiImage />
</div>
)}
</div>
<CardTitle className="mb-2 mt-2 text-xl font-bold">
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/app/satellites/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Link from "next/link";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import SatelliteStatsTable from "@/components/satelliteData/SatelliteStatsTable";
import Image from "next/image";
import { OuiImage } from "@/components/fullBlogCard";

const HOST_URL = process.env.HOST_URL;
const GET_SATELLITES = gql(`
Expand Down Expand Up @@ -65,14 +66,18 @@ export default async function Satellites() {
satName={satelliteName}
missionStatus={missionStatus}
/>
{previewImage && (
{previewImage ? (
<Image
src={previewImage}
alt={previewImage}
width={200}
height={0}
className="margin p-2"
/>
) : (
<div className="m-0 flex aspect-video max-h-full max-w-full items-center justify-center object-contain">
<OuiImage />
</div>
)}
</CardContent>
</Card>
Expand Down
24 changes: 23 additions & 1 deletion frontend/src/components/fullBlogCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ import Link from "next/link";
import { SlicePreviewText } from "./SlicePreviewText";
import { BlogPost } from "@/app/blog/page";
import Image from "next/image";
import { SVGProps } from "react";

export function OuiImage(props: SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={60}
height={60}
viewBox="0 0 16 16"
{...props}
>
<path
fill="white"
d="M6 5a2 2 0 1 1-4 0a2 2 0 0 1 4 0m9-4a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zm-3.448 6.134l-3.76 2.769a.5.5 0 0 1-.436.077l-.087-.034l-1.713-.87L1 11.8V14h14V9.751zM15 2H1v8.635l4.28-2.558a.5.5 0 0 1 .389-.054l.094.037l1.684.855l3.813-2.807a.5.5 0 0 1 .52-.045l.079.05L15 8.495z"
></path>
</svg>
);
}

export default function FullBlogCard(article: BlogPost) {
function formatDate(dateString: string) {
Expand All @@ -31,14 +49,18 @@ export default function FullBlogCard(article: BlogPost) {
>
<BlogCardHeader>
<BlogCardContent>
{article.coverImage && (
{article.coverImage ? (
<Image
src={article.coverImage}
alt={article.coverImage}
width={500}
height={0}
className="m-0 aspect-video max-h-[250px] w-full object-cover p-0"
/>
) : (
<div className="m-0 flex aspect-video max-h-[250px] w-full items-center justify-center">
<OuiImage />
</div>
)}
<div className="m-5">
<div className="flex">
Expand Down

0 comments on commit daaadee

Please sign in to comment.