Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have created the News Section #492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"aos": "^2.3.4",
"axios": "^1.5.1",
"clsx": "^2.1.1",
"framer-motion": "^11.3.2",
"framer-motion": "^11.3.21",
"jwt-decode": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
62 changes: 55 additions & 7 deletions src/components/Blog/newss.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import "./newss.css";
import Navbar from '../Navbar';
import Footer from '../Footer';
import image1 from "../../assets/news1.jpg"
import image2 from "../../assets/news2.jpg"
import image3 from "../../assets/news3.jpeg"

import { color, motion, useScroll } from "framer-motion";
const blogPosts = [
{
id: 1,
Expand Down Expand Up @@ -94,27 +94,75 @@ const blogPosts = [
];

const Newss = () => {
const [searchQuery, setSearchQuery] = useState('');
const [filteredPosts, setFilteredPosts] = useState([]);
useEffect(()=>{
setFilteredPosts([...blogPosts])
},[blogPosts])
const handleSearchChange = (event) => {
setSearchQuery(event.target.value);
};

const handleSearch = () => {
const lowercasedQuery = searchQuery.toLowerCase();
const newFilteredPosts = blogPosts.filter(post =>
post.title.toLowerCase().includes(lowercasedQuery) ||
post.author.toLowerCase().includes(lowercasedQuery)
);
setFilteredPosts(newFilteredPosts);
};

const eventVariants = {
hidden: { opacity: 0, y: 40 },
visible: { opacity: 1, y: 0 },
};
return (
<>
<Navbar/>
<div className="BlogpageContainer_main">
<header className="header">
<h1>Trending Food and Health News</h1>
{/* <h1>Trending Food and Health News</h1> */}
<div className="p-4 flex flex-col justify-center items-center gap-y-4 w-[100%]">
<div className="text-5xl font-extrabold text-center">
<span className="bg-clip-text text-transparent bg-gradient-to-r from-black to-yellow-400">
Trending Food and Health News
</span>
</div>
<div className="sm:flex mt-[20px]">
<input
type="text"
placeholder="Your Search..."
className="border-[1px] border-black p-2 outline-none"
value={searchQuery}
onChange={handleSearchChange}
required
/> <button onClick={handleSearch} className=" border-none bg-yellow-400 text-white p-2" >Search</button>
</div>
</div>
</header>
<div className="BlogpageContainer">

<div className="container">
{blogPosts.map(post => (
<div key={post.id} className="card">
{filteredPosts.map(post => (
<motion.div
key={post.id}
initial="hidden"
whileInView="visible"
whileHover={{ scale: 1.06 }}
viewport={{ once: true }}
variants={eventVariants}
transition={{ duration: 0.5, ease: "easeInOut" }}
className="card"
>
<div className="imagecontainer">
<img src={post.image} alt={post.title} className="image" />
<img src={post.image} alt={post.title} className="image" />
</div>
<div className="content1">
<h2>{post.title}</h2>
<p>~{post.author}</p>
<p>{post.date}</p>
</div>
</div>
</motion.div>
))}
</div>
</div>
Expand Down
Loading