Skip to content

Commit e2fa88c

Browse files
Merge pull request #164 from UnsignedArduino/home-page-card-images
Home page card images
2 parents 6f0fd5a + 8f75f7a commit e2fa88c

9 files changed

Lines changed: 45 additions & 7 deletions

File tree

9.96 KB
Loading
9.2 KB
Loading
10.8 KB
Loading
10.4 KB
Loading
9.2 KB
Loading
10.8 KB
Loading

src/components/QuickLinks/QuickLinkCards.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ import { motion } from "framer-motion";
33
import Link from "next/link";
44
import React from "react";
55
import { CARD_VARIANTS } from "@/animations/card";
6+
import Image from "next/image";
7+
import { ThemeContext } from "@/components/Navbar/ThemePicker";
68

79
export default function QuickLinkCards({
810
quickLinks,
9-
divColumnClasses = "row row-cols-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-4 g-3 px-1 pt-1 pb-3",
11+
divColumnClasses = "row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3 px-1 pt-1 pb-3",
1012
}: {
1113
quickLinks: QuickLink[];
1214
divColumnClasses?: string;
1315
}) {
16+
const theme = React.useContext(ThemeContext);
17+
1418
return (
1519
<div style={{ overflow: "hidden" }}>
1620
<div className={divColumnClasses}>
1721
{quickLinks.map((quick: QuickLink, index: number) => {
22+
const image =
23+
theme === "Dark" ? quick.image?.darkTheme : quick.image?.lightTheme;
1824
return (
1925
<motion.div
2026
custom={index}
@@ -32,12 +38,14 @@ export default function QuickLinkCards({
3238
>
3339
<div className="col h-100" key={`help-card-${index}`}>
3440
<div className="card h-100">
35-
{/* <Image
36-
src={quick.image}
37-
alt={quick.altText}
38-
className="card-img-top"
39-
objectFit="cover"
40-
/> */}
41+
{image != undefined ? (
42+
<Image
43+
src={image!}
44+
alt={quick.image?.altText!}
45+
className="card-img-top m-2"
46+
style={{ objectFit: "contain", height: "128px" }}
47+
/>
48+
) : undefined}
4149
<h5 className="card-title m-3 mb-0">{quick.name}</h5>
4250
<div className="card-body">
4351
<div className="card-text">
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import { StaticImageData } from "next/image";
2+
13
export type QuickLink = {
24
name: string;
35
description: string;
46
link: string;
57
linkText: string;
8+
image?: {
9+
darkTheme: StaticImageData;
10+
lightTheme: StaticImageData;
11+
altText: string;
12+
};
613
};

src/pages/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ import Link from "next/link";
77
import { useSession } from "next-auth/react";
88
import QuickLinkCards from "@/components/QuickLinks/QuickLinkCards";
99
import { QuickLink } from "@/components/QuickLinks/types";
10+
import darkBlog from "../assets/images/index/for-dark-theme/blog.png";
11+
import lightBlog from "../assets/images/index/for-light-theme/blog.png";
12+
import darkExtensions from "../assets/images/index/for-dark-theme/extensions.png";
13+
import lightExtensions from "../assets/images/index/for-light-theme/extensions.png";
14+
import darkTools from "../assets/images/index/for-dark-theme/tools.png";
15+
import lightTools from "../assets/images/index/for-light-theme/tools.png";
1016

1117
const pageName = "Home";
1218

@@ -15,25 +21,42 @@ type HomeProps = { appProps: AppProps };
1521
export function Home({ appProps }: HomeProps): React.ReactNode {
1622
const { data: session } = useSession();
1723

24+
// https://arcade.makecode.com/S14537-75361-35697-31523
1825
const quickLinks: QuickLink[] = [
1926
{
2027
name: "Extensions",
2128
description: `A list of ${Math.floor(appProps.extensionsListed / 10) * 10}+ awesome MakeCode Arcade extensions to further your games!`,
2229
link: "/extensions",
2330
linkText: "View awesome extensions",
31+
image: {
32+
darkTheme: darkExtensions,
33+
lightTheme: lightExtensions,
34+
altText:
35+
"A picture of the MakeCode Arcade extension puzzle piece icon in MakeCode Arcade image style.",
36+
},
2437
},
2538
{
2639
name: "Tools",
2740
description: `A list of ${Math.floor(appProps.toolsListed / 10) * 10}+ awesome MakeCode Arcade tools to help you develop great games!`,
2841
link: "/tools",
2942
linkText: "View awesome tools",
43+
image: {
44+
darkTheme: darkTools,
45+
lightTheme: lightTools,
46+
altText: "A picture of tools in MakeCode Arcade image style.",
47+
},
3048
},
3149
{
3250
name: "Blog",
3351
description:
3452
"Read about the latest news and updates in the MakeCode Arcade world!",
3553
link: "/blog",
3654
linkText: "Read the blog",
55+
image: {
56+
darkTheme: darkBlog,
57+
lightTheme: lightBlog,
58+
altText: "A picture of a newspaper in MakeCode Arcade image style.",
59+
},
3760
},
3861
];
3962

0 commit comments

Comments
 (0)