-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
21 changed files
with
873 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Box, Divider, Skeleton, Stack, Typography } from '@mui/material'; | ||
import { ReactNode } from 'react'; | ||
import { ChildrenProp, StyleProps } from '~/common'; | ||
|
||
interface ActionableSectionProps extends StyleProps, ChildrenProp { | ||
title?: ReactNode; | ||
action?: ReactNode; | ||
loading?: boolean; | ||
} | ||
|
||
export const ActionableSection = ({ | ||
loading, | ||
title, | ||
action, | ||
children, | ||
...rest | ||
}: ActionableSectionProps) => ( | ||
<Box component="section" {...rest}> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
p: 1, | ||
}} | ||
> | ||
<Typography variant="h3"> | ||
{!loading ? title : <Skeleton width="120px" />} | ||
</Typography> | ||
{action} | ||
</Box> | ||
<Divider /> | ||
<Stack p={2}>{children}</Stack> | ||
</Box> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ActionableSection'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { MoreVert } from '@mui/icons-material'; | ||
import { IconButton, MenuProps, Stack, Typography } from '@mui/material'; | ||
import { useState } from 'react'; | ||
import { canEditAny, StyleProps } from '~/common'; | ||
import { useDialog } from '../../Dialog'; | ||
import { FormattedDateTime } from '../../Formatters'; | ||
import { DeletePost } from '../DeletePost'; | ||
import { EditPost } from '../EditPost'; | ||
import { PostableIdFragment } from '../PostableId.graphql'; | ||
import { PostListItemCardFragment } from './PostListItemCard.graphql'; | ||
import { PostListItemMenu } from './PostListItemMenu'; | ||
|
||
interface PostListItemCardProps extends StyleProps { | ||
parent: PostableIdFragment; | ||
post: PostListItemCardFragment; | ||
includeMembership?: boolean; | ||
} | ||
|
||
export const PostListItem = ({ | ||
parent, | ||
post, | ||
includeMembership = false, | ||
...rest | ||
}: PostListItemCardProps) => { | ||
const [actionsAnchor, setActionsAnchor] = useState<MenuProps['anchorEl']>(); | ||
const [editState, editPost] = useDialog(); | ||
const [deleteState, deletePost] = useDialog(); | ||
const editable = canEditAny(post); | ||
|
||
return ( | ||
<Stack direction="column" spacing={1} {...rest}> | ||
<Stack | ||
direction="row" | ||
spacing={2} | ||
justifyContent="space-between" | ||
alignItems="flex-start" | ||
> | ||
<Stack | ||
direction="column" | ||
justifyContent="center" | ||
spacing={0.5} | ||
flex={1} | ||
> | ||
<Typography variant="body2" color="textSecondary"> | ||
{post.creator.value?.fullName} | ||
</Typography> | ||
<Typography variant="body2" color="textSecondary"> | ||
<FormattedDateTime date={post.createdAt} /> | ||
</Typography> | ||
</Stack> | ||
{editable && ( | ||
<IconButton onClick={(e) => setActionsAnchor(e.currentTarget)}> | ||
<MoreVert /> | ||
</IconButton> | ||
)} | ||
</Stack> | ||
<Typography variant="h4">{post.body.value}</Typography> | ||
|
||
<PostListItemMenu | ||
anchorEl={actionsAnchor} | ||
open={Boolean(actionsAnchor)} | ||
onClose={() => setActionsAnchor(null)} | ||
onEdit={() => { | ||
editPost(); | ||
setActionsAnchor(null); | ||
}} | ||
onDelete={() => { | ||
deletePost(); | ||
setActionsAnchor(null); | ||
}} | ||
/> | ||
<EditPost | ||
includeMembership={includeMembership} | ||
post={post} | ||
{...editState} | ||
/> | ||
<DeletePost parent={parent} post={post} {...deleteState} /> | ||
</Stack> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './PostListItemCard'; | ||
export * from './PostListItem'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.