-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 피드페이지 기능 구현 완료_디자인 작업 중 (#10)
- Loading branch information
Showing
12 changed files
with
198 additions
and
14 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
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
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,61 @@ | ||
import { useRecoilState, useRecoilValue } from "recoil"; | ||
import { FeedContent } from "@/recoilAtom/FeedContents"; | ||
import { FeedFullcontents } from "@/recoilAtom/FeedFulldata"; | ||
import { useEffect, useState } from "react"; | ||
import "@/style/FeedSort.scss"; | ||
|
||
export default function FeedSort(){ | ||
|
||
const [feedata, setFeedd] = useRecoilState(FeedContent); | ||
const fullfeeddata = useRecoilValue(FeedFullcontents); | ||
console.log("정렬 컴포넌트로 넘어간 피드 데이터", feedata); | ||
const [sortType, setSortType] = useState<string>(''); | ||
|
||
const allcontents = () => { | ||
setFeedd(fullfeeddata); | ||
} | ||
|
||
const handleSort = (event: React.ChangeEvent<HTMLSelectElement>) => { | ||
setSortType(event.target.value); | ||
} | ||
|
||
const sortByLikes = () => { | ||
const sorted = [...feedata].sort((a, b) => b.likeCount - a.likeCount); | ||
setFeedd(sorted); | ||
}; | ||
|
||
const sortByNewest = () => { | ||
const sorted = [...feedata].sort((a, b) => b.boardId - a.boardId); | ||
setFeedd(sorted); | ||
}; | ||
|
||
const sortByOldest = () => { | ||
const sorted = [...feedata].sort((a, b) => a.boardId - b.boardId); | ||
setFeedd(sorted); | ||
}; | ||
|
||
useEffect(() => { | ||
if (sortType === '좋아요순') { | ||
sortByLikes(); | ||
} else if (sortType === '최신순') { | ||
sortByNewest(); | ||
} else if (sortType === '오래된순') { | ||
sortByOldest(); | ||
} | ||
}, [sortType]); | ||
|
||
return( | ||
<> | ||
<div className="sort_box"> | ||
<div> | ||
<button id="allview_btn" onClick={allcontents}>전체 보기</button> | ||
<select id="sortSelect_bar" onChange={handleSort}> | ||
<option>최신순</option> | ||
<option>좋아요순</option> | ||
<option>오래된순</option> | ||
</select> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
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,28 @@ | ||
import { atom } from "recoil"; | ||
|
||
interface IMAGE { | ||
boardId: number; | ||
imageId: number; | ||
imageUrl: string; | ||
} | ||
|
||
interface LIKE { | ||
likeId : number; | ||
nickName: string; | ||
} | ||
|
||
interface FEEDATA { | ||
boardId: number; | ||
images: IMAGE; | ||
likeCount: number; | ||
likelist: LIKE[]; | ||
nickName: string; | ||
temperature: number; | ||
weather: string; | ||
weatherIcon?: string; | ||
} | ||
|
||
export const FeedFullcontents = atom<FEEDATA[]>({ | ||
key: "fullcontents_key_dj", //전역적으로 유일한 값 | ||
default: [], | ||
}); |
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,20 @@ | ||
.sort_box{ | ||
display: flex; | ||
flex-direction: row-reverse; | ||
margin-top: 10px; | ||
} | ||
|
||
#allview_btn{ | ||
border-right: 2px dotted #A0A0A0; | ||
border-left: 2px dotted #A0A0A0; | ||
// border-radius: 15px; | ||
|
||
height: 25px; | ||
width: 83px; | ||
|
||
margin: 0 5px; | ||
} | ||
|
||
#sortSelect_bar{ | ||
background-color:transparent; | ||
} |
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,17 @@ | ||
.goto{ | ||
background-color: #a8bbff; | ||
color: white; | ||
|
||
border-radius: 4px; | ||
|
||
height: 30px; | ||
width: 20%; | ||
|
||
text-align: center; | ||
|
||
font-weight: bold; | ||
} | ||
|
||
#login_msg{ | ||
font-weight: bold; | ||
} |
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,8 +1,38 @@ | ||
#category_dj{ | ||
display: flex; | ||
margin-top: 5px; | ||
} | ||
|
||
#category_dj_box{ | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 5px 0; | ||
} | ||
|
||
.tab_menu_dj{ | ||
border: 2px solid #A0A0A0; | ||
border-radius: 15px; | ||
|
||
height: 30px; | ||
width: 83px; | ||
|
||
margin: 0 5px; | ||
text-align: center; | ||
} | ||
|
||
.tab_menu_dj span{ | ||
color: #D1CDCD; | ||
} | ||
|
||
#temcontrol_btn{ | ||
// background-color: #E5EBFF; | ||
color: #224863; | ||
|
||
border: 1px solid #5a88a9; | ||
border-radius: 10px; | ||
|
||
height: 30px; | ||
width: 80px; | ||
|
||
margin-top: 5px; | ||
} |