cleanup
This commit is contained in:
@@ -1,99 +1,19 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Avatar from '@mui/material/Avatar';
|
|
||||||
import AvatarGroup from '@mui/material/AvatarGroup';
|
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Grid from '@mui/material/Grid';
|
import Grid from '@mui/material/Grid';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
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 { LatestProps } from "../types/props";
|
import { LatestProps } from "../types/props";
|
||||||
|
import { StyledTypography, TitleTypography } from "../types/styles";
|
||||||
|
import { ArticleMeta } from "./ArticleMeta";
|
||||||
import Fade from '@mui/material/Fade';
|
import Fade from '@mui/material/Fade';
|
||||||
|
|
||||||
|
export default function Latest({
|
||||||
const StyledTypography = styled(Typography)({
|
articles,
|
||||||
display: '-webkit-box',
|
onSelectArticle,
|
||||||
WebkitBoxOrient: 'vertical',
|
onLoadMore
|
||||||
WebkitLineClamp: 2,
|
}: LatestProps) {
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
});
|
|
||||||
|
|
||||||
const TitleTypography = styled(Typography)(({ theme }) => ({
|
|
||||||
position: 'relative',
|
|
||||||
textDecoration: 'none',
|
|
||||||
'&:hover': { cursor: 'pointer' },
|
|
||||||
'& .arrow': {
|
|
||||||
visibility: 'hidden',
|
|
||||||
position: 'absolute',
|
|
||||||
right: 0,
|
|
||||||
top: '50%',
|
|
||||||
transform: 'translateY(-50%)',
|
|
||||||
},
|
|
||||||
'&:hover .arrow': {
|
|
||||||
visibility: 'visible',
|
|
||||||
opacity: 0.7,
|
|
||||||
},
|
|
||||||
'&:focus-visible': {
|
|
||||||
outline: '3px solid',
|
|
||||||
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
|
||||||
outlineOffset: '3px',
|
|
||||||
borderRadius: '8px',
|
|
||||||
},
|
|
||||||
'&::before': {
|
|
||||||
content: '""',
|
|
||||||
position: 'absolute',
|
|
||||||
width: 0,
|
|
||||||
height: '1px',
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
backgroundColor: (theme.vars || theme).palette.text.primary,
|
|
||||||
opacity: 0.3,
|
|
||||||
transition: 'width 0.3s ease, opacity 0.3s ease',
|
|
||||||
},
|
|
||||||
'&:hover::before': {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 2,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{ display: 'flex', flexDirection: 'row', gap: 1, alignItems: 'center' }}
|
|
||||||
>
|
|
||||||
<AvatarGroup max={3}>
|
|
||||||
{authors.map((author, index) => (
|
|
||||||
<Avatar
|
|
||||||
key={index}
|
|
||||||
alt={author.name}
|
|
||||||
src={(
|
|
||||||
import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
|
|
||||||
"/" +
|
|
||||||
(author.avatar?.replace(/^\/+/, "") || "")
|
|
||||||
)}
|
|
||||||
sx={{ width: 24, height: 24 }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</AvatarGroup>
|
|
||||||
<Typography variant="caption">
|
|
||||||
{authors.map((a) => a.name).join(', ')}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="caption">Recently Updated</Typography>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 [animating, setAnimating] = React.useState(false);
|
||||||
@@ -182,7 +102,7 @@ export default function Latest({ articles, onSelectArticle, onLoadMore }: Latest
|
|||||||
{article.description}
|
{article.description}
|
||||||
</StyledTypography>
|
</StyledTypography>
|
||||||
|
|
||||||
<Author authors={article.authors} />
|
<ArticleMeta article={article} />
|
||||||
</Box>
|
</Box>
|
||||||
</Fade>
|
</Fade>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ import * as React from 'react';
|
|||||||
import { Box, TextField, Button, Typography, IconButton, CircularProgress, Link } from '@mui/material';
|
import { Box, TextField, Button, Typography, IconButton, CircularProgress, Link } from '@mui/material';
|
||||||
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
||||||
import { useAuth } from '../providers/Author';
|
import { useAuth } from '../providers/Author';
|
||||||
|
import { LoginProps } from '../types/props';
|
||||||
|
|
||||||
interface LoginProps {
|
export default function Login({
|
||||||
onBack: () => void;
|
onBack,
|
||||||
onRegister: () => void;
|
onRegister
|
||||||
}
|
}: LoginProps) {
|
||||||
|
|
||||||
export default function Login({ onBack, onRegister }: LoginProps) {
|
|
||||||
const { login, loading, error, currentUser } = useAuth();
|
const { login, loading, error, currentUser } = useAuth();
|
||||||
const [username, setUsername] = React.useState('');
|
const [username, setUsername] = React.useState('');
|
||||||
const [password, setPassword] = React.useState('');
|
const [password, setPassword] = React.useState('');
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
|
|||||||
import RssFeedRoundedIcon from '@mui/icons-material/RssFeedRounded';
|
import RssFeedRoundedIcon from '@mui/icons-material/RssFeedRounded';
|
||||||
|
|
||||||
import { ArticleModel } from "../types/models";
|
import { ArticleModel } from "../types/models";
|
||||||
|
import { MainContentProps } from "../types/props";
|
||||||
import ArticleCardsGrid from "./ArticleCards/ArticleCardsGrid";
|
import ArticleCardsGrid from "./ArticleCards/ArticleCardsGrid";
|
||||||
|
|
||||||
export function Search() {
|
export function Search() {
|
||||||
@@ -36,10 +37,7 @@ export function Search() {
|
|||||||
export default function MainContent({
|
export default function MainContent({
|
||||||
articles,
|
articles,
|
||||||
onSelectArticle,
|
onSelectArticle,
|
||||||
}: {
|
}: MainContentProps) {
|
||||||
articles: ArticleModel[];
|
|
||||||
onSelectArticle: (index: number) => void;
|
|
||||||
}) {
|
|
||||||
|
|
||||||
const [visibleArticles, setVisibleArticles] = React.useState<ArticleModel[]>(articles);
|
const [visibleArticles, setVisibleArticles] = React.useState<ArticleModel[]>(articles);
|
||||||
const [activeTag, setActiveTag] = React.useState<string>('all');
|
const [activeTag, setActiveTag] = React.useState<string>('all');
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
|||||||
import { useAuth } from '../providers/Author';
|
import { useAuth } from '../providers/Author';
|
||||||
import { useUpload } from "../providers/Upload";
|
import { useUpload } from "../providers/Upload";
|
||||||
import ImageUploadField from './ImageUploadField';
|
import ImageUploadField from './ImageUploadField';
|
||||||
|
import { ProfileProps } from '../types/props';
|
||||||
|
|
||||||
interface ProfileProps {
|
export default function Profile({
|
||||||
onBack: () => void;
|
onBack
|
||||||
}
|
}: ProfileProps) {
|
||||||
|
|
||||||
export default function Profile({ onBack }: ProfileProps) {
|
|
||||||
const { currentUser, loading, error, logout, updateProfile } = useAuth();
|
const { currentUser, loading, error, logout, updateProfile } = useAuth();
|
||||||
const { uploadFile } = useUpload();
|
const { uploadFile } = useUpload();
|
||||||
const [formData, setFormData] = React.useState({
|
const [formData, setFormData] = React.useState({
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import * as React from 'react';
|
|||||||
import { Box, TextField, Button, Typography, IconButton, CircularProgress, Alert, } from '@mui/material';
|
import { Box, TextField, Button, Typography, IconButton, CircularProgress, Alert, } from '@mui/material';
|
||||||
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
||||||
import { useAuth } from '../providers/Author';
|
import { useAuth } from '../providers/Author';
|
||||||
|
import { RegisterProps } from '../types/props';
|
||||||
|
|
||||||
interface RegisterProps {
|
export default function Register({
|
||||||
onBack: () => void;
|
onBack
|
||||||
}
|
}: RegisterProps) {
|
||||||
|
|
||||||
export default function Register({ onBack }: RegisterProps) {
|
|
||||||
const { register, loading, error, currentUser } = useAuth();
|
const { register, loading, error, currentUser } = useAuth();
|
||||||
const [username, setUsername] = React.useState('');
|
const [username, setUsername] = React.useState('');
|
||||||
const [password1, setPassword1] = React.useState('');
|
const [password1, setPassword1] = React.useState('');
|
||||||
|
|||||||
@@ -6,13 +6,30 @@ export interface LatestProps {
|
|||||||
onLoadMore?: (offset: number, limit: number) => Promise<void>; // optional async callback
|
onLoadMore?: (offset: number, limit: number) => Promise<void>; // optional async callback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LoginProps {
|
||||||
|
onBack: () => void;
|
||||||
|
onRegister: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MainContentProps {
|
||||||
|
articles: ArticleModel[];
|
||||||
|
onSelectArticle: (index: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProfileProps {
|
||||||
|
onBack: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegisterProps {
|
||||||
|
onBack: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ArticleViewProps {
|
export interface ArticleViewProps {
|
||||||
article: ArticleModel;
|
article: ArticleModel;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
open_editor: () => void;
|
open_editor: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface ArticleEditorProps {
|
export interface ArticleEditorProps {
|
||||||
article?: ArticleModel | null;
|
article?: ArticleModel | null;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
|
|||||||
@@ -38,3 +38,40 @@ export const StyledTypography = styled(Typography)({
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const TitleTypography = styled(Typography)(({ theme }) => ({
|
||||||
|
position: 'relative',
|
||||||
|
textDecoration: 'none',
|
||||||
|
'&:hover': { cursor: 'pointer' },
|
||||||
|
'& .arrow': {
|
||||||
|
visibility: 'hidden',
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: '50%',
|
||||||
|
transform: 'translateY(-50%)',
|
||||||
|
},
|
||||||
|
'&:hover .arrow': {
|
||||||
|
visibility: 'visible',
|
||||||
|
opacity: 0.7,
|
||||||
|
},
|
||||||
|
'&:focus-visible': {
|
||||||
|
outline: '3px solid',
|
||||||
|
outlineColor: 'hsla(210, 98%, 48%, 0.5)',
|
||||||
|
outlineOffset: '3px',
|
||||||
|
borderRadius: '8px',
|
||||||
|
},
|
||||||
|
'&::before': {
|
||||||
|
content: '""',
|
||||||
|
position: 'absolute',
|
||||||
|
width: 0,
|
||||||
|
height: '1px',
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
backgroundColor: (theme.vars || theme).palette.text.primary,
|
||||||
|
opacity: 0.3,
|
||||||
|
transition: 'width 0.3s ease, opacity 0.3s ease',
|
||||||
|
},
|
||||||
|
'&:hover::before': {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user