4 Commits

Author SHA1 Message Date
6b8d351fed bumping up to 0.0.8
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-07 21:49:45 +05:30
fd5093a1f8 smooth scrolling with fade 2025-11-07 21:48:01 +05:30
d3acf05b08 reduced my to 4 from 16 2025-11-07 21:43:27 +05:30
bc6bfef6ea cleanup 2025-11-07 21:43:15 +05:30
4 changed files with 55 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "aetoskia-blog-app",
"version": "0.0.7",
"version": "0.0.8",
"private": true,
"scripts": {
"dev": "vite",

View File

@@ -56,7 +56,7 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
<Container
maxWidth="lg"
component="main"
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
sx={{ display: 'flex', flexDirection: 'column', my: 4, gap: 4 }}
>
{selectedArticle === null ? (
<>

View File

@@ -8,6 +8,7 @@ import { styled } from '@mui/material/styles';
import NavigateNextRoundedIcon from '@mui/icons-material/NavigateNextRounded';
import CircularProgress from '@mui/material/CircularProgress';
import type { Article } from '../providers/Article'; // ✅ import type for correctness
import Fade from '@mui/material/Fade'; // ✅ for smooth appearance
const StyledTypography = styled(Typography)({
@@ -98,12 +99,11 @@ interface LatestProps {
export default function Latest({ articles, onSelectArticle, onLoadMore }: LatestProps) {
const [visibleCount, setVisibleCount] = React.useState(2);
const [loadingMore, setLoadingMore] = React.useState(false);
const [animating, setAnimating] = React.useState(false);
const loaderRef = React.useRef<HTMLDivElement | null>(null);
const displayedArticles = articles.slice(0, visibleCount);
// Intersection Observer ref
const loaderRef = React.useRef<HTMLDivElement | null>(null);
React.useEffect(() => {
if (!loaderRef.current) return;
@@ -114,17 +114,22 @@ export default function Latest({ articles, onSelectArticle, onLoadMore }: Latest
console.log('🟡 Intersection triggered — loading more blogs...');
setLoadingMore(true);
// simulate API load delay
await new Promise((resolve) => setTimeout(resolve, 1000));
if (onLoadMore) {
console.log(`📡 Calling onLoadMore(offset=${visibleCount}, limit=2)`);
await onLoadMore(visibleCount, 2);
}
setAnimating(true);
setVisibleCount((prev) => {
const newCount = prev + 2;
console.log(`✅ Increasing visibleCount from ${prev}${newCount}`);
return newCount;
});
setTimeout(() => setAnimating(false), 600);
setLoadingMore(false);
}
},
@@ -150,6 +155,7 @@ export default function Latest({ articles, onSelectArticle, onLoadMore }: Latest
<Grid container spacing={8} columns={12} sx={{ my: 4 }}>
{displayedArticles.map((article, index) => (
<Grid key={index} size={{ xs: 12, sm: 6 }}>
<Fade in timeout={animating ? 700 : 0}>
<Box
sx={{
display: 'flex',
@@ -157,6 +163,8 @@ export default function Latest({ articles, onSelectArticle, onLoadMore }: Latest
justifyContent: 'space-between',
gap: 1,
height: '100%',
transition: 'transform 0.3s ease',
'&:hover': { transform: 'translateY(-3px)' },
}}
>
<Typography gutterBottom variant="caption" component="div">
@@ -179,13 +187,26 @@ export default function Latest({ articles, onSelectArticle, onLoadMore }: Latest
<Author authors={article.authors} />
</Box>
</Fade>
</Grid>
))}
</Grid>
{/* Infinite scroll loader */}
<Box ref={loaderRef} sx={{ display: 'flex', justifyContent: 'center', py: 3 }}>
{loadingMore && <CircularProgress size={28} />}
<Box
ref={loaderRef}
sx={{
display: 'flex',
justifyContent: 'center',
py: 3,
opacity: loadingMore ? 1 : 0.6,
transition: 'opacity 0.4s ease',
}}
>
{loadingMore ? (
<CircularProgress size={32} thickness={5} />
) : (
<Typography variant="caption">Scroll to load more...</Typography>
)}
</Box>
</Box>
);

View File

@@ -16,7 +16,6 @@ import { styled } from '@mui/material/styles';
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
import RssFeedRoundedIcon from '@mui/icons-material/RssFeedRounded';
import { useArticles } from '../providers/Article';
const StyledCard = styled(Card)(({ theme }) => ({
display: 'flex',