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", "name": "aetoskia-blog-app",
"version": "0.0.7", "version": "0.0.8",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

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

View File

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

View File

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