Compare commits
5 Commits
eedb9a24f3
...
0.0.9
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f442c369b | |||
| 6b8d351fed | |||
| fd5093a1f8 | |||
| d3acf05b08 | |||
| bc6bfef6ea |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aetoskia-blog-app",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import CssBaseline from '@mui/material/CssBaseline';
|
||||
import Container from '@mui/material/Container';
|
||||
import Box from '@mui/material/Box';
|
||||
import AppTheme from '../shared-theme/AppTheme';
|
||||
import MainContent from './components/MainContent';
|
||||
import Article from './components/Article';
|
||||
import Latest from './components/Latest';
|
||||
import Footer from './components/Footer';
|
||||
import { useArticles } from './providers/Article'; // ✅ custom hook for global articles
|
||||
import { useArticles } from './providers/Article';
|
||||
|
||||
export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
const { articles, loading, error } = useArticles(); // ✅ Hook must be inside component
|
||||
const { articles, loading, error } = useArticles();
|
||||
const [selectedArticle, setSelectedArticle] = React.useState<number | null>(null);
|
||||
|
||||
const handleSelectArticle = (index: number) => {
|
||||
@@ -26,7 +27,12 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
<Container
|
||||
maxWidth="lg"
|
||||
component="main"
|
||||
sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
height: '100vh',
|
||||
}}
|
||||
>
|
||||
Loading articles...
|
||||
</Container>
|
||||
@@ -41,7 +47,12 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
<Container
|
||||
maxWidth="lg"
|
||||
component="main"
|
||||
sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
height: '100vh',
|
||||
}}
|
||||
>
|
||||
Failed to load articles: {error}
|
||||
</Container>
|
||||
@@ -53,28 +64,61 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
<AppTheme {...props}>
|
||||
<CssBaseline enableColorScheme />
|
||||
|
||||
<Container
|
||||
maxWidth="lg"
|
||||
component="main"
|
||||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
minHeight: '100vh',
|
||||
}}
|
||||
>
|
||||
{selectedArticle === null ? (
|
||||
<>
|
||||
<MainContent articles={articles} onSelectArticle={handleSelectArticle} />
|
||||
<Latest
|
||||
articles={articles}
|
||||
onSelectArticle={handleSelectArticle}
|
||||
onLoadMore={async (offset, limit) => {
|
||||
// Optional: fetch more from API (if you want true pagination)
|
||||
// await fetchMoreArticles(offset, limit);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<Article article={articles[selectedArticle]} onBack={handleBack} />
|
||||
<Container
|
||||
maxWidth="lg"
|
||||
component="main"
|
||||
sx={{
|
||||
flex: '1 0 auto',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
my: 4,
|
||||
gap: 4,
|
||||
pb: selectedArticle === null ? 24 : 0, // space for fixed footer on home
|
||||
}}
|
||||
>
|
||||
{selectedArticle === null ? (
|
||||
<>
|
||||
<MainContent
|
||||
articles={articles}
|
||||
onSelectArticle={handleSelectArticle}
|
||||
/>
|
||||
<Latest
|
||||
articles={articles}
|
||||
onSelectArticle={handleSelectArticle}
|
||||
onLoadMore={async (offset, limit) => {
|
||||
// Optional pagination call
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<Article article={articles[selectedArticle]} onBack={handleBack} />
|
||||
)}
|
||||
</Container>
|
||||
|
||||
{selectedArticle === null && (
|
||||
<Box
|
||||
component="footer"
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
zIndex: 1000,
|
||||
bgcolor: 'background.paper',
|
||||
boxShadow: '0 -2px 10px rgba(0,0,0,0.08)',
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</Box>
|
||||
)}
|
||||
</Container>
|
||||
<Footer />
|
||||
</Box>
|
||||
</AppTheme>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
import * as React from 'react';
|
||||
import Box from '@mui/material/Box';
|
||||
import Button from '@mui/material/Button';
|
||||
import Container from '@mui/material/Container';
|
||||
import Divider from '@mui/material/Divider';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import InputLabel from '@mui/material/InputLabel';
|
||||
import Link from '@mui/material/Link';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import TextField from '@mui/material/TextField';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import GitHubIcon from '@mui/icons-material/GitHub';
|
||||
import LinkedInIcon from '@mui/icons-material/LinkedIn';
|
||||
import TwitterIcon from '@mui/icons-material/X';
|
||||
|
||||
function Copyright() {
|
||||
return (
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary', mt: 1 }}>
|
||||
{'Copyright © '}
|
||||
<Link color="text.secondary" href="https://mui.com/">
|
||||
Sitemark
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
|
||||
<Link color="text.secondary" href="https://www.aetoskia.com/">
|
||||
{'Copyright © Aetoskia Internal Infrastructure — All rights reserved.'}
|
||||
</Link>
|
||||
|
||||
{new Date().getFullYear()}
|
||||
@@ -29,197 +19,17 @@ function Copyright() {
|
||||
export default function Footer() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Divider />
|
||||
<Container
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: { xs: 4, sm: 8 },
|
||||
py: { xs: 8, sm: 10 },
|
||||
gap: { xs: 2, sm: 4 },
|
||||
py: { xs: 2, sm: 4 },
|
||||
textAlign: { sm: 'center', md: 'left' },
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: { xs: 'column', sm: 'row' },
|
||||
width: '100%',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 4,
|
||||
minWidth: { xs: '100%', sm: '60%' },
|
||||
}}
|
||||
>
|
||||
<Box sx={{ width: { xs: '100%', sm: '60%' } }}>
|
||||
<Typography
|
||||
variant="body2"
|
||||
gutterBottom
|
||||
sx={{ fontWeight: 600, mt: 2 }}
|
||||
>
|
||||
Join the newsletter
|
||||
</Typography>
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 2 }}>
|
||||
Subscribe for weekly updates. No spams ever!
|
||||
</Typography>
|
||||
<InputLabel htmlFor="email-newsletter">Email</InputLabel>
|
||||
<Stack direction="row" spacing={1} useFlexGap>
|
||||
<TextField
|
||||
id="email-newsletter"
|
||||
hiddenLabel
|
||||
size="small"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
aria-label="Enter your email address"
|
||||
placeholder="Your email address"
|
||||
slotProps={{
|
||||
htmlInput: {
|
||||
autoComplete: 'off',
|
||||
'aria-label': 'Enter your email address',
|
||||
},
|
||||
}}
|
||||
sx={{ width: '250px' }}
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
sx={{ flexShrink: 0 }}
|
||||
>
|
||||
Subscribe
|
||||
</Button>
|
||||
</Stack>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: { xs: 'none', sm: 'flex' },
|
||||
flexDirection: 'column',
|
||||
gap: 1,
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ fontWeight: 'medium' }}>
|
||||
Product
|
||||
</Typography>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Features
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Testimonials
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Highlights
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Pricing
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
FAQs
|
||||
</Link>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: { xs: 'none', sm: 'flex' },
|
||||
flexDirection: 'column',
|
||||
gap: 1,
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ fontWeight: 'medium' }}>
|
||||
Company
|
||||
</Typography>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
About us
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Careers
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Press
|
||||
</Link>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: { xs: 'none', sm: 'flex' },
|
||||
flexDirection: 'column',
|
||||
gap: 1,
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ fontWeight: 'medium' }}>
|
||||
Legal
|
||||
</Typography>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Terms
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Privacy
|
||||
</Link>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Contact
|
||||
</Link>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
pt: { xs: 4, sm: 8 },
|
||||
width: '100%',
|
||||
borderTop: '1px solid',
|
||||
borderColor: 'divider',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Privacy Policy
|
||||
</Link>
|
||||
<Typography sx={{ display: 'inline', mx: 0.5, opacity: 0.5 }}>
|
||||
•
|
||||
</Typography>
|
||||
<Link color="text.secondary" variant="body2" href="#">
|
||||
Terms of Service
|
||||
</Link>
|
||||
<Copyright />
|
||||
</div>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
useFlexGap
|
||||
sx={{ justifyContent: 'left', color: 'text.secondary' }}
|
||||
>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
size="small"
|
||||
href="https://github.com/mui"
|
||||
aria-label="GitHub"
|
||||
sx={{ alignSelf: 'center' }}
|
||||
>
|
||||
<GitHubIcon />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
size="small"
|
||||
href="https://x.com/MaterialUI"
|
||||
aria-label="X"
|
||||
sx={{ alignSelf: 'center' }}
|
||||
>
|
||||
<TwitterIcon />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
size="small"
|
||||
href="https://www.linkedin.com/company/mui/"
|
||||
aria-label="LinkedIn"
|
||||
sx={{ alignSelf: 'center' }}
|
||||
>
|
||||
<LinkedInIcon />
|
||||
</IconButton>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Copyright />
|
||||
</Container>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
@@ -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,42 +155,58 @@ 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 }}>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-between',
|
||||
gap: 1,
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<Typography gutterBottom variant="caption" component="div">
|
||||
{article.tag}
|
||||
</Typography>
|
||||
|
||||
<TitleTypography
|
||||
gutterBottom
|
||||
variant="h6"
|
||||
tabIndex={0}
|
||||
onClick={() => onSelectArticle?.(index)}
|
||||
<Fade in timeout={animating ? 700 : 0}>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'space-between',
|
||||
gap: 1,
|
||||
height: '100%',
|
||||
transition: 'transform 0.3s ease',
|
||||
'&:hover': { transform: 'translateY(-3px)' },
|
||||
}}
|
||||
>
|
||||
{article.title}
|
||||
<NavigateNextRoundedIcon className="arrow" sx={{ fontSize: '1rem' }} />
|
||||
</TitleTypography>
|
||||
<Typography gutterBottom variant="caption" component="div">
|
||||
{article.tag}
|
||||
</Typography>
|
||||
|
||||
<StyledTypography variant="body2" color="text.secondary" gutterBottom>
|
||||
{article.description}
|
||||
</StyledTypography>
|
||||
<TitleTypography
|
||||
gutterBottom
|
||||
variant="h6"
|
||||
tabIndex={0}
|
||||
onClick={() => onSelectArticle?.(index)}
|
||||
>
|
||||
{article.title}
|
||||
<NavigateNextRoundedIcon className="arrow" sx={{ fontSize: '1rem' }} />
|
||||
</TitleTypography>
|
||||
|
||||
<Author authors={article.authors} />
|
||||
</Box>
|
||||
<StyledTypography variant="body2" color="text.secondary" gutterBottom>
|
||||
{article.description}
|
||||
</StyledTypography>
|
||||
|
||||
<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>
|
||||
);
|
||||
|
||||
@@ -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',
|
||||
@@ -138,7 +137,6 @@ export default function MainContent({
|
||||
<Typography variant="h1" gutterBottom>
|
||||
Blog
|
||||
</Typography>
|
||||
<Typography>Stay in the loop with the latest about our products</Typography>
|
||||
</div>
|
||||
<Box
|
||||
sx={{
|
||||
|
||||
Reference in New Issue
Block a user