Skip to content

Commit

Permalink
event & project : changed styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush4345 committed Feb 27, 2024
1 parent 9cecac0 commit ce77ae3
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/app/blogs/[blogid]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const BlogId = ({ params }) => {
const data = await response.json();
console.log("check", data);
// Find the blog post with the matching id
const matchingBlog = data.items.find(blog => blog?.meta.slug === params.blogid);
const matchingBlog = data.items.find(blog => blog?.blog_slug === params.blogid);
console.log("matchingBlog", data.items[0]);
// Update the state with the matching blog data
setBlogData(matchingBlog);
Expand Down Expand Up @@ -51,7 +51,7 @@ const BlogId = ({ params }) => {
return (
<>

<div className="mt-14 pb-10 min-h-screen flex items-center justify-center">
<div className="mt-20 pb-10 min-h-screen flex items-center justify-center">
<div className="w-full">
{blogData ? (
<div >
Expand Down
2 changes: 1 addition & 1 deletion src/app/blogs/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const BlogList = () => {
authors={blog.blog_authors}
img={blog.blog_img_url}
description={blog.blog_description}
slug={blog.meta.slug}
slug={blog.blog_slug}
date={blog.published_on}
/>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/app/events/[eventid]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BlogId = ({ params }) => {
const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*');
const data = await response.json();
// Find the blog post with the matching id
const matchingBlog = data.items.find(blog => blog?.meta.slug === params.eventid);
const matchingBlog = data.items.find(blog => blog?.event_slug === params.eventid);
// Update the state with the matching blog data
setEventData(matchingBlog);

Expand All @@ -48,7 +48,7 @@ const BlogId = ({ params }) => {
return (
<>

<div className="mt-14 pb-10 min-h-screen flex items-center justify-center">
<div className="mt-20 pb-10 min-h-screen flex items-center justify-center">
<div className="w-full">
{eventData ? (
<div >
Expand Down
14 changes: 11 additions & 3 deletions src/app/events/eventCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import { CiCalendar } from "react-icons/ci";
import { IoLocationOutline } from "react-icons/io5";
import ReactMarkdown from "react-markdown";

const BlogCard = ({ title, img, description, slug, date }) => {
const BlogCard = ({ title, img, description, slug, date, location }) => {
// const truncatedDescription = description.length > 100 ? `${description.slice(0, 100)}...` : description;

let inputDate = date;
let dateObj = new Date(inputDate);
let day = dateObj.getDate();
let month = dateObj.toLocaleString('default', { month: 'short' });
let year = dateObj.getFullYear();

let formattedDate = `${day} ${month} ${year}`;

return (
<Link href={`/events/${slug}`} >
<div className={styles.blogCard}>
Expand All @@ -17,8 +25,8 @@ const BlogCard = ({ title, img, description, slug, date }) => {
</div>
<div className={styles.blogDetails}>
<h2 className={`font-semibold ${styles.head}`}>{title}</h2>
<p className='font-medium text-sm mb-1 flex gap-2 items-center'><CiCalendar /> {" "} <span>{date}</span></p>
<p className='font-medium text-sm mb-1 flex gap-2 items-center'><IoLocationOutline /> {" "} <span>SJA</span></p>
<p className='font-medium text-sm mb-1 flex gap-2 items-center'><CiCalendar /> {" "} <span>{formattedDate}</span></p>
<p className='font-medium text-sm mb-1 flex gap-2 items-center'><IoLocationOutline /> {" "} <span>{location}</span></p>
<p className={styles.para}>{description.slice(0, 150) + "... see more"}</p>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/app/events/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ const EventList = () => {
organizer={blog.event_organizer}
img="https://images.unsplash.com/photo-1549451371-64aa98a6f660?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
description="A fun-filled event to bring out the gamer in you and compete to be the best gamer out there. Register in teams of 5 or individually and showcase your gaming talent! Individual registrants will be teamed up with other individual registrants to form teams of 5."
slug={blog.meta.slug}
slug={blog.event_slug}
date={blog.event_date}
location={blog.event_location}
/>
</>
)
Expand Down
82 changes: 82 additions & 0 deletions src/app/projects/[projectid]/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Import necessary modules
"use client"
import { useEffect, useState } from "react";
import Navbar from "@/components/Navbar/Navbar";
import Footer from "@/components/footer";
import ReactMarkdown from "react-markdown";
import './styleblog.css'
// Import Tailwind CSS classes
import 'tailwindcss/tailwind.css';

// Component definition
const ProjectId = ({ params }) => {
console.log(params.blogid)
// State to store the fetched data
const [projectData, setProjectData] = useState(null);

// Effect to fetch data when the component mounts
useEffect(() => {
const fetchData = async () => {
try {
// Fetch data from the API
const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=projects.ProjectsPage&fields=*');
const data = await response.json();
console.log("check", data);
// Find the blog post with the matching id
const matchingBlog = data.items.find(project => project?.project_slug === params.projectid);
console.log("matchingBlog", data.items[0]);
// Update the state with the matching blog data
setProjectData(matchingBlog);
console.log("blog :", matchingBlog.project_img_url)

} catch (error) {
console.error('Error fetching data:', error);
}
};

// Call the fetchData function
fetchData();
}, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes
console.log(projectData?.project_tags.split(","))

return (
<>

<div className="mt-20 pb-10 min-h-screen flex items-center justify-center">
<div className="w-full">
{projectData ? (
<div >
<section className="w-full bg-[#461461] mb-10">
<div className=" flex flex-col text-white py-6 mx-auto w-4/5 md:max-w-full lg:max-w-screen-md 2xl:max-w-screen-lg lg:pt-16">
<div className="flex flex-wrap gap-2">
{projectData?.project_tags.split(",").map((data, index) => {
return (
<span key={index} className="px-2 py-1 bg-purple-600/40 rounded-full">{data}</span>
)
}
)}
</div>
<div className="text-xl text-white font-bold font-sans mt-4">
{projectData.title}
</div>
<div className="text-xl text-gray-300 font-thin font-sans mt-2">
{projectData.project_description}
</div>
<div className="text-xl text-purple-200/90 font-medium font-sans mt-6 flex justify-between items-center">
<span>{projectData.project_authors}</span>
</div>
</div>
</section>
<ReactMarkdown className="prose mx-auto w-4/5 md:max-w-full lg:max-w-screen-md 2xl:max-w-screen-lg text-black">{projectData.project_body}</ReactMarkdown>
</div>
) : (
<p>Loading...</p>
)}
</div>
</div>
</>
);
};

// Export the component
export default ProjectId;
18 changes: 18 additions & 0 deletions src/app/projects/[projectid]/styleblog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import url('https://fonts.googleapis.com/css2?family=Creepster&family=Crimson+Text:ital,wght@1,700&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Poppins:wght@900&display=swap');

.blogstyle {
font-family: "Montserrat", sans-serif;
font-size: 50px;
font-weight: bold;
font-style: normal;
letter-spacing: 0;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-top: 5.4rem;
}

.blogbody{
font-family: "Montserrat", sans-serif;

}
38 changes: 19 additions & 19 deletions src/components/ProjectCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import Link from 'next/link'

const ProjectCard = ({ project }) => {
return (
<div className="w-full xs:w-[320px] overflow-hidden flex justify-between flex-col h-full mx-auto bg-gray-50 rounded-lg shadow relative hover:bg-gray-100 transition duration-300">
<div className="rounded-t-4">
<img className='w-full object-cover h-52' src={project.project_img_url} alt={project.title} />
</div>
<div className='p-6 pb-0'>
<Link href={`/projects/${project.id}`} className='h-full'>
<h6 className="mb-2 text-md font-semibold text-fuchsia-900">{project.project_sig}</h6>
<h5 className="mb-2 text-2xl font-semibold tracking-tight text-black">{project.title}</h5>
<p className="mb-3 font-normal text-gray-700">({project.project_description.slice(0, 150) + "... see more"})</p>
</Link>

</div>
<a href={project.github_url} className="inline-flex items-center px-3 py-2 mb-3 mx-3 text-sm font-medium text-center text-white bg-teal-600 rounded-lg hover:bg-teal-700 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-github mr-2" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8" />
</svg> Repository URL
</a>
</div>

<Link href={`/projects/${project.project_slug}`}>
<div className="w-full xs:w-[320px] overflow-hidden flex justify-between flex-col h-full mx-auto bg-gray-50 rounded-lg relative hover:bg-gray-100 transition duration-300">
<div className="rounded-t-4">
<img className='w-full object-cover h-52' src={project.project_img_url} alt={project.title} />
</div>
<div className='p-6 pb-0 h-full'>
<div className='h-full'>
<h6 className="mb-2 text-md font-semibold text-fuchsia-900">{project.project_sig}</h6>
<h5 className="mb-2 text-2xl font-semibold tracking-tight text-black">{project.title}</h5>
<p className="mb-3 font-normal text-gray-700">({project.project_description.slice(0, 150) + "... see more"})</p>
</div>

</div>
<a href={project.github_url} className="inline-flex items-center px-3 py-2 mb-3 mx-3 text-sm font-medium text-center text-white bg-teal-600 rounded-lg hover:bg-teal-700 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" className="bi bi-github mr-2" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8" />
</svg> Repository URL
</a>
</div>
</Link>
);
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/ProjectDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReactMarkdown from "react-markdown";

const ProjectDetailsPage = ({ project }) => {
console.log();

return (
<div className="p-4 bg-white rounded-lg w-[80vw] m-auto my-8 py-10 px-10">
<ReactMarkdown style={{width:"100%"}} className='prose'>{project.project_body}</ReactMarkdown>
Expand Down

0 comments on commit ce77ae3

Please sign in to comment.