Skip to content

Commit 1c415f4

Browse files
committed
refactor: replace SocialSharingFooter with SocialSharing component and update Footer and Sidebar for improved layout and functionality
1 parent 4b81d78 commit 1c415f4

File tree

7 files changed

+53
-60
lines changed

7 files changed

+53
-60
lines changed

app/layout.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import "./globals.css";
33
import type { Metadata } from "next";
44
import Header from "@/components/Header";
55
import Footer from "@/components/Footer";
6-
// import PodcastContextProvider from "@/context/PodcastContext";
76
import ArticleContextProvider from "@/context/ArticleContext";
87

98
export const metadata: Metadata = {
@@ -27,13 +26,11 @@ export default function RootLayout({
2726
</head>
2827
<body>
2928
<ArticleContextProvider>
30-
{/* <PodcastContextProvider> */}
3129
<Container>
3230
<Header />
3331
{children}
3432
<Footer />
3533
</Container>
36-
{/* </PodcastContextProvider> */}
3734
</ArticleContextProvider>
3835
</body>
3936
</html>

components/Footer.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
"use client";
22

3-
import NewsletterTicker from "./NewsletterTicker";
4-
import { Input } from "@/components/ui/input";
5-
import { Button } from "./ui/button";
63
import Link from "next/link";
74
import FooterSocialLinks from "./FooterSocialsLinks";
8-
import NewsletterSignUp from "./NewsletterSignUp";
95
import Image from "next/image";
106

117
export default function Footer() {
128
return (
13-
<footer className="bg-[#8a2be2] overflow-hidden">
9+
<footer className="overflow-hidden border-t-4 border-[#8a2be2]">
1410
<div className="max-w-[95rem] mx-auto px-6 mt-11">
1511
<div className="flex flex-col md:flex-row flex-wrap lg:justify-between gap-6 max-w-[95rem] w-full">
1612
<Image

components/FooterSocialsLinks.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import SocialSharingFooter from "./SocialSharingFooter";
1+
import SocialSharing from "./SocialSharing";
22
import {
33
RiInstagramLine,
44
RiTwitterFill,
@@ -11,7 +11,7 @@ import {
1111
export default function FooterSocialLinks() {
1212
return (
1313
<div className="flex gap-3">
14-
<SocialSharingFooter
14+
<SocialSharing
1515
links={[
1616
{
1717
href: "https://www.youtube.com/@lap-tutorials",

components/PopularArticles.tsx

+38-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,62 @@
1-
import { useArticleContext } from "@/hooks/useArticleContext";
1+
"use client";
2+
3+
import { useEffect, useState } from "react";
4+
import { collection, onSnapshot, query, where, orderBy } from "firebase/firestore";
5+
import { db } from "@/lib/firebase";
26
import { Separator } from "@radix-ui/react-separator";
37
import Link from "next/link";
48

9+
// Define the structure of an article
10+
type Article = {
11+
id: string;
12+
title: string;
13+
slug: string;
14+
authorName: string;
15+
popularity: boolean;
16+
};
17+
518
export default function PopularArticles() {
6-
const { data } = useArticleContext();
19+
const [popularArticles, setPopularArticles] = useState<Article[]>([]);
20+
21+
useEffect(() => {
22+
// Firestore Query: Get popular articles sorted by popularity
23+
const articlesQuery = query(
24+
collection(db, "articles"),
25+
where("popularity", "==", true),
26+
orderBy("popularity", "asc")
27+
);
728

8-
const popularArticles = data.flatMap((author) =>
9-
author.articles
10-
.filter((article) => article.popular === true)
11-
.sort((a, b) => Number(a.popularity) - Number(b.popularity))
12-
);
29+
const unsubscribe = onSnapshot(articlesQuery, (snapshot) => {
30+
const articles: Article[] = snapshot.docs.map((doc) => ({
31+
id: doc.id,
32+
...doc.data(),
33+
})) as Article[];
34+
35+
setPopularArticles(articles);
36+
});
37+
38+
return () => unsubscribe();
39+
}, []);
1340

1441
return (
1542
<article>
1643
<h2 className="uppercase font-semibold mt-16 mb-8">Most Popular</h2>
1744
{popularArticles.map((article, index) => (
18-
<article key={article.title}>
45+
<article key={article.id}>
1946
<div className="grid grid-cols-[0fr_1fr] gap-8">
2047
<p className="text-2xl font-semibold">{`0${index + 1}`}</p>
2148
<article className="flex flex-col gap-4">
2249
<h3 className="text-2xl font-semibold">
2350
<Link href={`/magazine/${article.slug}`}>{article.title}</Link>
2451
</h3>
2552
<span className="flex gap-2">
26-
<p className="font-semibold">Text</p>
27-
<p>{data[0].author}</p>
53+
<p className="font-semibold">Author:</p>
54+
<p>{article.authorName}</p>
2855
</span>
2956
</article>
3057
</div>
3158
{index < popularArticles.length - 1 && (
32-
<Separator className="border border-black my-6" />
59+
<Separator className="border border-white my-6" />
3360
)}
3461
</article>
3562
))}

components/Sidebar.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ import Image from "next/image";
22
import NewsletterSignUp from "./NewsletterSignUp";
33
import PopularArticles from "./PopularArticles";
44
import { Button } from "./ui/button";
5-
import magazineCover from "@/public/images/homepage/magazine-cover.jpg";
5+
import magazineCover from "@/public/logos/LAP-Logo-Color.png";
66

77
export default function Sidebar() {
8+
const youtubeChannelUrl =
9+
"https://www.youtube.com/@lap-tutorials?sub_confirmation=1";
10+
811
return (
912
<aside>
10-
<h3 className="uppercase font-semibold mb-2">Printmagazine</h3>
11-
<p className="text-5xl font-semibold">03/2022</p>
13+
<h3 className="uppercase font-semibold mb-2">Subscribe To</h3>
14+
<p className="text-4xl font-semibold">L.A.P - Tutorials</p>
1215
<Image
1316
className="w-[20rem] pt-8 pb-4"
1417
src={magazineCover}
15-
alt="A rust-colored magazine cover, showing a sculpture of a man, the words 'FYRRE MAGAZINE' on the top left and '03/2022' on the bottom right, a gold badge just above with 'EXCLUSIVE JAKOB GRONBERG INTERVIEW' printed on it, and an arrow pointing in the bottom right corner"
18+
alt="A cool and simple logo of L.A.P - Tutorials"
1619
/>
17-
<Button>Order</Button>
20+
<Button asChild className="hover:bg-[#8a2be2] transition ease-in-out duration-300">
21+
<a href={youtubeChannelUrl} target="_blank" rel="noopener noreferrer">
22+
Subscribe on YouTube
23+
</a>
24+
</Button>
1825
<PopularArticles />
19-
<div className="bg-[#f8f8f8] p-[1.88rem] mt-16">
20-
<h3 className="uppercase font-semibold mb-2">Newsletter</h3>
21-
<p className="heading3-title mb-4">Design News to your Inbox</p>
22-
<NewsletterSignUp />
23-
</div>
2426
</aside>
2527
);
2628
}

components/SocialSharingFooter.tsx

-29
This file was deleted.

public/logos/LAP-Logo-Color.png

18.2 KB
Loading

0 commit comments

Comments
 (0)