Skip to content

Commit

Permalink
Add logic for closing drawer on click
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed May 26, 2024
1 parent 6472fe3 commit 6f3b74e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/blog/src/components/DrawerComment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import CommentAvatar from "#components/CommentAvatar";
import Typography from "#components/Typography";
import styles from "./index.module.scss";

export interface DrawerCommentProps {
closeDrawer(): void;
}

const cx = classNames(styles, "drawer-comment");

function DrawerComment() {
function DrawerComment({ closeDrawer }: DrawerCommentProps) {
const { data } = useComments({ count: 6 });

return (
<ol className={cx()}>
{data.map(({ _id: id, name, url, body, createdAt, byPostAuthor, postSlug }) => (
<li key={id} className={cx("__comment")}>
<Link href={postSlug} className={cx("__link")}>
<Link href={postSlug} className={cx("__link")} onClick={closeDrawer}>
<figure className={cx("__avatar")}>
<CommentAvatar name={name} url={url} postAuthor={byPostAuthor} />
</figure>
Expand Down
2 changes: 1 addition & 1 deletion apps/blog/src/components/DrawerContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function DrawerContent({ opened, closeDrawer, willClose, setWillClose }: DrawerC
<QueryClientProvider client={queryClient}>
<ErrorBoundary fallback={null}>
<Suspense fallback={null}>
<DrawerComment />
<DrawerComment closeDrawer={close} />
</Suspense>
</ErrorBoundary>
</QueryClientProvider>
Expand Down

0 comments on commit 6f3b74e

Please sign in to comment.