-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Refactor] 컴포넌트, 변수명 리펙토링 #204
Changes from 8 commits
4c7f9f0
ccd1251
d74ebf0
6eb52cb
a4051ee
aa73180
5b1ee70
2d258d7
bcefe98
718b2c2
296f702
ea57b6b
7bf7760
d314584
96ad38c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ export const tabStyle = (tabId: string) => | |
font: `${theme.text.body04}`, | ||
}); | ||
|
||
export const selectedStyle = (selected: string, tabId: string) => | ||
selected === tabId | ||
export const selectedStyle = (selectedTabId: string, tabId: string) => | ||
selectedTabId === tabId | ||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍👍 |
||
? css({ | ||
backgroundColor: theme.colors.white, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,21 @@ import Button from '@/common/component/Button/Button'; | |
import Flex from '@/common/component/Flex/Flex'; | ||
|
||
interface DocumentBarTabProps { | ||
selectedId: string; | ||
onTabClick: (selectedId: string, tabId: string) => void; | ||
selectedTabId: string; | ||
onTabClick: (selectedTabId: string, tabId: string) => void; | ||
} | ||
|
||
const DocumentBarTab = ({ selectedId, onTabClick }: DocumentBarTabProps) => { | ||
const DocumentBarTab = ({ selectedTabId, onTabClick }: DocumentBarTabProps) => { | ||
return ( | ||
<Flex tag={'nav'}> | ||
<Button | ||
onClick={() => onTabClick(selectedId, 'selected')} | ||
css={[tabStyle('selected'), selectedStyle(selectedId, 'selected')]}> | ||
onClick={() => onTabClick(selectedTabId, 'selected')} | ||
css={[tabStyle('selected'), selectedStyle(selectedTabId, 'selected')]}> | ||
선택한 블록 | ||
</Button> | ||
<Button | ||
onClick={() => onTabClick(selectedId, 'total')} | ||
css={[tabStyle('total'), selectedStyle(selectedId, 'total')]}> | ||
onClick={() => onTabClick(selectedTabId, 'total')} | ||
css={[tabStyle('total'), selectedStyle(selectedTabId, 'total')]}> | ||
Comment on lines
+15
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 규홍님께 제가 HTML문서를 찾아봤는데, " 즉, 이 때 또 고려해볼 수 있는건 실제로 WAI-ARIA 가 제공해주는 거기다가 더해서 li 태그를 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호!! 이거 브렌치 머지하고 다른 브렌치파서 주용님이 알려주신 방향으로 공컴 구현 도전해보겠습니다!! |
||
전체 문서 | ||
</Button> | ||
</Flex> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/* eslint-disable jsx-a11y/click-events-have-key-events */ | ||
import { | ||
blockNameTextStyle, | ||
containerStyle, | ||
fileNameStyle, | ||
blockNameStyle, | ||
documentItemContainerStyle, | ||
documentNameStyle, | ||
} from '@/page/archiving/index/component/DocumentItem/DocumentItem.style'; | ||
import { handleDownload } from '@/page/archiving/index/util/document'; | ||
import { downloadDocument } from '@/page/archiving/index/util/document'; | ||
|
||
import { ReactNode } from 'react'; | ||
|
||
|
@@ -21,51 +21,58 @@ import { useTeamId } from '@/shared/store/team'; | |
interface DocumentItemProps { | ||
documentId: number; | ||
children: ReactNode; | ||
selectedId: string; | ||
selectedTabId: string; | ||
blockName?: string; | ||
fileUrl: string; | ||
color?: string; | ||
documentUrl: string; | ||
blockColor?: string; | ||
} | ||
|
||
const DocumentItem = ({ documentId, children, selectedId, blockName, fileUrl, color }: DocumentItemProps) => { | ||
const DocumentItem = ({ | ||
documentId, | ||
children, | ||
selectedTabId, | ||
blockName, | ||
documentUrl, | ||
blockColor, | ||
}: DocumentItemProps) => { | ||
const { isOpen, openModal, closeModal, currentContent } = useModal(); | ||
|
||
const fileName = children?.toString(); | ||
const documentName = children?.toString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file ->document로 변경해주니 코드 전체적으로 통일감이 느껴져서 좋네요👍 |
||
|
||
const teamId = useTeamId(); | ||
|
||
//문서 클릭시 띄워주는 함수 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수명만으로도 어떤 의도인지 파악이 충분히 가능하다고 생각해서 이 주석은 제거해주셔도 좋을 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 동의합니다! |
||
const onClickDocumentItem = () => { | ||
window.open(fileUrl); | ||
const handleDocumentItemClick = () => { | ||
window.open(documentUrl); | ||
}; | ||
|
||
const handleDownloadClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
handleDownload(fileUrl, fileName); | ||
downloadDocument(documentUrl, documentName); | ||
e.stopPropagation(); | ||
}; | ||
|
||
const handleTrashClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
const handleTrashBoxClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
e.stopPropagation(); | ||
openModal(<DeleteModal title="docs" detail="docs" onClose={closeModal} teamId={+teamId} id={documentId} />); | ||
}; | ||
|
||
return ( | ||
<> | ||
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */} | ||
<li css={containerStyle(selectedId)} onClick={onClickDocumentItem}> | ||
{color && ( | ||
<li css={documentItemContainerStyle(selectedTabId)} onClick={handleDocumentItemClick}> | ||
{blockColor && ( | ||
<div> | ||
<Text tag="body8" css={blockNameTextStyle(color)}> | ||
<Text tag="body8" css={blockNameStyle(blockColor)}> | ||
{blockName} | ||
</Text> | ||
</div> | ||
)} | ||
<Flex> | ||
<Text tag="body6" css={fileNameStyle}> | ||
{fileName} | ||
<Text tag="body6" css={documentNameStyle}> | ||
{documentName} | ||
</Text> | ||
<Download width={20} height={20} css={{ cursor: 'pointer' }} onClick={handleDownloadClick} /> | ||
<TrashBox width={20} height={20} onClick={(e) => handleTrashClick(e)} css={{ cursor: 'pointer' }} /> | ||
<TrashBox width={20} height={20} onClick={(e) => handleTrashBoxClick(e)} css={{ cursor: 'pointer' }} /> | ||
</Flex> | ||
</li> | ||
<Modal isOpen={isOpen} children={currentContent} onClose={closeModal} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import DocumentItem from '@/page/archiving/index/component/DocumentItem/DocumentItem'; | ||
import { ICON_TYPE } from '@/page/archiving/index/constant/icon'; | ||
import { useBlockQuery } from '@/page/archiving/index/hook/api/useBlockQuery'; | ||
import { useBlockInfoQuery } from '@/page/archiving/index/hook/api/useBlockInfoQuery'; | ||
import { Block } from '@/page/archiving/index/type/blockType'; | ||
import { DocumentType } from '@/page/archiving/index/type/documentType'; | ||
import { formattingDate } from '@/page/archiving/index/util/date'; | ||
|
@@ -19,23 +19,23 @@ import { useTeamId } from '@/shared/store/team'; | |
import { blockNameStyle, deleteBtnStyle } from './SelectedBlock.style'; | ||
|
||
interface DocumentBarInfoProps { | ||
selectedId: string; | ||
selectedTabId: string; | ||
blockName: string; | ||
selectedBlock: Block; | ||
onClickClose: () => void; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 동의합니다! |
||
} | ||
|
||
const SelectedBlock = ({ selectedId, blockName, selectedBlock, onClickClose }: DocumentBarInfoProps) => { | ||
const SelectedBlock = ({ selectedTabId, blockName, selectedBlock, onClickClose }: DocumentBarInfoProps) => { | ||
const { isOpen, openModal, closeModal, currentContent } = useModal(); | ||
|
||
const teamId = useTeamId(); | ||
|
||
const { data: blockData } = useBlockQuery(+teamId, selectedBlock?.timeBlockId ?? 0); | ||
const { data: blockData } = useBlockInfoQuery(+teamId, selectedBlock?.timeBlockId ?? 0); | ||
|
||
const startDate = formattingDate(selectedBlock.startDate); | ||
const endDate = formattingDate(selectedBlock.endDate); | ||
|
||
const handleCloseClick = () => { | ||
const handleModalClose = () => { | ||
onClickClose(); | ||
closeModal; | ||
}; | ||
|
@@ -56,7 +56,7 @@ const SelectedBlock = ({ selectedId, blockName, selectedBlock, onClickClose }: D | |
<DeleteModal | ||
title="block" | ||
detail="block" | ||
onClose={handleCloseClick} | ||
onClose={handleModalClose} | ||
teamId={+teamId} | ||
id={selectedBlock.timeBlockId} | ||
/> | ||
|
@@ -74,9 +74,9 @@ const SelectedBlock = ({ selectedId, blockName, selectedBlock, onClickClose }: D | |
<DocumentItem | ||
key={data.documentId} | ||
documentId={data.documentId} | ||
selectedId={selectedId} | ||
selectedTabId={selectedTabId} | ||
blockName={data.blockName} | ||
fileUrl={data.fileUrl}> | ||
documentUrl={data.fileUrl}> | ||
{data.fileName} | ||
</DocumentItem> | ||
))} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query'; | |
|
||
import { getDocuments } from '@/shared/api/time-blocks/team/time-block'; | ||
|
||
export const useBlockQuery = (teamId: number, blockId: number) => { | ||
export const useBlockInfoQuery = (teamId: number, blockId: number) => { | ||
return useQuery({ | ||
queryKey: ['document', blockId], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 블럭 내용 관련 이라면 쿼리키를 'blockInfo' 와 같은 블록 내용관련으로 바꿔도 좋을 거 같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요거는 문서 삭제되면 전체문서, 블록 문서 두개 모두 재실행 시키기 위해서 두 쿼리의 첫 쿼리키를 document로 지정해 보았습니다! |
||
queryFn: () => getDocuments(teamId, blockId), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 이전 네이밍이 더 좋은 것 같아요 !
어차피
DocumentBar.style.ts
이므로 도큐먼트바에 대한 스타일링이 명시되어있으므로, 그냥container
스타일이라 해도 좋을 것 같아요There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
흠 containerStyle로만 하니 온갖 군데에서 선언한 containerStyle이 자동완성에 다떠서 요렇게 바꾸어 봤는데 저도 너무 길다는 느낌이 들긴해서 다시 돌려놓는게 맞는거 같네요!!