changes for UX of opening and closing editor from both home and through article view
This commit is contained in:
@@ -53,7 +53,6 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
setShowProfile(false);
|
setShowProfile(false);
|
||||||
};
|
};
|
||||||
const handleShowEditor = () => {
|
const handleShowEditor = () => {
|
||||||
console.log("handleShowEditor")
|
|
||||||
setShowEditor(true);
|
setShowEditor(true);
|
||||||
};
|
};
|
||||||
const handleHideEditor = () => {
|
const handleHideEditor = () => {
|
||||||
@@ -67,7 +66,7 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
|
|
||||||
// derive a single source of truth for view
|
// derive a single source of truth for view
|
||||||
const view: View = React.useMemo(() => {
|
const view: View = React.useMemo(() => {
|
||||||
if (selectedArticle !== null) return 'article';
|
if (selectedArticle !== null && !showEditor) return 'article';
|
||||||
if (showRegister) return 'register';
|
if (showRegister) return 'register';
|
||||||
if (showLogin) return 'login';
|
if (showLogin) return 'login';
|
||||||
if (showProfile) return 'profile';
|
if (showProfile) return 'profile';
|
||||||
@@ -97,9 +96,20 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
);
|
);
|
||||||
case 'article':
|
case 'article':
|
||||||
if (selectedArticle == null || !articles[selectedArticle]) return null;
|
if (selectedArticle == null || !articles[selectedArticle]) return null;
|
||||||
return <ArticleView article={articles[selectedArticle]} onBack={handleArticleViewBack} />;
|
return <ArticleView
|
||||||
|
article={articles[selectedArticle]}
|
||||||
|
onBack={handleArticleViewBack}
|
||||||
|
onEdit={handleShowEditor}
|
||||||
|
/>;
|
||||||
case 'editor':
|
case 'editor':
|
||||||
return <ArticleEditor onBack={handleArticleEditorBack} ></ArticleEditor>
|
if (selectedArticle == null || !articles[selectedArticle])
|
||||||
|
return <ArticleEditor
|
||||||
|
onBack={handleArticleEditorBack}
|
||||||
|
/>
|
||||||
|
return <ArticleEditor
|
||||||
|
article={articles[selectedArticle] || null}
|
||||||
|
onBack={handleArticleEditorBack}
|
||||||
|
/>
|
||||||
case 'home':
|
case 'home':
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { marked } from 'marked';
|
|||||||
import { Box, Typography, Divider, IconButton, Chip } from '@mui/material';
|
import { Box, Typography, Divider, IconButton, Chip } from '@mui/material';
|
||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
||||||
|
import EditRoundedIcon from '@mui/icons-material/EditRounded';
|
||||||
import { ArticleMeta } from "../ArticleMeta";
|
import { ArticleMeta } from "../ArticleMeta";
|
||||||
import { ArticleProps } from '../../types/props';
|
import { ArticleProps } from '../../types/props';
|
||||||
|
|
||||||
@@ -25,7 +26,8 @@ const CoverImage = styled('img')({
|
|||||||
|
|
||||||
export default function ArticleView({
|
export default function ArticleView({
|
||||||
article,
|
article,
|
||||||
onBack
|
onBack,
|
||||||
|
onEdit,
|
||||||
}: ArticleProps) {
|
}: ArticleProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,6 +43,10 @@ export default function ArticleView({
|
|||||||
sx={{ mb: 2, textTransform: 'uppercase', fontWeight: 500 }}
|
sx={{ mb: 2, textTransform: 'uppercase', fontWeight: 500 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<IconButton onClick={onEdit} sx={{ mb: 2 }}>
|
||||||
|
<EditRoundedIcon />
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
<Typography variant="h3" component="h1" gutterBottom fontWeight="bold">
|
<Typography variant="h3" component="h1" gutterBottom fontWeight="bold">
|
||||||
{article.title}
|
{article.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface LatestProps {
|
|||||||
export interface ArticleProps {
|
export interface ArticleProps {
|
||||||
article: ArticleModel;
|
article: ArticleModel;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
|
onEdit: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ArticleEditorProps {
|
export interface ArticleEditorProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user