Skip to content

Commit

Permalink
refactor: remove extra comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hikasap committed Oct 19, 2024
1 parent a49cb80 commit 130a8ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
11 changes: 2 additions & 9 deletions frontend/src/components/news/NewsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const mockNewsData = [
description: "Recent reports indicate that GDP growth forecasts for major economies have been revised upwards.",
rssUrl: "https://example.com/news1",
category: "Global Economy",
publishedAt: "2 hours ago", // Time ago
publishedAt: "2 hours ago",
coverImageUrl: "https://www.thisiscolossal.com/wp-content/uploads/2024/10/jonk-1.jpg",
source: "Economic Times", // Publishing source name
source: "Economic Times",
},
{
id: 2,
Expand Down Expand Up @@ -95,26 +95,21 @@ const NewsPage = () => {
const [newsData, setNewsData] = useState([]);
const [rssNewsData, setRssNewsData] = useState([]);
const all = 'All';
// Separate category states for both sections
const [selectedCategory, setSelectedCategory] = useState(all);
const [selectedRssCategory, setSelectedRssCategory] = useState(all);

useEffect(() => {
// Set mock news data
setNewsData(mockNewsData);
setRssNewsData(mockRssFeedData);
}, []);

// Extract unique categories for mock news and RSS feed news
const newsCategories = [all, ...new Set(mockNewsData.map(news => news.category))];
const rssCategories = [all, ...new Set(mockRssFeedData.map(news => news.category))];

// Filter logic for the first news section
const filteredNews = newsData.filter((news) =>
selectedCategory === all ? true : news.category === selectedCategory
);

// Filter logic for the RSS feed news section
const filteredRssNews = rssNewsData.filter((news) =>
selectedRssCategory === all ? true : news.category === selectedRssCategory
);
Expand All @@ -127,7 +122,6 @@ const NewsPage = () => {
</div>

<div className="news-content">
{/* Filter Buttons for Mock News Section */}
<h3 className="section-title">Mock Economic News Section</h3>
<div className="filter-buttons">
<FilterButtons categories={newsCategories} setSelectedCategory={setSelectedCategory} selectedCategory={selectedCategory} />
Expand All @@ -138,7 +132,6 @@ const NewsPage = () => {
))}
</div>

{/* Filter Buttons for Mock RSS Feed News Section */}
<h3 className="section-title">Mock RSS Feed Economic News Section</h3>
<div className="filter-buttons">
<FilterButtons categories={rssCategories} setSelectedCategory={setSelectedRssCategory} selectedCategory={selectedRssCategory} />
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/styles/News.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@

.card-icon {
width: auto;
width: 25%; /* Allow the icon to take up at most 20% of the card width */
width: 25%;
height: auto;
aspect-ratio: 1 / 1; /* Keep it square */
border-radius: 12px; /* Rounded corners */
overflow: hidden; /* Crop image if it's too large */
margin-left: 10px; /* Space between text and icon */
flex-shrink: 0; /* Prevent shrinking smaller than its natural size */
aspect-ratio: 1 / 1;
border-radius: 12px;
overflow: hidden;
margin-left: 10px;
flex-shrink: 0;
}

.card-icon img {
width: 100%;
height: 100%;
object-fit: cover; /* Ensure the image fits without stretching */
object-fit: cover;
}

0 comments on commit 130a8ce

Please sign in to comment.