-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[๐ฅ : feat] ํฌ์คํ
๊ฒ์ํ๊ธฐ (๋ฏธ์)
- Loading branch information
1 parent
ed4848b
commit aed21a1
Showing
7 changed files
with
119 additions
and
7 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
import { atom } from 'recoil'; | ||
|
||
export const searchKeywordAtom = atom({ | ||
key: 'searchKeyword', | ||
default: '', | ||
}); | ||
|
||
export const tmp = ''; |
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,54 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { | ||
collection, | ||
getDocs, | ||
limit, | ||
orderBy, | ||
query, | ||
where, | ||
} from 'firebase/firestore'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { db } from '../firebase.ts'; | ||
import Tweet from './tweet.tsx'; | ||
import TimelineWrapper from '../styles/timeline.ts'; | ||
import ITweet from '../interfaces/ITweet.ts'; | ||
import { searchKeywordAtom } from '../atoms.tsx'; | ||
|
||
export default function SearchTimeline() { | ||
const [tweets, setTweets] = useState<ITweet[]>([]); | ||
const searchKeyword = useRecoilValue(searchKeywordAtom); | ||
const fetchTweets = async () => { | ||
const tweetsQuery = query( | ||
collection(db, 'tweets'), | ||
orderBy('tweet'), | ||
where('tweet', '>=', searchKeyword), | ||
orderBy('createdAt', 'desc'), | ||
limit(25), | ||
); | ||
const snapshot = await getDocs(tweetsQuery); | ||
const tweetList = snapshot.docs.map((doc) => { | ||
const { userId, userName, tweet, createdAt, photo } = doc.data(); | ||
return { | ||
userId, | ||
userName, | ||
tweet, | ||
createdAt, | ||
photo, | ||
id: doc.id, | ||
}; | ||
}); | ||
setTweets(tweetList); | ||
}; | ||
useEffect(() => { | ||
fetchTweets(); | ||
}, [searchKeyword]); | ||
return ( | ||
<TimelineWrapper> | ||
{tweets.length !== 0 ? ( | ||
tweets.map((tweet) => <Tweet key={tweet.id} {...tweet} />) | ||
) : ( | ||
<p>๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค.</p> | ||
)} | ||
</TimelineWrapper> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import SearchTimeline from '../components/search-timeline.tsx'; | ||
import WindowTop from '../components/window-top.tsx'; | ||
import * as W from '../styles/window.ts'; | ||
|
||
export default function SearchResult() { | ||
return null; | ||
return ( | ||
<W.Window> | ||
<WindowTop /> | ||
<SearchTimeline /> | ||
</W.Window> | ||
); | ||
} |
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,12 +1,31 @@ | ||
import { styled } from 'styled-components'; | ||
import { Input } from './button.ts'; | ||
import { grayColor } from './global.ts'; | ||
|
||
export const Form = styled.form` | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
width: 100%; | ||
max-width: 500px; | ||
`; | ||
|
||
export const FormInput = styled(Input)``; | ||
export const FormInput = styled(Input)` | ||
padding-right: 50px; | ||
`; | ||
|
||
export const FormButton = styled.button` | ||
position: absolute; | ||
top: 3px; | ||
right: 3px; | ||
bottom: 3px; | ||
height: 37px; | ||
width: 37px; | ||
background-color: transparent; | ||
border-radius: 50%; | ||
border: none; | ||
svg { | ||
stroke: ${grayColor}; | ||
} | ||
`; |