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

Fix/bottom sheet open twice #159

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions src/assets/icons/default-profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CheckIcon from './check.svg?react';
import ClockIcon from './clock.svg?react';
import CloseIcon from './close.svg?react';
import CommentIcon from './comment.svg?react';
import DefaultProfileIcon from './default-profile.svg?react';
import DownChevronIcon from './down-chevron.svg?react';
import GoogleIcon from './google.svg?react';
import HideIcon from './hide.svg?react';
Expand Down Expand Up @@ -51,6 +52,7 @@ export {
ClockIcon,
CloseIcon,
CommentIcon,
DefaultProfileIcon,
DownChevronIcon,
GoogleIcon,
HideIcon,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Home/Comment/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';

import { useReactComment } from '@apis/comment/useComment';
import { Col, Row } from '@components/commons/Flex/Flex';
import ProfileImg from '@components/commons/ProfileImg/ProfileImg';
import Text from '@components/commons/Text/Text';
import useModal from '@hooks/useModal/useModal';
import { CommentResponse } from '@interfaces/api/comment';
Expand Down Expand Up @@ -69,7 +70,7 @@ const Comment = React.memo(({ comment }: CommentProps) => {
<Col padding={'14px 20px 24px'}>
<Row justifyContent={'space-between'} alignItems={'flex-start'}>
<Row gap={8}>
<CommentAuthorProfileImg src={'https://picsum.photos/50/50'} alt={'profile'} />
<ProfileImg url={comment.writer.profileImageUrl} size={22} />
<Col gap={2}>
<Row>
<Text size={14} color={colors.black_60}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Home/TopicComments/TopicComments.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { memo, useState } from 'react';

import { useComments, useCreateComment } from '@apis/comment/useComment';
import { Row } from '@components/commons/Flex/Flex';
Expand All @@ -21,7 +21,7 @@ interface TopicCommentsProps {
topic: TopicResponse;
}

const TopicComments = ({ topic }: TopicCommentsProps) => {
const TopicComments = memo(({ topic }: TopicCommentsProps) => {
const { data: comments, fetchNextPage } = useComments(
topic.topicId,
topic.selectedOption !== null
Expand Down Expand Up @@ -71,6 +71,6 @@ const TopicComments = ({ topic }: TopicCommentsProps) => {
</CommentInputContainer>
</TopicCommentsContainer>
);
};
});

export default TopicComments;
35 changes: 35 additions & 0 deletions src/components/commons/ProfileImg/ProfileImg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

import { DefaultProfileIcon } from '@icons/index';

interface ProfileImgProps {
url: string | null;
size?: string | number;
rounded?: boolean;
}

const ProfileImg = ({ url, size = '100%', rounded = true }: ProfileImgProps) => {
if (!url) {
return (
<div>
<DefaultProfileIcon
width={size}
height={size}
style={rounded ? { borderRadius: '50%' } : {}}
/>
</div>
);
}

return (
<img
src={url}
alt="ํ”„๋กœํ•„ ์ด๋ฏธ์ง€"
width={size}
height={size}
style={rounded ? { borderRadius: '50%' } : {}}
/>
);
};

export default ProfileImg;
2 changes: 1 addition & 1 deletion src/hooks/useBottomSheet/useBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useBottomSheet = (props: UseBottomSheetProps) => {
</BottomSheet>
);

return { BottomSheet: isOpen ? Sheet : () => null, toggleSheet };
return { BottomSheet: Sheet, toggleSheet };
};

export default useBottomSheet;
Loading