forked from openai/openai-assistants-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather-widget.tsx
44 lines (39 loc) · 1.09 KB
/
weather-widget.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from "react";
import styles from "./weather-widget.module.css";
const WeatherWidget = ({
location = "---",
temperature = "---",
conditions = "Sunny",
isEmpty = false,
}) => {
const conditionClassMap = {
Cloudy: styles.weatherBGCloudy,
Sunny: styles.weatherBGSunny,
Rainy: styles.weatherBGRainy,
Snowy: styles.weatherBGSnowy,
Windy: styles.weatherBGWindy,
};
if (isEmpty) {
return (
<div className={`${styles.weatherWidget} ${styles.weatherEmptyState}`}>
<div className={styles.weatherWidgetData}>
<p>Enter a city to see local weather</p>
<p>try: what's the weather like in Berkeley?</p>
</div>
</div>
);
}
const weatherClass = `${styles.weatherWidget} ${
conditionClassMap[conditions] || styles.weatherBGSunny
}`;
return (
<div className={weatherClass}>
<div className={styles.weatherWidgetData}>
<p>{location}</p>
<h2>{temperature !== "---" ? `${temperature}°F` : temperature}</h2>
<p>{conditions}</p>
</div>
</div>
);
};
export default WeatherWidget;