// src\pages\index.js
import Head from "next/head";
import { Inter } from "@next/font/google";
import Header from "@/components/Header";
import Layout from "@/components/Layout";
import Card from "@/components/Card";
import DetailsCard from "@/components/DetailsCard";
const inter = Inter({
subsets: ["latin"],
weight: ["400", "700"],
preload: true,
});
export default function Home({ cards, details }) {
return (
<>
<Head>
<title>Social Media Dashboard</title>
<meta
name="description"
content="Social Media Dashboard Design with Next.js"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={`${inter.className} m-auto bg-pink-100`}>
<Header />
<Layout>
<div className="grid xl:grid-cols-2 place-content-between
gap-8 sm:grid-cols-2 -mt-10 md:-mt-[120px]
ml-auto mr-auto text-center">
{cards.map(renderCard)}
</div>
<h2 className="dark:text-text-light text-titles-dark
font-bold text-2xl my-6 md:mt-10">
Overview - Today
</h2>
<div className="grid grid-cols-1 sm:grid-cols-2
xl:grid-cols-4 md:flex-row md:justify-between
items-center flex-wrap gap-8 mb-12">
{details.map(renderDetailsCard)}
</div>
</Layout>
</main>
</>
);
}
function renderCard(card, index) {
return (
<Card
key={card.mediaName + index}
icon={card.icon}
mediaName={card.mediaName}
isUp={card.isUp}
userName={card.username}
type={card.type}
followers={card.followers}
recentNotify={card.recentNotify}
arrow={card.arrow}
/>
);
}
function renderDetailsCard(detail, index) {
return (
<DetailsCard
key={detail.mediaName + index}
mediaName={detail.mediaName}
icon={detail.icon}
arrow={detail.arrow}
isUp={detail.isUp}
sectionName={detail.sectionName}
state={detail.state}
percentage={detail.percentage}
/>
);
}
export async function getStaticProps() {
const cards = [
{
icon: "./../assets/facebook-svgrepo-com.svg",
mediaName: "facebook",
username: "Geek",
type: "followers",
followers: 1234,
recentNotify: 12,
arrow: "./../assets/icon-up.svg",
isUp: true,
},
{
icon: "./../assets/twitter-svgrepo-com.svg",
mediaName: "twitter",
username: "Geek",
type: "followers",
followers: 8294,
recentNotify: 99,
arrow: "./../assets/icon-up.svg",
isUp: true,
},
{
icon: "./../assets/instagram-svgrepo-com.svg",
mediaName: "instagram",
username: "realGeek",
type: "followers",
followers: 86000,
recentNotify: 1099,
arrow: "./../assets/icon-up.svg",
isUp: true,
},
{
icon: "./../assets/youtube-svgrepo-com.svg",
mediaName: "youtube",
username: "Geek.",
type: "subscribers",
followers: 5432,
recentNotify: 144,
arrow: "./../assets/icon-down.svg",
isUp: false,
},
// Add more card objects here if needed
];
const details = [
{
mediaName: "facebook-views",
icon: "./../assets/facebook-svgrepo-com.svg",
arrow: "./../assets/icon-up.svg",
isUp: true,
sectionName: "Page Views",
state: 202,
percentage: "3%",
},
{
mediaName: "facebook-likes",
icon: "./../assets/facebook-svgrepo-com.svg",
arrow: "./../assets/icon-down.svg",
isUp: false,
sectionName: "Likes",
state: 40,
percentage: "2%",
},
{
mediaName: "instagram-likes",
icon: "./../assets/instagram-svgrepo-com.svg",
arrow: "./../assets/icon-up.svg",
isUp: true,
sectionName: "Likes",
state: 50101,
percentage: "2257%",
},
{
mediaName: "instagram-views",
icon: "./../assets/instagram-svgrepo-com.svg",
arrow: "./../assets/icon-up.svg",
isUp: true,
sectionName: "Profile Views",
state: 202000,
percentage: "1375%",
},
{
mediaName: "retweets",
icon: "./../assets/twitter-svgrepo-com.svg",
arrow: "./../assets/icon-up.svg",
isUp: true,
sectionName: "Retweets",
state: 513,
percentage: "303%",
},
{
mediaName: "twitter-likes",
icon: "./../assets/twitter-svgrepo-com.svg",
arrow: "./../assets/icon-up.svg",
isUp: true,
sectionName: "Likes",
state: 1013,
percentage: "553%",
},
{
mediaName: "youtube-likes",
icon: "./../assets/youtube-svgrepo-com.svg",
arrow: "./../assets/icon-down.svg",
isUp: false,
sectionName: "Likes",
state: 214,
percentage: "19%",
},
{
mediaName: "youtube-views",
icon: "./../assets/youtube-svgrepo-com.svg",
arrow: "./../assets/icon-down.svg",
isUp: false,
sectionName: "Total Views",
state: 3658,
percentage: "12%",
},
// Add more details objects here if needed
];
return {
props: {
cards,
details,
},
};
}