abstracted styles and Author from ArticleCardSizes
This commit is contained in:
@@ -1,84 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Typography } from '@mui/material';
|
import { Typography } from '@mui/material';
|
||||||
import Box from "@mui/material/Box";
|
import { Author } from "../Author";
|
||||||
import AvatarGroup from "@mui/material/AvatarGroup";
|
|
||||||
import Avatar from "@mui/material/Avatar";
|
|
||||||
import { styled } from "@mui/material/styles";
|
|
||||||
import Card from "@mui/material/Card";
|
|
||||||
import CardContent from "@mui/material/CardContent";
|
|
||||||
import { ArticleCardProps } from "../../types/props";
|
import { ArticleCardProps } from "../../types/props";
|
||||||
|
import { StyledCard, StyledCardContent, StyledTypography } from "../../types/styles";
|
||||||
|
|
||||||
|
|
||||||
const StyledCard = styled(Card)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
padding: 0,
|
|
||||||
height: '100%',
|
|
||||||
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
||||||
'&:hover': {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
cursor: 'pointer',
|
|
||||||
},
|
|
||||||
'&:focus-visible': {
|
|
||||||
outline: '3px solid',
|
|
||||||
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
|
||||||
outlineOffset: '2px',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledCardContent = styled(CardContent)({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: 4,
|
|
||||||
padding: 16,
|
|
||||||
flexGrow: 1,
|
|
||||||
'&:last-child': {
|
|
||||||
paddingBottom: 16,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledTypography = styled(Typography)({
|
|
||||||
display: '-webkit-box',
|
|
||||||
WebkitBoxOrient: 'vertical',
|
|
||||||
WebkitLineClamp: 2,
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 2,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{ display: 'flex', flexDirection: 'row', gap: 1, alignItems: 'center' }}
|
|
||||||
>
|
|
||||||
<AvatarGroup max={3}>
|
|
||||||
{authors.map((author, index) => (
|
|
||||||
<Avatar
|
|
||||||
key={index}
|
|
||||||
alt={author.name}
|
|
||||||
src={author.avatar}
|
|
||||||
sx={{ width: 24, height: 24 }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</AvatarGroup>
|
|
||||||
<Typography variant="caption">
|
|
||||||
{authors.map((author) => author.name).join(', ')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="caption">July 14, 2021</Typography>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ArticleCardSize2({
|
export default function ArticleCardSize2({
|
||||||
article,
|
article,
|
||||||
index,
|
index,
|
||||||
|
|||||||
@@ -1,84 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CardMedia, Typography } from '@mui/material';
|
import { CardMedia, Typography } from '@mui/material';
|
||||||
import Box from "@mui/material/Box";
|
import { Author } from "../Author";
|
||||||
import AvatarGroup from "@mui/material/AvatarGroup";
|
|
||||||
import Avatar from "@mui/material/Avatar";
|
|
||||||
import { styled } from "@mui/material/styles";
|
|
||||||
import Card from "@mui/material/Card";
|
|
||||||
import CardContent from "@mui/material/CardContent";
|
|
||||||
import { ArticleCardProps } from "../../types/props";
|
import { ArticleCardProps } from "../../types/props";
|
||||||
|
import { StyledCard, StyledCardContent, StyledTypography } from "../../types/styles";
|
||||||
|
|
||||||
|
|
||||||
const StyledCard = styled(Card)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
padding: 0,
|
|
||||||
height: '100%',
|
|
||||||
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
||||||
'&:hover': {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
cursor: 'pointer',
|
|
||||||
},
|
|
||||||
'&:focus-visible': {
|
|
||||||
outline: '3px solid',
|
|
||||||
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
|
||||||
outlineOffset: '2px',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledCardContent = styled(CardContent)({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: 4,
|
|
||||||
padding: 16,
|
|
||||||
flexGrow: 1,
|
|
||||||
'&:last-child': {
|
|
||||||
paddingBottom: 16,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledTypography = styled(Typography)({
|
|
||||||
display: '-webkit-box',
|
|
||||||
WebkitBoxOrient: 'vertical',
|
|
||||||
WebkitLineClamp: 2,
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 2,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{ display: 'flex', flexDirection: 'row', gap: 1, alignItems: 'center' }}
|
|
||||||
>
|
|
||||||
<AvatarGroup max={3}>
|
|
||||||
{authors.map((author, index) => (
|
|
||||||
<Avatar
|
|
||||||
key={index}
|
|
||||||
alt={author.name}
|
|
||||||
src={author.avatar}
|
|
||||||
sx={{ width: 24, height: 24 }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</AvatarGroup>
|
|
||||||
<Typography variant="caption">
|
|
||||||
{authors.map((author) => author.name).join(', ')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="caption">July 14, 2021</Typography>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ArticleCardSize4({
|
export default function ArticleCardSize4({
|
||||||
article,
|
article,
|
||||||
index,
|
index,
|
||||||
|
|||||||
@@ -1,84 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CardMedia, Typography } from '@mui/material';
|
import { CardMedia, Typography } from '@mui/material';
|
||||||
import Box from "@mui/material/Box";
|
import { Author } from "../Author";
|
||||||
import AvatarGroup from "@mui/material/AvatarGroup";
|
|
||||||
import Avatar from "@mui/material/Avatar";
|
|
||||||
import { styled } from "@mui/material/styles";
|
|
||||||
import Card from "@mui/material/Card";
|
|
||||||
import CardContent from "@mui/material/CardContent";
|
|
||||||
import { ArticleCardProps } from "../../types/props";
|
import { ArticleCardProps } from "../../types/props";
|
||||||
|
import { StyledCard, StyledCardContent, StyledTypography } from "../../types/styles";
|
||||||
|
|
||||||
|
|
||||||
const StyledCard = styled(Card)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
padding: 0,
|
|
||||||
height: '100%',
|
|
||||||
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
||||||
'&:hover': {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
cursor: 'pointer',
|
|
||||||
},
|
|
||||||
'&:focus-visible': {
|
|
||||||
outline: '3px solid',
|
|
||||||
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
|
||||||
outlineOffset: '2px',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledCardContent = styled(CardContent)({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: 4,
|
|
||||||
padding: 16,
|
|
||||||
flexGrow: 1,
|
|
||||||
'&:last-child': {
|
|
||||||
paddingBottom: 16,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledTypography = styled(Typography)({
|
|
||||||
display: '-webkit-box',
|
|
||||||
WebkitBoxOrient: 'vertical',
|
|
||||||
WebkitLineClamp: 2,
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 2,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{ display: 'flex', flexDirection: 'row', gap: 1, alignItems: 'center' }}
|
|
||||||
>
|
|
||||||
<AvatarGroup max={3}>
|
|
||||||
{authors.map((author, index) => (
|
|
||||||
<Avatar
|
|
||||||
key={index}
|
|
||||||
alt={author.name}
|
|
||||||
src={author.avatar}
|
|
||||||
sx={{ width: 24, height: 24 }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</AvatarGroup>
|
|
||||||
<Typography variant="caption">
|
|
||||||
{authors.map((author) => author.name).join(', ')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="caption">July 14, 2021</Typography>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ArticleCardSize6({
|
export default function ArticleCardSize6({
|
||||||
article,
|
article,
|
||||||
index,
|
index,
|
||||||
|
|||||||
39
src/blog/components/Author.tsx
Normal file
39
src/blog/components/Author.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import AvatarGroup from "@mui/material/AvatarGroup";
|
||||||
|
import Avatar from "@mui/material/Avatar";
|
||||||
|
import {Typography} from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 2,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
padding: '16px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{ display: 'flex', flexDirection: 'row', gap: 1, alignItems: 'center' }}
|
||||||
|
>
|
||||||
|
<AvatarGroup max={3}>
|
||||||
|
{authors.map((author, index) => (
|
||||||
|
<Avatar
|
||||||
|
key={index}
|
||||||
|
alt={author.name}
|
||||||
|
src={author.avatar}
|
||||||
|
sx={{ width: 24, height: 24 }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</AvatarGroup>
|
||||||
|
<Typography variant="caption">
|
||||||
|
{authors.map((author) => author.name).join(', ')}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Typography variant="caption">July 14, 2021</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
40
src/blog/types/styles.ts
Normal file
40
src/blog/types/styles.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import {styled} from "@mui/material/styles";
|
||||||
|
import Card from "@mui/material/Card";
|
||||||
|
import CardContent from "@mui/material/CardContent";
|
||||||
|
import {Typography} from "@mui/material";
|
||||||
|
|
||||||
|
export const StyledCard = styled(Card)(({ theme }) => ({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
padding: 0,
|
||||||
|
height: '100%',
|
||||||
|
backgroundColor: (theme.vars || theme).palette.background.paper,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
cursor: 'pointer',
|
||||||
|
},
|
||||||
|
'&:focus-visible': {
|
||||||
|
outline: '3px solid',
|
||||||
|
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
||||||
|
outlineOffset: '2px',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const StyledCardContent = styled(CardContent)({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: 4,
|
||||||
|
padding: 16,
|
||||||
|
flexGrow: 1,
|
||||||
|
'&:last-child': {
|
||||||
|
paddingBottom: 16,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const StyledTypography = styled(Typography)({
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user