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); setSelectedArticle(index);
window.scrollTo({ top: 0, behavior: 'smooth' }); window.scrollTo({ top: 0, behavior: 'smooth' });
}; };
const handleBack = () => setSelectedArticle(null);
const handleShowLogin = () => { const handleShowLogin = () => {
setShowLogin(true); setShowLogin(true);
setShowRegister(false); setShowRegister(false);
@@ -62,6 +59,11 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
const handleHideEditor = () => { const handleHideEditor = () => {
setShowEditor(false); setShowEditor(false);
}; };
const handleArticleViewBack = () => setSelectedArticle(null);
const handleArticleEditorBack = () => {
handleHideEditor()
window.scrollTo({ top: 0, behavior: 'smooth' });
};
// 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(() => {
@@ -95,9 +97,9 @@ 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={handleBack} />; return <ArticleView article={articles[selectedArticle]} onBack={handleArticleViewBack} />;
case 'editor': case 'editor':
return <ArticleEditor author={currentUser} onBack={handleBack} ></ArticleEditor> return <ArticleEditor onBack={handleArticleEditorBack} ></ArticleEditor>
case 'home': case 'home':
default: default:
return ( return (

View File

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

View File

@@ -1,6 +1,4 @@
import {ArticleModel, AuthorModel} from "./models"; import { ArticleModel } from "./models";
import {styled} from "@mui/material/styles";
import Card from "@mui/material/Card";
export interface LatestProps { export interface LatestProps {
articles: ArticleModel[]; articles: ArticleModel[];
@@ -14,9 +12,8 @@ export interface ArticleProps {
} }
export interface ArticleEditorProps { export interface ArticleEditorProps {
article: ArticleModel; article?: ArticleModel;
onBack: () => void; onBack: () => void;
author: AuthorModel;
} }
export interface ArticleMetaProps { export interface ArticleMetaProps {