feat(fe): make container and file upload component for TCManage page#3579
feat(fe): make container and file upload component for TCManage page#3579ojongii wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the problem creation interface by consolidating several standalone pages into a unified TcManagePage and introducing a reusable FileUpload component. The changes also include adding an 'underline' variant to the shadcn Tabs component. Review feedback highlights several improvement opportunities for the FileUpload component, including enhancing accessibility, ensuring the multiple prop is respected during drag-and-drop, and using more unique keys for file lists. Further suggestions include resetting the active tab state in TcManagePage when the problem type changes and cleaning up unused state in the tab sub-components.
| const handleFiles = (incoming: FileList | null) => { | ||
| if (!incoming) { | ||
| return | ||
| } | ||
| const next = Array.from(incoming) | ||
| setFiles(next) | ||
| onFilesChange(next) | ||
| } |
There was a problem hiding this comment.
| <div | ||
| onClick={() => inputRef.current?.click()} |
There was a problem hiding this comment.
div 요소에 onClick 이벤트를 사용하여 버튼처럼 동작하게 할 때는 웹 접근성(A11y)을 위해 role="button"과 tabIndex={0}, 그리고 키보드 이벤트 핸들러(onKeyDown)를 추가하여 키보드 사용자가 상호작용할 수 있도록 개선하는 것이 좋습니다.
<div
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
inputRef.current?.click()
}
}}
onClick={() => inputRef.current?.click()}
| > | ||
| <input | ||
| ref={inputRef} | ||
| type="file" |
| <ul className="flex flex-col items-center gap-1"> | ||
| {files.map((f) => ( | ||
| <li | ||
| key={f.name} |
| <Tabs | ||
| value={activeValue} |
There was a problem hiding this comment.
| const [, setFiles] = useState<File[]>([]) | ||
| return ( | ||
| <FileUpload | ||
| multiple | ||
| primaryText="업로드 된 테스트 생성 파일이 없습니다." | ||
| secondaryText=".in 자동 생성이 필요하면 추가해주세요." | ||
| onFilesChange={setFiles} |
There was a problem hiding this comment.
TcAutoCard1에서 정의된 files 상태는 컴포넌트 내에서 사용되지 않고 있습니다. FileUpload 내부에서 이미 파일 목록 상태를 관리하고 있으므로, 부모 컴포넌트에서 이 정보가 필요하지 않다면 불필요한 상태 선언입니다.
| const [, setFiles] = useState<File[]>([]) | |
| return ( | |
| <FileUpload | |
| multiple | |
| primaryText="업로드 된 테스트 생성 파일이 없습니다." | |
| secondaryText=".in 자동 생성이 필요하면 추가해주세요." | |
| onFilesChange={setFiles} | |
| return ( | |
| <FileUpload | |
| multiple | |
| primaryText="업로드 된 테스트 생성 파일이 없습니다." | |
| secondaryText=".in 자동 생성이 필요하면 추가해주세요." | |
| onFilesChange={() => {}} |
| handleFiles(e.dataTransfer.files) | ||
| }} | ||
| className={cn( | ||
| 'border-color-cool-neutral-80 bg-color-neutral-99 flex cursor-pointer flex-col items-center justify-center rounded-[12px] py-20', |
There was a problem hiding this comment.
TC 인풋 자동 생성처럼 border가 먼저 적용되면 피그마 디자인처럼 안 나오는 부분이 있어서 border는 빼고 컴포넌트화 한 뒤에, 사용할 때 border를 필요에 따라 추가해야 할 것 같아요!
…nt-for-TCManage-page
|
✅ Syncing Preview App Succeeded Application: |
|
✅ Syncing Preview App Succeeded Application: |
| ))} | ||
| </TabsList> | ||
| </Tabs> | ||
| {active.cards.map((Card, i) => ( |
There was a problem hiding this comment.
피그마 디자인을 보면 0번째 카드는 탭과 함께 박스로 묶여야 될 것 같아요~
Description
테스트 케이스 관리 탭들의 컨테이너와 파일 업로드 컴포넌트를 만들었습니다.
특수 문제 생성 탭은 /problem/create/?type=special에서 확인할 수 있습니다.
Additional context
closes TAS-2720
Before submitting the PR, please make sure you do the following
fixes #123).