天气 动图 接入
This commit is contained in:
23
src/components/Weather/WeatherCloudy.css
Normal file
23
src/components/Weather/WeatherCloudy.css
Normal file
@@ -0,0 +1,23 @@
|
||||
.cloud-group {
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.cloud {
|
||||
font-size: 45px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.cloud1 {
|
||||
left: 10px;
|
||||
animation: floatCloud 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.cloud2 {
|
||||
left: 60px;
|
||||
animation: floatCloud 4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes floatCloud {
|
||||
0%, 100% { transform: translateX(0); }
|
||||
50% { transform: translateX(10px); }
|
||||
}
|
||||
11
src/components/Weather/WeatherCloudy.jsx
Normal file
11
src/components/Weather/WeatherCloudy.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import "./WeatherCloudy.css";
|
||||
|
||||
export default function WeatherCloudy() {
|
||||
return (
|
||||
<div className="weather-box cloudy">
|
||||
<div className="cloud-group">
|
||||
<span className="cloud cloud1">☁️</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
23
src/components/Weather/WeatherRainy.css
Normal file
23
src/components/Weather/WeatherRainy.css
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
.cloud {
|
||||
font-size: 50px;
|
||||
position: absolute;
|
||||
top: 70px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.rain span {
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 20px;
|
||||
background: #4A90E2;
|
||||
margin: 0 2px;
|
||||
animation: rainDrop 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rainDrop {
|
||||
0% { transform: translateY(-10px); opacity: 0; }
|
||||
50% { opacity: 1; }
|
||||
100% { transform: translateY(30px); opacity: 0; }
|
||||
}
|
||||
14
src/components/Weather/WeatherRainy.jsx
Normal file
14
src/components/Weather/WeatherRainy.jsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import "./WeatherRainy.css";
|
||||
|
||||
export default function WeatherRainy() {
|
||||
return (
|
||||
<div className="weather-box rainy">
|
||||
<div className="cloud">☁️</div>
|
||||
<div className="rain">
|
||||
{[...Array(6)].map((_, i) => (
|
||||
<span key={i} style={{ animationDelay: `${i * 0.2}s` }}></span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
58
src/components/Weather/WeatherSunny.css
Normal file
58
src/components/Weather/WeatherSunny.css
Normal file
@@ -0,0 +1,58 @@
|
||||
.weather-sunny {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.sun {
|
||||
position: relative;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* 太阳核心 */
|
||||
.core {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: radial-gradient(circle, #FFEB3B, #FF9800);
|
||||
border-radius: 50%;
|
||||
box-shadow:
|
||||
0 0 30px #FFEB3B,
|
||||
0 0 60px rgba(255, 193, 7, 0.6);
|
||||
}
|
||||
|
||||
/* 光芒 */
|
||||
.ray {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 6px;
|
||||
height: 40px;
|
||||
background: linear-gradient(to top, #FFEB3B, transparent);
|
||||
transform-origin: center bottom;
|
||||
animation: rayPulse 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* 错开动画,形成波浪感 */
|
||||
.ray:nth-child(odd) {
|
||||
animation-delay: 0.75s;
|
||||
}
|
||||
|
||||
@keyframes rayPulse {
|
||||
0% {
|
||||
opacity: 0.3;
|
||||
transform: var(--transform) scaleY(0.8);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
transform: var(--transform) scaleY(1.2);
|
||||
}
|
||||
100% {
|
||||
opacity: 0.3;
|
||||
transform: var(--transform) scaleY(0.8);
|
||||
}
|
||||
}
|
||||
25
src/components/Weather/WeatherSunny.jsx
Normal file
25
src/components/Weather/WeatherSunny.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import "./WeatherSunny.css";
|
||||
|
||||
export default function WeatherSunny() {
|
||||
const rays = Array.from({ length: 12 }).map((_, i) => {
|
||||
const angle = i * 30; // 每根 30°
|
||||
return (
|
||||
<span
|
||||
key={i}
|
||||
className="ray"
|
||||
style={{
|
||||
transform: `rotate(${angle}deg) translateY(-120px)`
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="weather-sunny">
|
||||
<div className="sun">
|
||||
{/*{rays}*/}
|
||||
<div className="core"></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
23
src/components/Weather/index.jsx
Normal file
23
src/components/Weather/index.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import WeatherSunny from "./WeatherSunny";
|
||||
import WeatherRainy from "./WeatherRainy";
|
||||
import WeatherCloudy from "./WeatherCloudy";
|
||||
|
||||
export default function WeatherDisplay({ type }) {
|
||||
const map = {
|
||||
sunny: <WeatherSunny />,
|
||||
rainy: <WeatherRainy />,
|
||||
cloudy: <WeatherCloudy />
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="weather-icon-wrapper">
|
||||
{map[type] || null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
WeatherDisplay.propTypes = {
|
||||
type: PropTypes.oneOf(["sunny", "rainy", "cloudy"])
|
||||
};
|
||||
Reference in New Issue
Block a user