Skip to content

Commit 5371d27

Browse files
committed
feat(projects): 添加全局背景组件
1 parent 7be1cbf commit 5371d27

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

src/components/WaveBg.tsx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { getPaletteColorByNumber } from '@sa/color';
2+
3+
interface Props {
4+
/** Theme color */
5+
themeColor: string;
6+
}
7+
8+
const WaveBg = memo(({ themeColor }: Props) => {
9+
const lightColor = getPaletteColorByNumber(themeColor, 200);
10+
const darkColor = getPaletteColorByNumber(themeColor, 500);
11+
12+
return (
13+
<div className="absolute-lt z-1 size-full overflow-hidden">
14+
<div className="absolute -right-300px -top-900px lt-sm:(-right-100px -top-1170px)">
15+
<svg
16+
height="1337"
17+
width="1337"
18+
>
19+
<defs>
20+
<path
21+
d="M1337,668.5 C1337,1037.455193874239 1037.455193874239,1337 668.5,1337 C523.6725684305388,1337 337,1236 370.50000000000006,1094 C434.03835568300906,824.6732385973953 6.906089672974592e-14,892.6277623047779 0,668.5000000000001 C0,299.5448061257611 299.5448061257609,1.1368683772161603e-13 668.4999999999999,0 C1037.455193874239,0 1337,299.544806125761 1337,668.5Z"
22+
fillRule="evenodd"
23+
id="path-1"
24+
opacity="1"
25+
/>
26+
<linearGradient
27+
id="linearGradient-2"
28+
x1="0.79"
29+
x2="0.21"
30+
y1="0.62"
31+
y2="0.86"
32+
>
33+
<stop
34+
offset="0"
35+
stopColor={lightColor}
36+
stopOpacity="1"
37+
/>
38+
<stop
39+
offset="1"
40+
stopColor={darkColor}
41+
stopOpacity="1"
42+
/>
43+
</linearGradient>
44+
</defs>
45+
<g opacity="1">
46+
<use
47+
fill="url(#linearGradient-2)"
48+
fillOpacity="1"
49+
xlinkHref="#path-1"
50+
/>
51+
</g>
52+
</svg>
53+
</div>
54+
<div className="absolute -bottom-400px -left-200px lt-sm:(-bottom-760px -left-100px)">
55+
<svg
56+
height="896"
57+
width="967.8852157128662"
58+
>
59+
<defs>
60+
<path
61+
d="M896,448 C1142.6325445712241,465.5747656464056 695.2579309733121,896 448,896 C200.74206902668806,896 5.684341886080802e-14,695.2579309733121 0,448.0000000000001 C0,200.74206902668806 200.74206902668791,5.684341886080802e-14 447.99999999999994,0 C695.2579309733121,0 475,418 896,448Z"
62+
fillRule="evenodd"
63+
id="path-2"
64+
opacity="1"
65+
/>
66+
<linearGradient
67+
id="linearGradient-3"
68+
x1="0.5"
69+
x2="0.5"
70+
y1="0"
71+
y2="1"
72+
>
73+
<stop
74+
offset="0"
75+
stopColor={lightColor}
76+
stopOpacity="1"
77+
/>
78+
<stop
79+
offset="1"
80+
stopColor={darkColor}
81+
stopOpacity="1"
82+
/>
83+
</linearGradient>
84+
</defs>
85+
<g opacity="1">
86+
<use
87+
fill="url(#linearGradient-3)"
88+
fillOpacity="1"
89+
xlinkHref="#path-2"
90+
/>
91+
</g>
92+
</svg>
93+
</div>
94+
</div>
95+
);
96+
});
97+
98+
export default WaveBg;

0 commit comments

Comments
 (0)