changes for UX of opening and closing editor
This commit is contained in:
@@ -31,9 +31,6 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
setSelectedArticle(index);
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
};
|
||||
|
||||
const handleBack = () => setSelectedArticle(null);
|
||||
|
||||
const handleShowLogin = () => {
|
||||
setShowLogin(true);
|
||||
setShowRegister(false);
|
||||
@@ -62,6 +59,11 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
const handleHideEditor = () => {
|
||||
setShowEditor(false);
|
||||
};
|
||||
const handleArticleViewBack = () => setSelectedArticle(null);
|
||||
const handleArticleEditorBack = () => {
|
||||
handleHideEditor()
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
};
|
||||
|
||||
// derive a single source of truth for view
|
||||
const view: View = React.useMemo(() => {
|
||||
@@ -95,9 +97,9 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
||||
);
|
||||
case 'article':
|
||||
if (selectedArticle == null || !articles[selectedArticle]) return null;
|
||||
return <ArticleView article={articles[selectedArticle]} onBack={handleBack} />;
|
||||
return <ArticleView article={articles[selectedArticle]} onBack={handleArticleViewBack} />;
|
||||
case 'editor':
|
||||
return <ArticleEditor author={currentUser} onBack={handleBack} ></ArticleEditor>
|
||||
return <ArticleEditor onBack={handleArticleEditorBack} ></ArticleEditor>
|
||||
case 'home':
|
||||
default:
|
||||
return (
|
||||
|
||||
@@ -27,7 +27,6 @@ const CoverImage = styled('img')({
|
||||
export default function ArticleView({
|
||||
article,
|
||||
onBack,
|
||||
author,
|
||||
}: ArticleEditorProps) {
|
||||
|
||||
const [title, setTitle] = React.useState(article?.title ?? "");
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {ArticleModel, AuthorModel} from "./models";
|
||||
import {styled} from "@mui/material/styles";
|
||||
import Card from "@mui/material/Card";
|
||||
import { ArticleModel } from "./models";
|
||||
|
||||
export interface LatestProps {
|
||||
articles: ArticleModel[];
|
||||
@@ -14,9 +12,8 @@ export interface ArticleProps {
|
||||
}
|
||||
|
||||
export interface ArticleEditorProps {
|
||||
article: ArticleModel;
|
||||
article?: ArticleModel;
|
||||
onBack: () => void;
|
||||
author: AuthorModel;
|
||||
}
|
||||
|
||||
export interface ArticleMetaProps {
|
||||
|
||||
Reference in New Issue
Block a user