diff --git a/src/blog/components/ArticleCards/ArticleCardSize12.tsx b/src/blog/components/ArticleCards/ArticleCardSize12.tsx new file mode 100644 index 0000000..6815aae --- /dev/null +++ b/src/blog/components/ArticleCards/ArticleCardSize12.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { CardMedia, Typography } from '@mui/material'; +import { ArticleMeta } from "../ArticleMeta"; +import { ArticleCardProps } from "../../types/props"; +import { StyledCard, StyledCardContent, StyledTypography } from "../../types/styles"; + + +export default function ArticleCardSize12({ + article, + index, + focusedCardIndex, + onSelectArticle, + onFocus, + onBlur, +}: ArticleCardProps) { + return ( + onSelectArticle(index)} + onFocus={() => onFocus(index)} + onBlur={onBlur} + tabIndex={0} + className={focusedCardIndex === index ? 'Mui-focused' : ''} + > + + + + {article.tag} + + + {article.title} + + + {article.description} + + + + + ); +}; diff --git a/src/blog/components/ArticleCards/ArticleCardsGrid.tsx b/src/blog/components/ArticleCards/ArticleCardsGrid.tsx index fcea26f..83d501c 100644 --- a/src/blog/components/ArticleCards/ArticleCardsGrid.tsx +++ b/src/blog/components/ArticleCards/ArticleCardsGrid.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Grid, Box } from '@mui/material'; +import ArticleCardSize12 from './ArticleCardSize12'; import ArticleCardSize6 from './ArticleCardSize6'; import ArticleCardSize4 from './ArticleCardSize4'; import ArticleCardSize2 from './ArticleCardSize2'; @@ -10,6 +11,7 @@ export default function ArticleCardsGrid({ articles, onSelectArticle, xs = 12, + md12 = 12, md6 = 6, md4 = 4, nested = 2, @@ -30,8 +32,9 @@ export default function ArticleCardsGrid({ setFocusedCardIndex(null); }; - const renderCard = (article: ArticleModel, index: number, type: '6' | '4' | '2' = '6') => { + const renderCard = (article: ArticleModel, index: number, type: '12' | '6' | '4' | '2' = '12') => { const CardComponent = + type === '12' ? ArticleCardSize12 : type === '6' ? ArticleCardSize6 : type === '4' ? ArticleCardSize4 : ArticleCardSize2; @@ -51,6 +54,17 @@ export default function ArticleCardsGrid({ return ( + {/* ---- 1 article: 12 ---- */} + {count === 1 && ( + <> + {visibleArticles.map((a, i) => ( + + {renderCard(a, i, '12')} + + ))} + + )} + {/* ---- 2 articles: 6 | 6 ---- */} {count === 2 && ( <> diff --git a/src/blog/types/props.ts b/src/blog/types/props.ts index 506c5d5..8fe0992 100644 --- a/src/blog/types/props.ts +++ b/src/blog/types/props.ts @@ -34,6 +34,7 @@ export interface ArticleGridProps { articles: ArticleModel[]; onSelectArticle: (index: number) => void; xs?: number; // default 12 for mobile full-width + md12?: number, // default 12 (full-width) md6?: number; // default 6 (half-width) md4?: number; // default 4 (third-width) nested?: 1 | 2; // number of stacked cards in a nested column