This repository was archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add list and delete page #24
Open
choi138
wants to merge
13
commits into
main
Choose a base branch
from
feature/22-add-list-and-delete-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
428fdc1
feat: add list api & query hook
choi138 c77b18c
feat: add list page
choi138 69ffb2b
feat: add data list component
choi138 0a0d3bb
feat: add file detail component & list page style
choi138 a621ffe
feat: add text detail component
choi138 a2e1b8f
feat: add delete page
choi138 06a263b
feat: add skeleton UI box component
choi138 03bba19
style: list page style & add skeleton when it loads
choi138 cb01840
fix: data load error fix
choi138 b0b968b
fix: add SkeletonUIBox in index.ts file
choi138 bf0b6a2
fix: checkPw page add loading handling
choi138 3851cd7
refactor: add get short data utils file
choi138 0251c63
refactor: optionActive by option name
choi138 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| import { API_SUFFIX, instance } from './api'; | ||
| import { FileResponse } from './file'; | ||
| import { TextResponse } from './text'; | ||
|
|
||
| export interface DataListResponse { | ||
| files: FileResponse[]; | ||
| texts: TextResponse[]; | ||
| } | ||
|
|
||
| export const getList = async (): Promise<DataListResponse> => { | ||
| const { data } = await instance.get(API_SUFFIX.LIST); | ||
| return data; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { useGetWindowSize } from '@/hooks'; | ||
| import { FileResponse } from '@/api'; | ||
|
|
||
| export interface FileDetailProps { | ||
| uploadDate: { | ||
| year: number; | ||
| month: number; | ||
| day: number; | ||
| }; | ||
| fileData: FileResponse; | ||
| fileSize: string; | ||
| isDetailPage?: boolean; | ||
| } | ||
|
|
||
| export const FileDetail: React.FC<FileDetailProps> = ({ | ||
| uploadDate, | ||
| fileData, | ||
| fileSize, | ||
| isDetailPage, | ||
| }) => { | ||
| const { windowSize } = useGetWindowSize(); | ||
|
|
||
| const calculateMaxFilenameLength = () => { | ||
| switch (true) { | ||
| case windowSize > 1250: | ||
| return 80; | ||
| case windowSize > 1180: | ||
| return 60; | ||
| case windowSize > 768: | ||
| return 55; | ||
| case windowSize > 530: | ||
| return 42; | ||
| default: | ||
| return 27; | ||
| } | ||
| }; | ||
|
|
||
| const getShortFileName = (fileName: string, maxFilenameLength: number) => { | ||
| const lastDot = fileName.lastIndexOf('.'); | ||
| const fileExtension = lastDot === -1 ? '' : fileName.substring(lastDot + 1); | ||
|
|
||
| if (fileName.length > maxFilenameLength) { | ||
| return `${fileName.slice(0, maxFilenameLength)}(...).${fileExtension}`; | ||
| } | ||
|
|
||
| return fileName; | ||
| }; | ||
|
|
||
| const fileName = fileData.filename; | ||
| const fileNameLength = fileName.length; | ||
|
|
||
| const maxFilenameLength = calculateMaxFilenameLength(); | ||
| const shortFileName = getShortFileName(fileName, maxFilenameLength); | ||
|
|
||
| let detailsText: React.ReactNode; | ||
|
|
||
| if (windowSize < 550 && fileNameLength <= 18) { | ||
| detailsText = ( | ||
| <> | ||
| {!isDetailPage ? shortFileName : fileName} / {fileSize} <br /> | ||
| ์ ๋ก๋๋ ๋ ์ง: {uploadDate.year}-{uploadDate.month}-{uploadDate.day} | ||
| </> | ||
| ); | ||
| } else if ( | ||
| (windowSize > 550 && fileNameLength >= 18) || | ||
| (windowSize < 550 && fileNameLength > 30) | ||
| ) { | ||
| detailsText = ( | ||
| <> | ||
| {!isDetailPage ? shortFileName : fileName} | ||
| <br /> | ||
| {fileSize} / ์ ๋ก๋๋ ๋ ์ง: {uploadDate.year}-{uploadDate.month}-{uploadDate.day} | ||
| </> | ||
| ); | ||
| } else { | ||
| detailsText = ( | ||
| <> | ||
| {!isDetailPage ? shortFileName : fileName} / {fileSize} / ์ ๋ก๋๋ ๋ ์ง: {uploadDate.year}- | ||
| {uploadDate.month}-{uploadDate.day} | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| return <>{detailsText}</>; | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| /** @jsxImportSource @emotion/react */ | ||
| import React from 'react'; | ||
|
|
||
| import { css } from '@emotion/react'; | ||
|
|
||
| import * as S from './styled'; | ||
| export interface SkeletonUIBoxProps { | ||
| randomWidth: string; | ||
| } | ||
|
|
||
| export const SkeletonUIBox: React.FC<SkeletonUIBoxProps> = ({ randomWidth }) => { | ||
| return ( | ||
| <S.SkeletonUIBoxElement | ||
| css={css` | ||
| min-width: ${randomWidth}rem; | ||
| `} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or 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,30 @@ | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| import { colors } from '@/styles'; | ||
|
|
||
| export const SkeletonUIBoxElement = styled.div` | ||
| display: flex; | ||
| background-color: ${colors.file}; | ||
| border-radius: 1rem; | ||
| margin-bottom: 1.5rem; | ||
| min-height: 3rem; | ||
| overflow: hidden; | ||
| &::before { | ||
| content: ' '; | ||
| width: 100%; | ||
| height: auto; | ||
| animation: loading 2s infinite; | ||
| box-shadow: 0 0 3rem 3rem rgba(255, 255, 255, 0.3); | ||
| } | ||
| @keyframes loading { | ||
| 0% { | ||
| transform: translateX(-50%); | ||
| } | ||
| 50% { | ||
| transform: translateX(100%); | ||
| } | ||
| 100% { | ||
| transform: translate(200%); | ||
| } | ||
| } | ||
| `; |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,5 +1,5 @@ | ||
| export * from './common'; | ||
| export * from './layouts'; | ||
| export * from './main'; | ||
| export * from './detail'; | ||
| export * from './apiList'; | ||
| export * from './list'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.