//App.js
import React from 'react';
import { FaPlay, FaPause, FaPodcast, FaClock } from 'react-icons/fa';
// Sample podcast data
const podcasts = [
{
title: "Tech Talk",
description: "Latest discussions in technology and innovation.",
cover: "https://via.placeholder.com/150",
episodes: [
{
title: "Episode 1: The Rise of AI",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3",
duration: "30:00",
description: "Exploring the impact of AI on society."
},
{
title: "Episode 2: Blockchain Explained",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3",
duration: "45:00",
description: "Understanding blockchain technology."
},
{
title: "Episode 3: Future of Work",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3",
duration: "50:00",
description: "How technology is shaping the future workplace."
},
{
title: "Episode 4: Cybersecurity Trends",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-4.mp3",
duration: "40:00",
description: "Navigating the world of cybersecurity."
},
{
title: "Episode 5: The Future of Blockchain",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-5.mp3",
duration: "30:00",
description: "Discussing future prospects of blockchain technology."
},
{
title: "Episode 6: AI in Healthcare",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-6.mp3",
duration: "55:00",
description: "Impact of AI on healthcare solutions."
},
{
title: "Episode 7: Data Science Explained",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3",
duration: "40:00",
description: "Basics of data science for beginners."
},
{
title: "Episode 8: The Rise of IoT",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3",
duration: "45:00",
description: "Understanding the Internet of Things."
},
{
title: "Episode 9: Cloud Computing Basics",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3",
duration: "50:00",
description: "Introduction to cloud computing."
},
{
title: "Episode 10: Tech for Good",
audioUrl: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-4.mp3",
duration: "35:00",
description: "Using technology to solve social issues."
},
],
},
];
const trendingPodcasts = Array.from({ length: 10 }, (_, idx) => ({
title: `Trending Podcast ${idx + 1}`,
description: `This is the description for trending podcast ${idx + 1}.`,
cover: "https://via.placeholder.com/150",
}));
const recentPodcasts = Array.from({ length: 10 }, (_, idx) => ({
title: `Recent Podcast ${idx + 1}`,
description: `This is the description for recent podcast ${idx + 1}.`,
cover: "https://via.placeholder.com/150",
}));
const favouritePodcasts = Array.from({ length: 10 }, (_, idx) => ({
title: `Favourite Podcast ${idx + 1}`,
description: `This is the description for favourite podcast ${idx + 1}.`,
cover: "https://via.placeholder.com/150",
}));
// Main App component
const App = () => {
const [playing, setPlaying] = React.useState(null);
const audioRef = React.useRef(null);
const handlePlay = (episode) => {
if (playing === episode) {
audioRef.current.pause();
setPlaying(null);
} else {
audioRef.current.src = episode.audioUrl;
audioRef.current.play();
setPlaying(episode);
}
};
return (
<div className="bg-gray-900 text-white
min-h-screen flex flex-col p-6 lg:p-10">
<header className="mb-8 flex flex-col items-center">
<FaPodcast className="text-green-500 text-6xl" />
<h1 className="text-4xl font-bold
text-center mt-2">
Podcast App
</h1>
</header>
<main className="flex-1 space-y-10">
{/* Episodes List */}
<section>
<h2 className="text-3xl font-bold mb-5">
Episodes List
</h2>
<div className="grid grid-cols-1
sm:grid-cols-2 md:grid-cols-3
lg:grid-cols-4 gap-6">
{podcasts[0].episodes.map((episode, idx) => (
<div key={idx} className="bg-gray-800 p-4
rounded-lg shadow-lg">
<h3 className="font-semibold">{episode.title}</h3>
<p className="text-gray-500">{episode.description}</p>
<div className="flex justify-between items-center mt-3">
<span className="text-gray-400">
<FaClock className="inline-block mr-1" />
{episode.duration}
</span>
<button className="text-green-500
hover:text-green-400"
onClick={() => handlePlay(episode)}>
{playing === episode ? <FaPause /> : <FaPlay />}
</button>
</div>
</div>
))}
</div>
</section>
{/* Trending Podcasts */}
<section>
<h2 className="text-3xl font-bold mb-5">Trending Podcasts</h2>
<div className="grid grid-cols-2 sm:grid-cols-3
md:grid-cols-4 lg:grid-cols-5 gap-6">
{trendingPodcasts.map((podcast, index) => (
<div key={index} className="bg-gray-800 p-5
rounded-lg shadow-lg
hover:shadow-xl transition">
<img src={podcast.cover} alt={podcast.title} className="w-full h-40
object-cover
rounded-lg mb-4" />
<h3 className="text-2xl font-semibold">{podcast.title}</h3>
<p className="text-gray-400">{podcast.description}</p>
</div>
))}
</div>
</section>
{/* Recent Podcasts */}
<section>
<h2 className="text-3xl font-bold mb-5">Recent Podcasts</h2>
<div className="grid grid-cols-2 sm:grid-cols-3
md:grid-cols-4 lg:grid-cols-5 gap-6">
{recentPodcasts.map((podcast, index) => (
<div key={index} className="bg-gray-800 p-5
rounded-lg shadow-lg
hover:shadow-xl transition">
<img src={podcast.cover} alt={podcast.title} className="w-full h-40
object-cover
rounded-lg mb-4" />
<h3 className="text-2xl font-semibold">{podcast.title}</h3>
<p className="text-gray-400">{podcast.description}</p>
</div>
))}
</div>
</section>
{/* Favourite Podcasts */}
<section>
<h2 className="text-3xl font-bold mb-5">Favourite Podcasts</h2>
<div className="grid grid-cols-2 sm:grid-cols-3
md:grid-cols-4 lg:grid-cols-5 gap-6">
{favouritePodcasts.map((podcast, index) => (
<div key={index} className="bg-gray-800 p-5
rounded-lg shadow-lg
hover:shadow-xl transition">
<img src={podcast.cover} alt={podcast.title} className="w-full h-40
object-cover
rounded-lg mb-4" />
<h3 className="text-2xl font-semibold">{podcast.title}</h3>
<p className="text-gray-400">{podcast.description}</p>
</div>
))}
</div>
</section>
</main>
<audio ref={audioRef} />
</div>
);
};
export default App;