-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ 4주차 기본/심화 과제 ] 비니의 날씨 입니다 #9
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8c943cd
init: 초기 설치
eunbeann 2c216e2
feat: yarn 설치
eunbeann 004aab4
styles: 샘플 컨텐츠 삭제
eunbeann 7649446
chore: styled-component 설치
eunbeann d85b48e
styles: GlobalStyles 설정
eunbeann e0cd6bf
styled: styled-reset 설치
eunbeann 030a4ef
styles: 전역 스타일 설정 (GlobalStyles, styled-reset)
eunbeann 1135b8c
chore: 날씨 이미지 상수 데이터 추가
eunbeann 013f743
design: header 뷰 짜기
eunbeann de0ae0d
design: 서칭바 뷰 제작
eunbeann 3971ee4
desing:날씨 섹션 뷰 제작
eunbeann 9a279a9
desgin: 전역 테마 색 수정, 폰트 수정
eunbeann f16e9a4
style: MainPage 렌더링
eunbeann 9c07f43
chore:react-router-dom 설치
eunbeann eb67cc2
sttyles: 스타일드컴포넌트 형식 바꾸기 St.~
eunbeann 67ce2a5
feat: Error 페이지 추가
eunbeann 62b2ae8
styles; day뷰 분리
eunbeann 37d1363
feat: day 불러온 데이터 띄워주기
eunbeann 486b116
styles: Week 뷰 분리 작성
eunbeann bb437fe
feat: Week 데이터 불러오기
eunbeann a061f65
styles: 각 날씨 내부 헤더 일반 태그로 변경
eunbeann 174322c
feat: 검색할 때 day/:area로 보이게
eunbeann f07343b
feat:select 박스에 기능 추가 + 일간 주간 선택
eunbeann d49875d
feat: 기본 과제 끝!
eunbeann f01e8c6
styles:서치바 태그 수정으로 가독성 개선
eunbeann f3af660
style:placeholder 스타일 추가
eunbeann e7509c4
feat: 검색창에 value 남기기
eunbeann 0ca15fb
feat: skeletone 추가
eunbeann 9e73472
styles: 스타일 정렬
eunbeann 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 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,2 @@ | ||
# VITE_APP_WEATHER='587bd6b133db966f6015b13ee1898879';//언니꺼 | ||
VITE_APP_WEATHER='fb02f9333a202901a648da747fc19542' #내꺼 | ||
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,15 @@ | ||
module.exports = { | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
], | ||
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, | ||
settings: { react: { version: '18.2' } }, | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': 'warn', | ||
}, | ||
} |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image" href="https://cdn-icons-png.flaticon.com/512/2570/2570524.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>비니의 날씨입니다</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
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,31 @@ | ||
{ | ||
"name": "weather-forecast", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.11.1", | ||
"styled-components": "^6.0.0-rc.1", | ||
"styled-reset": "^4.4.7", | ||
"yarn.lock": "^0.0.1-security" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"@vitejs/plugin-react": "^4.0.0", | ||
"eslint": "^8.38.0", | ||
"eslint-plugin-react": "^7.32.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.3.4", | ||
"vite": "^4.3.2" | ||
} | ||
} |
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,18 @@ | ||
import GlobalStyles from './styles/GlobalStyles.jsx' | ||
import { ThemeProvider } from 'styled-components' | ||
import theme from "./styles/theme"; | ||
import Router from "./Router"; | ||
|
||
function App() { | ||
|
||
return ( | ||
<> | ||
<ThemeProvider theme={theme}> | ||
<GlobalStyles /> | ||
<Router /> | ||
</ThemeProvider> | ||
</> | ||
) | ||
} | ||
|
||
export default App |
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 @@ | ||
import Main from './pages/Main' | ||
import { BrowserRouter, Route, Routes} from 'react-router-dom' | ||
import Error from './components/Error' | ||
import DayList from './pages/DayList' | ||
import DaySection from './components/DaySection' | ||
import WeekList from './pages/WeekList' | ||
import WeekSection from './components/WeekSection' | ||
|
||
const Router = () => { | ||
return ( | ||
<BrowserRouter> | ||
<Routes> | ||
<Route index element={<Main/>} /> | ||
<Route path="day" element={<DayList />}> | ||
<Route path=":area" element={<DaySection />}/> | ||
</Route> | ||
<Route path="week" element={<WeekList />}> | ||
<Route path=":area" element={<WeekSection />}/> | ||
</Route> | ||
<Route path="*" element={<Error/>} /> | ||
</Routes> | ||
</BrowserRouter> | ||
) | ||
} | ||
|
||
export default Router |
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,205 @@ | ||
import { styled } from 'styled-components' | ||
import { WEATHER_TYPE } from '../data/weatherImg' | ||
import axios from 'axios'; | ||
import { useState, useEffect } from 'react' | ||
import { useParams } from 'react-router-dom'; | ||
|
||
const DaySection = () => { | ||
const {area} = useParams(); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [dayWeather, setDayWeather] = useState( | ||
{ | ||
id: 0, | ||
name: "", | ||
weather: "", | ||
temp: 0.0, | ||
feels_like: 0.0, | ||
temp_min: 0.0, | ||
temp_max: 0.0, | ||
clouds: 0.0, | ||
}); | ||
|
||
const getDayWeather = async() => { | ||
// 일간 데이터 | ||
try{ | ||
setIsLoading(true); | ||
await axios | ||
.get(`https://api.openweathermap.org/data/2.5/weather?q=${area}&appid=${import.meta.env.VITE_APP_WEATHER}&units=metric`) | ||
.then((res) => res.data) | ||
.then((data)=> { | ||
if(data.cod == 200) { | ||
console.log(data) | ||
setDayWeather( | ||
{ | ||
id: 0, | ||
name: data.name, | ||
weather_description: data.weather[0].description, | ||
weather_img_url: WEATHER_TYPE.filter( | ||
(weather) => weather.description === data.weather[0].description | ||
)[0].imgURL, | ||
temp: data.main.temp, | ||
feels_like: data.main.feels_like, | ||
temp_min: data.main.temp_min, | ||
temp_max: data.main.temp_max, | ||
clouds: data.clouds.all, | ||
}) | ||
} | ||
}) | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
setIsLoading(false); | ||
} | ||
|
||
useEffect(() => { | ||
getDayWeather(); | ||
}, [area]) | ||
|
||
return ( | ||
<> | ||
{isLoading?( | ||
<> | ||
<St.MockCard> | ||
<h3 className='skeleton-title'></h3> | ||
<img className='skeleton-img'/> | ||
<div className='skeleton-div'> | ||
<span className='skeleton-span'> </span> | ||
<p className='skeleton-p'> </p> | ||
</div> | ||
</St.MockCard> | ||
</> | ||
):( | ||
<> | ||
<St.MockCard> | ||
<h3>{dayWeather.name}</h3> | ||
<img src={dayWeather.weather_img_url} alt={dayWeather.weather_description} /> | ||
<div> | ||
<span> 온도 </span> | ||
<p> {dayWeather.temp} </p> | ||
</div> | ||
<div> | ||
<span> 체감 온도 </span> | ||
<p> {dayWeather.feels_like}</p> | ||
</div> | ||
<div> | ||
<span> 최저 / 최고 </span> | ||
<p> {dayWeather.temp_max} / {dayWeather.temp_min} </p> | ||
</div> | ||
<div> | ||
<span> 구름 </span> | ||
<p> {dayWeather.clouds}% </p> | ||
</div> | ||
</St.MockCard> | ||
</> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default DaySection | ||
|
||
const St = { | ||
|
||
MockCard : styled.article ` | ||
display: flex; | ||
flex-flow: column wrap; | ||
justify-content: space-around; | ||
align-items: center; | ||
width: 24rem; | ||
height: 40rem; | ||
border-radius: 1rem; | ||
background-color: ${(props) => props.theme.muteGreen}; | ||
padding: 2rem 1rem; | ||
margin: 1rem; | ||
> h3 { | ||
height: fit-content; | ||
font-size: 4rem; | ||
color: ${(props) => props.theme.backgroundColor}; | ||
} | ||
> img { | ||
/* width: 17rem; */ | ||
height: 17rem; | ||
object-fit: contain; | ||
border-radius: 1rem; | ||
} | ||
> div { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 17rem; | ||
font-size: 2.3rem; | ||
font-weight: 600; | ||
>span { | ||
text-align: start; | ||
} | ||
>p { | ||
text-align: end; | ||
} | ||
} | ||
@keyframes skeleton-gradient { | ||
0% { | ||
background-color: rgba(165, 165, 165, 0.1); | ||
} | ||
50% { | ||
background-color: rgba(165, 165, 165, 0.3); | ||
} | ||
100% { | ||
background-color: rgba(165, 165, 165, 0.1); | ||
} | ||
} | ||
.skeleton-title { | ||
width: 12rem; | ||
height: 4rem; | ||
background: ${(props) => props.theme.lightgrey}; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.skeleton-title::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
animation: skeleton-gradient 1.5s infinite ease-in-out; | ||
} | ||
|
||
|
||
.skeleton-img { | ||
width: 14rem; | ||
height: 14rem; | ||
background: ${(props) => props.theme.lightgrey}; | ||
margin: 2rem 2rem; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.skeleton-img::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
animation: skeleton-gradient 1.5s infinite ease-in-out; | ||
} | ||
|
||
.skeleton-div { | ||
width: 14rem; | ||
height: 14rem; | ||
background: ${(props) => props.theme.lightgrey}; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.skeleton-div::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
animation: skeleton-gradient 1.5s infinite ease-in-out; | ||
} | ||
`, | ||
}; |
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,43 @@ | ||
import React from 'react' | ||
import PageLayout from './PageLayout' | ||
import { styled } from 'styled-components' | ||
|
||
const Error = () => { | ||
return ( | ||
<div> | ||
<PageLayout> | ||
<St.Error> | ||
<h1> | ||
Error 404 | ||
</h1> | ||
<p> | ||
주소가 잘못되진 않았나요? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 너무 친절하고 귀엽다ㅎㅎ |
||
</p> | ||
</St.Error> | ||
</PageLayout> | ||
</div> | ||
) | ||
} | ||
|
||
export default Error | ||
|
||
|
||
const St = { | ||
Error : styled.div ` | ||
margin-top: 10rem; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
width: 60vh; | ||
|
||
h1 { | ||
font-size:10rem; | ||
} | ||
|
||
p { | ||
font-size: 4rem; | ||
} | ||
` | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭐야 이거 왜 올라가잇어
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋㅋㅋㅋgitignore에 얼른 추가해줘