Skip to content

Commit

Permalink
Refactor FileListBox component to use styled.a instead of styled.div
Browse files Browse the repository at this point in the history
  • Loading branch information
minpeter committed Apr 22, 2024
1 parent 3491802 commit f435e3c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
26 changes: 12 additions & 14 deletions src/components/FileListBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ export function FileListBox({
setDownloading,
}: FileListBoxProps) {
return (
<S.FileListBoxContainer>
<a
style={{ color: 'inherit', textDecoration: 'none' }}
href={Backend(downloadUrl)}
onClick={async (e) => {
e.preventDefault();
setDownloading(true);
await downloadFile(downloadUrl, filename);
setDownloading(false);
}}
>
{filename} / {getFileSize(size)}
{downloading && size >= 2000_000 ? ' / 다운로드 중...' : ''}
</a>
<S.FileListBoxContainer
style={{ color: 'inherit', textDecoration: 'none' }}
href={Backend(downloadUrl)}
onClick={async (e) => {
e.preventDefault();
setDownloading(true);
await downloadFile(downloadUrl, filename);
setDownloading(false);
}}
>
{filename} / {getFileSize(size)}
{downloading && size >= 2000_000 ? ' / 다운로드 중...' : ''}
</S.FileListBoxContainer>
);
}
15 changes: 12 additions & 3 deletions src/components/FileListBox/styled.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import styled from '@emotion/styled';

export const FileListBoxContainer = styled.div`
export const FileListBoxContainer = styled.a`
width: fit-content;
background-color: var(--color-backgorund-filelistbox);
color: var(--color-text-tertiary);
border-radius: 1rem;
padding: 1.2rem 1.2rem 1.2rem 1.2rem;
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-start;
align-items: center;
font-size: 2.2rem;
margin-bottom: 1.5rem;
margin: 0.5rem auto;
cursor: pointer;
text-wrap: balance;
text-align: center;
`;
27 changes: 13 additions & 14 deletions src/pages/download/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,20 @@ export function DownloadPage() {
</S.IdBox>
<S.DownloadFileListBoxContainer>
{fileProps.files.map((file: FileListBoxProps, index: number) => (
<div key={index}>
<FileListBox
filename={file.filename}
size={file.size}
downloadUrl={file.downloadUrl}
downloading={itemDownloading[index]}
setDownloading={(downloading: boolean) => {
const updatedItemDownloading = [...itemDownloading];
updatedItemDownloading[index] = downloading;
setItemDownloading(updatedItemDownloading);
<FileListBox
key={index}
filename={file.filename}
size={file.size}
downloadUrl={file.downloadUrl}
downloading={itemDownloading[index]}
setDownloading={(downloading: boolean) => {
const updatedItemDownloading = [...itemDownloading];
updatedItemDownloading[index] = downloading;
setItemDownloading(updatedItemDownloading);

return downloading;
}}
/>
</div>
return downloading;
}}
/>
))}
</S.DownloadFileListBoxContainer>

Expand Down
3 changes: 3 additions & 0 deletions src/pages/download/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const DownloadFileListBoxContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
margin: 0 1rem;
&::-webkit-scrollbar {
display: none;
}
Expand Down

0 comments on commit f435e3c

Please sign in to comment.