-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ananjaemin/3-file-list-page-dev
3 file list page dev
- Loading branch information
Showing
12 changed files
with
215 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
import * as S from './styled'; | ||
|
||
type FileListBoxProps = { | ||
filename: string; | ||
size: string; | ||
LastModified: any; | ||
}; | ||
|
||
export const FileListBox: React.FC<FileListBoxProps> = ({ filename, size, LastModified }) => ( | ||
<S.FileListBoxContainer> | ||
파일이름: {filename} / 크기:{size} / 업로드날짜:{LastModified.getFullYear()}- | ||
{LastModified.getMonth() + 1}-{LastModified.getDate()} | ||
</S.FileListBoxContainer> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const FileListBoxContainer = styled.div` | ||
background-color: var(--color-backgorund-filelistbox); | ||
color: var(--color-text-filelistbox); | ||
border-radius: 10px; | ||
padding: 1.2rem 1.2rem 1.2rem 1.2rem; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
font-size: 2.2rem; | ||
margin-bottom: 1.5rem; | ||
cursor: pointer; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import axios from 'axios'; | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { FileListBox } from '../../components'; | ||
import { getFileSize, getShortFileName } from '../../utils'; | ||
import * as S from './styled'; | ||
|
||
export const FileListPage: React.FC = () => { | ||
const [loading, setLoading] = useState(false); | ||
const SkeletonUIRandomWidth = ['50', '55', '60', '65', '70', '75', '80']; | ||
const [fileList, setFileList] = useState<any[]>(); | ||
const getFileList = async () => { | ||
await axios({ | ||
method: 'get', | ||
url: 'https://tfb.minpeter.cf/list', | ||
}) | ||
.then((res) => { | ||
setFileList(res.data.list); | ||
setLoading(true); //loading 확인하고싶으면 false로 바꿔주세요. | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}; | ||
useEffect(() => { | ||
getFileList(); | ||
}, []); | ||
return ( | ||
<> | ||
{loading ? ( | ||
<> | ||
<S.FileListPageContainer> | ||
{fileList?.map((item, index) => ( | ||
<FileListBox | ||
key={index} | ||
filename={getShortFileName(item.Name)} | ||
size={getFileSize(item.Size)} | ||
LastModified={new Date(item.LastModified)} | ||
/> | ||
))} | ||
</S.FileListPageContainer> | ||
<S.FileListPageBoxShoadow /> | ||
</> | ||
) : ( | ||
<> | ||
<S.FileListPageContainer> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
<S.FileListSkeletonUI | ||
randomWitdh={SkeletonUIRandomWidth[Math.floor(Math.random() * 6)]} | ||
/> | ||
</S.FileListPageContainer> | ||
<S.FileListPageBoxShoadow /> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const FileListPageContainer = styled.div` | ||
max-height: 40rem; | ||
overflow: auto; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
&::-webkit-scrollbar { | ||
display: none; | ||
} | ||
`; | ||
|
||
export const FileListPageBoxShoadow = styled.div` | ||
width: 100%; | ||
height: 6rem; | ||
position: relative; | ||
top: -25px; | ||
background: linear-gradient(180deg, rgba(40, 42, 58, 0) 0%, #282a3a 45.31%); | ||
`; | ||
|
||
export const FileListSkeletonUI = styled.div<{ randomWitdh: string }>` | ||
display: flex; | ||
background-color: var(--color-backgorund-filelistbox); | ||
border-radius: 10px; | ||
margin-bottom: 1.5rem; | ||
min-height: 4.6rem; | ||
min-width: ${(props) => props.randomWitdh}rem; | ||
overflow: hidden; | ||
&::before { | ||
content: ' '; | ||
width: 100%; | ||
height: auto; | ||
animation: loading 2.5s infinite; | ||
box-shadow: 0 0 30px 30px rgba(255, 255, 255, 0.3); | ||
} | ||
@keyframes loading { | ||
0% { | ||
transform: translateX(-50%); | ||
} | ||
50% { | ||
transform: translateX(100%); | ||
} | ||
100% { | ||
transform: translate(200%); | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const getFileFullName = (fileName: string) => { | ||
var lastDot = fileName.lastIndexOf('.'); | ||
if (lastDot === -1) { | ||
lastDot = fileName.length; | ||
} | ||
const fileFullName = fileName.substring(0, lastDot); | ||
return fileFullName; | ||
}; | ||
|
||
const getFileExtension = (fileName: string) => { | ||
var lastDot = fileName.lastIndexOf('.'); | ||
const fileLength = fileName.length; | ||
const fileExtension = fileName.substring(lastDot + 1, fileLength); | ||
if (lastDot === -1) { | ||
return ''; | ||
} | ||
return '.' + fileExtension; | ||
}; | ||
|
||
export const getShortFileName = (fileName: string) => { | ||
const fileFullName = getFileFullName(fileName); | ||
if (fileFullName.length >= 9) { | ||
return fileFullName.substring(0, 10) + '(...)' + getFileExtension(fileName); | ||
} | ||
return fileName; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const getFileFullName = (fileName: string) => { | ||
var lastDot = fileName.lastIndexOf('.'); | ||
if (lastDot === -1) { | ||
lastDot = fileName.length; | ||
} | ||
const fileFullName = fileName.substring(0, lastDot); | ||
return fileFullName; | ||
}; | ||
|
||
const getFileExtension = (fileName: string) => { | ||
var lastDot = fileName.lastIndexOf('.'); | ||
const fileLength = fileName.length; | ||
const fileExtension = fileName.substring(lastDot + 1, fileLength); | ||
if (lastDot === -1) { | ||
return ''; | ||
} | ||
return '.' + fileExtension; | ||
}; | ||
|
||
export const getShotFileName = (fileName: string) => { | ||
const fileFullName = getFileFullName(fileName); | ||
if (fileFullName.length >= 9) { | ||
return fileFullName.substring(0, 10) + '(...)' + getFileExtension(fileName); | ||
} | ||
return fileName; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './getFileSize'; | ||
export * from './getShortFileName'; |