Skip to content

Commit 0b52b0f

Browse files
committed
호ㅏ이팅 ~~
0 parents  commit 0b52b0f

21 files changed

+16718
-0
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

README.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# 날씨 앱
2+
3+
Open-Meteo API를 사용하여 서울의 현재 날씨, 12시간 예보 및 7일 예보를 표시하는 React.js 날씨 애플리케이션입니다.
4+
5+
## 과제 내용
6+
현재 마크업과 API 호출은 구현되어 있어요!
7+
8+
- [ ] DailyForcast.js 컴포넌트 완성하기
9+
- [ ] CurrentWeather.js 컴포넌트 완성하기
10+
- [ ] HourlyForcast.js 컴포넌트 완성하기
11+
- [ ] utils/weather.js 내 데이터 포맷팅 함수 2개 완성하기
12+
13+
### 요렇게 만들기
14+
<img width="300" alt="image" src="https://github.com/user-attachments/assets/0552982d-b3b1-4092-828a-77d38ddaa1f6" />
15+
16+
## API 구조
17+
18+
다음 엔드포인트로 Open-Meteo API를 사용합니다:
19+
20+
```
21+
https://api.open-meteo.com/v1/forecast?latitude=37.566&longitude=126.9784&hourly=temperature_2m,weather_code&daily=weather_code,temperature_2m_max&timezone=Asia%2FTokyo&forecast_days=7
22+
```
23+
24+
### API 매개변수:
25+
- `latitude`, `longitude`: 서울 좌표 (37.566°N, 126.9784°E)
26+
- `hourly`: 시간별 날씨 데이터 포함:
27+
- `temperature_2m`: 섭씨 온도
28+
- `weather_code`: 날씨 상태 코드
29+
- `daily`: 일별 날씨 데이터 포함:
30+
- `weather_code`: 일별 날씨 상태 코드
31+
- `temperature_2m_max`: 일 최고 기온
32+
- `timezone`: Asia/Tokyo
33+
- `forecast_days`: 7일 예보
34+
35+
## 프로젝트 구조
36+
37+
```
38+
alom-08/README.md
39+
src/
40+
├── components/
41+
│ ├── CurrentWeather.js # 현재 날씨 표시
42+
│ ├── HourlyForecast.js # 12시간 예보
43+
│ └── DailyForecast.js # 7일 예보
44+
├── styles/
45+
│ └── StyledComponents.js # Styled-components 정의
46+
├── utils/
47+
│ └── weather.js # 날씨 데이터 처리 유틸리티
48+
└── App.js # 메인 애플리케이션 컴포넌트
49+
```
50+
51+
## 컴포넌트
52+
53+
### 1. CurrentWeather
54+
- 현재 기온과 날씨 상태 표시
55+
- Props: `weatherData`, `isLoading`
56+
57+
### 2. HourlyForecast
58+
- 12시간 날씨 예보를 가로로 표시
59+
- Props: `weatherData`
60+
- 각 시간별 시간, 기온, 날씨 상태 표시
61+
62+
### 3. DailyForecast
63+
- 7일 날씨 예보를 세로로 표시
64+
- Props: `weatherData`
65+
- 각 일자별 날짜, 날씨 상태, 기온 표시
66+
67+
## 유틸리티 함수
68+
69+
`utils/weather.js`에 위치:
70+
71+
### 1. getWeatherDescription(code)
72+
- 날씨 코드를 한글 설명으로 변환
73+
- 입력: 날씨 코드 (숫자)
74+
- 출력: 한글 날씨 설명 (문자열)
75+
76+
### 2. formatHourlyData(weatherData)
77+
- API 원시 데이터를 시간별 예보 형식으로 처리
78+
- 입력: API 날씨 데이터
79+
- 출력: 12시간 예보 배열:
80+
- 시간 (시 형식)
81+
- 기온
82+
- 날씨 코드
83+
84+
### 3. formatDailyData(weatherData)
85+
- API 원시 데이터를 일별 예보 형식으로 처리
86+
- 입력: API 날씨 데이터
87+
- 출력: 7일 예보 배열:
88+
- 날짜 (한국어 형식)
89+
- 날씨 코드
90+
- 기온
91+
92+
## 스타일링
93+
94+
styled-components를 사용한 스타일링:
95+
- 반응형 레이아웃
96+
- 그라데이션 배경
97+
- 반투명 예보 컨테이너
98+
99+
## 날씨 코드
100+
101+
날씨 상태는 다음과 같은 한글 설명으로 매핑됩니다:
102+
103+
```
104+
{
105+
0: "맑음",
106+
1: "대체로 맑음",
107+
2: "부분적으로 흐림",
108+
3: "흐림",
109+
45: "안개",
110+
48: "짙은 안개",
111+
51: "약한 이슬비",
112+
53: "보통 이슬비",
113+
55: "강한 이슬비",
114+
61: "약한 비",
115+
63: "보통 비",
116+
65: "강한 비",
117+
71: "약한 눈",
118+
73: "보통 눈",
119+
75: "강한 눈"
120+
}
121+
```
122+
123+
## 힌트
124+
125+
### 1. API 호출
126+
127+
```
128+
// App.js에서 API 호출 구현
129+
130+
useEffect(() => {
131+
fetch(API_URL)
132+
.then((response) => response.json())
133+
.then((data) => {
134+
setWeatherData(data);
135+
setIsLoading(false);
136+
})
137+
.catch((error) => {
138+
console.error("Error fetching weather data:", error);
139+
setIsLoading(false);
140+
});
141+
}, []);
142+
```
143+
144+
### 2. 날씨 코드 매핑
145+
```
146+
// utils/weather.js에서 상수 매핑 구현
147+
148+
const weatherCodes = {
149+
0: "맑음",
150+
1: "대체로 맑음",
151+
2: "부분적으로 흐림",
152+
// ... 기타 날씨 코드
153+
};
154+
155+
// 매핑 함수
156+
export const getWeatherDescription = (code) => {
157+
return weatherCodes[code] || "알 수 없음";
158+
};
159+
```

0 commit comments

Comments
 (0)