Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added close button to PostDetail #466

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Admin/custom/PostPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export const PostPreview: FC = () => {
</Stack>
</Grid>
<Grid xs={5}>
{isDetailOpen && <PostDetail caption={formData?.caption ?? ''} details={formData?.details ?? ''} />}
{isDetailOpen && (
<PostDetail
closeDetail={() => openDetail(false)}
caption={formData?.caption ?? ''}
details={formData?.details ?? ''}
/>
)}
</Grid>
</Grid>
)}
Expand Down
10 changes: 8 additions & 2 deletions src/components/Posts/PostDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {Stack, Typography} from '@mui/material'
import {Box, Stack, Typography} from '@mui/material'
import {FC} from 'react'

import {CloseButton} from '../CloseButton/CloseButton'
import {PostMarkdown} from './PostMarkdown'

type PostDetailProps = {
caption: string
details: string
closeDetail: () => void
}

export const PostDetail: FC<PostDetailProps> = ({caption, details}) => {
export const PostDetail: FC<PostDetailProps> = ({caption, details, closeDetail}) => {
return (
<Stack
p={2}
Expand All @@ -17,8 +19,12 @@ export const PostDetail: FC<PostDetailProps> = ({caption, details}) => {
backgroundColor: 'white',
maxHeight: '60vh',
overflow: 'auto',
position: 'relative',
}}
>
<Box position="absolute" top={16} right={16}>
<CloseButton size={30} onClick={closeDetail} invertColors />
</Box>
<Typography variant="postTitle" textTransform="uppercase" fontStyle="italic" mb={4}>
{caption}
</Typography>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Posts/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export const Posts: FC = () => {
</Stack>
</Grid>
<Grid xs={12} sm={6} mt={{xs: 2, sm: 0}}>
<PostDetail caption={posts[activePostDetailIndex].caption} details={posts[activePostDetailIndex].details} />
<PostDetail
closeDetail={() => setActivePostDetailIndex(undefined)}
caption={posts[activePostDetailIndex].caption}
details={posts[activePostDetailIndex].details}
/>
</Grid>
</Grid>
)}
Expand Down
Loading