Skip to content

Commit 7a3c38f

Browse files
authored
News UI polish, load-more opacity fix, and join dev arrow alignment (#529)
* news UI,load-more opacity,join dev arrow alignment fix * prevent unexpected auto-scroll to top
1 parent c413bbd commit 7a3c38f

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/components/DeveloperLinks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const DeveloperLinks = () => {
6767

6868
{/* Arrow with enhanced animation */}
6969
<div className="relative z-10 flex items-center justify-center w-8 h-8 rounded-full bg-red-100 group-hover:bg-red-200 transition-colors ml-4 flex-shrink-0">
70-
<span className="text-gray-600 group-hover:text-red-700 transform group-hover:translate-x-1 transition-all">
70+
<span className="-mt-1 text-gray-600 group-hover:text-red-700 transform group-hover:translate-x-1 transition-all">
7171
7272
</span>
7373
</div>

src/pages/News/NewsPage.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useMemo } from 'react';
1+
import React, { useState, useEffect, useMemo, useLayoutEffect } from 'react';
22
import ShareModal from '@/components/ShareModal';
33
import { useNavigate, useParams, useLocation } from 'react-router-dom';
44
import { getAllPosts, groupPostsByCategory, Post } from '@/utils/posts-utils';
@@ -49,6 +49,18 @@ const NewsPage: React.FC = () => {
4949
return params.get('q') || '';
5050
});
5151

52+
useLayoutEffect(() => {
53+
if (!isLoading) {
54+
const savedY = Number(sessionStorage.getItem('newsScrollY') || 0);
55+
if (savedY > 0) {
56+
requestAnimationFrame(() => {
57+
window.scrollTo({ top: savedY, behavior: 'auto' });
58+
});
59+
}
60+
sessionStorage.removeItem('newsScrollY');
61+
}
62+
}, [isLoading, activeCategory, searchTerm]);
63+
5264
useEffect(() => {
5365
async function load() {
5466
setIsLoading(true);
@@ -127,7 +139,10 @@ const NewsPage: React.FC = () => {
127139

128140
const hasMore = filteredPosts.length > displayCount;
129141

130-
const handleCategoryClick = (cat: string) => setActiveCategory(cat);
142+
const handleCategoryClick = (cat: string) => {
143+
sessionStorage.setItem('newsScrollY', String(window.scrollY));
144+
setActiveCategory(cat);
145+
};
131146

132147
const handleShowMore = () => {
133148
const total = filteredPosts.length;
@@ -260,7 +275,7 @@ const NewsPage: React.FC = () => {
260275
className="text-blue-500 mr-4 animate-pulse"
261276
size={32}
262277
/>
263-
<h1 className="text-8xl font-bold font-Caveat text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-green-600">
278+
<h1 className="p-4 text-8xl font-bold font-Caveat text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-green-600">
264279
NEWS
265280
</h1>
266281
<TrendingUp
@@ -296,6 +311,10 @@ const NewsPage: React.FC = () => {
296311
value={searchTerm}
297312
onChange={(e) => {
298313
const value = e.target.value;
314+
sessionStorage.setItem(
315+
'newsScrollY',
316+
String(window.scrollY),
317+
);
299318
setSearchTerm(value);
300319
const catPath =
301320
activeCategory === 'All'
@@ -561,7 +580,7 @@ const NewsPage: React.FC = () => {
561580
Read more
562581
<ArrowRight
563582
size={14}
564-
className="ml-1 group-hover:translate-x-1 transition-transform duration-300"
583+
className="ml-1 mt-1 group-hover:translate-x-1 transition-transform duration-300"
565584
/>
566585
</div>
567586
</div>
@@ -584,7 +603,9 @@ const NewsPage: React.FC = () => {
584603
whileHover="hover"
585604
whileTap="tap"
586605
>
587-
<div className="absolute inset-0 bg-white opacity-0 group-hover:opacity-10 transition-opacity duration-300"></div>
606+
<div className="relative group rounded-xl overflow-hidden">
607+
<div className="absolute inset-0 bg-white opacity-0 group-hover:opacity-10 transition-opacity duration-300 rounded-xl"></div>
608+
</div>
588609
<span className="relative z-10">Load More Articles</span>
589610
<ArrowRight
590611
size={18}

0 commit comments

Comments
 (0)