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

Feature/common feed #21

Merged
merged 18 commits into from
Oct 30, 2024
Merged

Feature/common feed #21

merged 18 commits into from
Oct 30, 2024

Conversation

lee1nna
Copy link
Collaborator

@lee1nna lee1nna commented Oct 24, 2024

Pull Request 요약

PR에 대한 내용을 작성해주세요.

일반 피드 작업 관련 PR 입니다.


작업 내용

작업 내용에 대해서 작성해주세요.

  • 일반피드 생성화면 UI 개발
  • 이미지 업로드 훅으로 분리
  • 일반피드 파일첨부 기능 개발
  • 해시태그 컴포넌트 적용
  • ConfirmPopup 컴포넌트 개발

참고 사항

참고 사항이 있다면 첨부해주세요.

  • 일반피드 모달의 좌측영역은 동일하여 ImagePreview 컴포넌트로 분리하였습니다.
  • 모달의 단계에 따라 우측영역만 변경되므로 AddImage 컴포넌트와 AddContent 컴포넌트로 단계적으로 처리하였습니다.
  • 이미지 업로드 로직은 useImageUpload 훅으로 별도로 분리하여 가독성을 개선하고 AddImage, AddContent 컴포넌트는 UI에 집중할 수 있도록 구성하였습니다.
  • 게시 또는 삭제 팝업은 ConfirmPopup 컴포넌트로 공통적으로 구현하였습니다.
    image

관련 이슈

closing할 이슈 번호를 작성해주세요.


- remove aria-hidden="true" in modal background
- remove aria-hidden="true" in modal container
- add role in modal div
- change link to button in ModalMenu
- modify modal scss
- seperate image upload logic hooks
- add image preview common component
- add flex related mixin
- seperate common feed related type
- add setData useEffect dependency array
- change image tag to next/image
- common feed popup state intergration
- add common feed popup type
- remove children setState props & apply to update function from parent
@lee1nna lee1nna added the feat 구현, 개선 사항에 관련된 이슈입니다. label Oct 24, 2024
@lee1nna lee1nna self-assigned this Oct 24, 2024
Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for prostargram failed.

Name Link
🔨 Latest commit 4d006ca
🔍 Latest deploy log https://app.netlify.com/sites/prostargram/deploys/6721eaf7b1625e0008e8c739

@seongjin2427 seongjin2427 self-requested a review October 26, 2024 12:42
Copy link
Collaborator

@seongjin2427 seongjin2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 하셨습니다!!

setCurrentImage,
removeImage,
} = useImageUpload();
const [data, setData] = useState<CommonFeedData>({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상태명을 feedData로 변경해보는건 어떨까요!?
그냥 data는 너무 일반적인 명사라서 어떤 데이터인지 명확하지 않은 것 같아서요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature/discussion-feed 브랜치에서 변경 될 예정입니다!

...prev,
hashtag: newHashtags,
}));
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateImages, updateContents, updateHashTags를 하나의 메서드로 변경해보는건 어떨까요!
하나의 메서드로 합치면 코드 복잡성도 낮출 수 있고, 이후 하위 컴포넌트로 전달할 props의 개수도 적으니
나중에 유지보수하거나 코드 읽기도 더 쉬울 것 같아요!

  const changeFeedData = (nextFeedData: Partial<CommonFeedData>) => {
    setFeedData((prev) => ({
      ...prev,
      ...nextFeedData,
    }));
  };

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다 😊

onNext?: () => void;
images: FeedImage[];
currentImage: FeedImage | null;
setCurrentImage: React.Dispatch<SetStateAction<FeedImage | null>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적인 의견입니다!
props로 전달받는 상태 변경 함수를 그대로 사용하여 React.Dispatch, SetStateAction 타입을 사용하는 것보다,
아래와 같이 상태 변경 함수를 호출하는 메서드를 전달받아
타입을 길게 작성하지 않아도 되는 걸 선호하는 편입니다 하하.

  • Before
import { ChangeEvent, SetStateAction, useEffect, useState } from 'react';

...
const SomeComponent = () => {
  const [currentImage, setCurrentImage] = useSate<FeedImage | null>(null);
  ...
}

type AddContentProps = {
  ... 
  setCurrentImage: React.Dispatch<SetStateAction<FeedImage | null>>;
}
  • After
import { ChangeEvent, useEffect, useState } from 'react';
// SetStateAction 타입 제거 가능

const SomeComponent = () => {
  const [currentImage, setCurrentImage] = useSate<FeedImage | null>(null);

  const updateCurrentImage = (nextCurrentImage: FeedImage) => {
    setCurrentImage(nextCurrentImage);
  }
  ...
}

type AddContentProps = {
  ... 
  updateCurrentImage: (nextCurrentImage: FeedImage) => void;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다 😊

@@ -56,7 +57,9 @@ const Navigation = () => {
type: 'modal',
url: '/',
icon: <CommonFeedIcon />,
component: <Modal onClose={closeModal}>일반피드로 대체 예정입니다</Modal>,
component: (
<CommonFeed modalStatus={feedModal} setModalStauts={setFeedModal} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오타가 있습니닷! 😅
setModalStauts -> setModalStatus

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature/discussion-feed 브랜치에서 변경 될 예정입니다!


const createCommonFeed = () => {
// TODO: 일반피드 작성 서버 API 연동
console.log('데이터', data);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최종적으로 서버로 생성할 피드 정보를 보낼 때,
base64로 인코딩 된 문자열이 아닌 File 객체 그대로 전송해야 합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다 😊

- change ts file name (commonFeed -> feed)
- add discussion subject components
- add AddContents feed type props
- modify commonfeed typo
- replace Textarea component
- change document name (@type->type)
- modify update discussion feed data using Partial
- add modal component max height
- modify refactoring feed data using Partial
- add max-height in modal css
- remove setStateAction props
- modify common feed update function using Partial
- change image type to match server request value
Copy link

@lee1nna lee1nna merged commit bff4a9d into develop Oct 30, 2024
2 of 6 checks passed
@lee1nna lee1nna deleted the feature/common-feed branch December 16, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 구현, 개선 사항에 관련된 이슈입니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

토론피드 UI 개발 일반피드 생성 UI 개발
2 participants