Skip to content

Commit 1d53a03

Browse files
committed
feat: mesh gradient background
1 parent 66818be commit 1d53a03

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react'
2+
import styles from './index.module.less'
3+
4+
const MeshGradientBackground = (props) => {
5+
return (
6+
<div style={{ position: 'relative', height: '100%' }}>
7+
<div className={styles.background}>Mesh Gradient Background</div>
8+
</div>
9+
)
10+
}
11+
export default MeshGradientBackground
12+
13+
// https://www.csshero.org/animator/
14+
// https://csshero.org/mesher/
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.background {
2+
position: absolute;
3+
top: 0;
4+
left: 0;
5+
width: 100%;
6+
height: 100%;
7+
background-color: #ff99df;
8+
background-image: radial-gradient(circle at 52% 73%, hsla(310, 85%, 67%, 1) 0px, transparent 50%),
9+
radial-gradient(circle at 0% 30%, hsla(197, 90%, 76%, 1) 0px, transparent 50%),
10+
radial-gradient(circle at 41% 26%, hsla(234, 79%, 69%, 1) 0px, transparent 50%),
11+
radial-gradient(circle at 41% 51%, hsla(41, 70%, 63%, 1) 0px, transparent 50%),
12+
radial-gradient(circle at 41% 88%, hsla(36, 83%, 61%, 1) 0px, transparent 50%),
13+
radial-gradient(circle at 76% 73%, hsla(346, 69%, 70%, 1) 0px, transparent 50%),
14+
radial-gradient(circle at 29% 37%, hsla(272, 96%, 64%, 1) 0px, transparent 50%);
15+
16+
background-size: 150% 150%;
17+
filter: blur(10px);
18+
animation: moveBackground 10s linear infinite;
19+
}
20+
21+
@keyframes moveBackground {
22+
0% {
23+
background-size: 100% 100%;
24+
}
25+
10% {
26+
background-size: 120% 80%;
27+
}
28+
20% {
29+
background-size: 190% 140%;
30+
}
31+
30% {
32+
background-size: 130% 110%;
33+
}
34+
40% {
35+
background-size: 150% 120%;
36+
}
37+
50% {
38+
background-size: 180% 100%;
39+
}
40+
60% {
41+
background-size: 220% 80%;
42+
}
43+
70% {
44+
background-size: 100% 50%;
45+
}
46+
80% {
47+
background-size: 120% 70%;
48+
}
49+
90% {
50+
background-size: 110% 90%;
51+
}
52+
100% {
53+
background-size: 100% 100%;
54+
}
55+
}

src/pages/home/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ScrollAnimation from '@stateless/ScrollAnimation'
2121
import AnimateOnScreen from '@stateless/AnimateOnScreen'
2222
import AnimateRipple from '@stateless/AnimateRipple'
2323
import AnimateWave from '@stateless/AnimateWave'
24+
import MeshGradientBackground from '@stateless/MeshGradientBackground'
2425

2526
import { oneApiChat, prettyObject } from '@utils/aidFn'
2627

@@ -217,13 +218,21 @@ const Home = () => {
217218
</>
218219
</AnimateOnScreen.ScaleIn>
219220
</section>
221+
<section style={{ marginBottom: 40, height: 200, width: 360, overflow: 'hidden' }}>
222+
<MeshGradientBackground />
223+
</section>
220224
<section style={{ marginBottom: 40 }}>
221225
<AnimateRipple>Click Me</AnimateRipple>
222226
</section>
223227
<section style={{ marginBottom: 40 }} className={styles.maskBox}>
224228
<section className={styles.watermark}>water mark</section>
225229
mask
226230
</section>
231+
<section style={{ marginBottom: 40 }}>
232+
<button className={styles['button']}>
233+
<span className={styles['button-label']}>Click Me</span>
234+
</button>
235+
</section>
227236

228237
<section style={{ width: 600, margin: '30px 0' }}>
229238
<Input defaultValue={apiKey} placeholder="api key" onChange={changeApiKey} style={{ marginBottom: 20 }} />
@@ -236,7 +245,7 @@ const Home = () => {
236245
onChange={changeChatText}
237246
onKeyDown={onInputKeyDown}
238247
autoSize
239-
style={{ width: 300, height: 30 }}
248+
style={{ width: 300, height: 30, caretColor: '#ff0000' }}
240249
/>
241250
</LinearWrap>
242251
<Button

src/pages/home/index.module.less

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,23 @@
6565
transform: translateY(50px);
6666
}
6767
}
68+
69+
.button {
70+
background: transparent;
71+
padding: 0.5rem 1rem;
72+
background-image: linear-gradient(90deg, white, white), linear-gradient(90deg, hsl(289, 65%, 64%), hsl(226, 78%, 67%));
73+
background-clip: padding-box, border-box;
74+
background-origin: border-box;
75+
border: 5px solid transparent;
76+
border-radius: 1.75rem;
77+
}
78+
79+
.button-label {
80+
background-image: linear-gradient(90deg, hsl(289, 65%, 64%), hsl(226, 78%, 67%));
81+
background-clip: text;
82+
-webkit-background-clip: text;
83+
color: transparent;
84+
font-weight: 600;
85+
font-size: 1.25rem;
86+
line-height: 1.5rem;
87+
}

0 commit comments

Comments
 (0)