changes for UX of opening and closing editor

This commit is contained in:
2025-11-15 04:12:24 +05:30
parent 7a28dde7d5
commit 8838ff10f4
3 changed files with 9 additions and 11 deletions

View File

@@ -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 (

View File

@@ -27,7 +27,6 @@ const CoverImage = styled('img')({
export default function ArticleView({
article,
onBack,
author,
}: ArticleEditorProps) {
const [title, setTitle] = React.useState(article?.title ?? "");

View File

@@ -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 {