File tree Expand file tree Collapse file tree
components/stateless/StarBackground Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React , { useEffect , useState } from 'react'
2+ import styles from './index.module.less'
3+ // 生成随机阴影值的函数
4+ const generateBoxShadow = ( n ) => {
5+ let shadowValues = [ ]
6+ for ( let i = 0 ; i < n ; i ++ ) {
7+ const randomX = Math . floor ( Math . random ( ) * 2000 )
8+ const randomY = Math . floor ( Math . random ( ) * 2000 )
9+ shadowValues . push ( `${ randomX } px ${ randomY } px #333` )
10+ }
11+ return shadowValues . join ( ', ' )
12+ }
13+ const StarBack = ( ) => {
14+ const [ smallShadows ] = useState ( generateBoxShadow ( 1400 ) )
15+ const [ mediumShadows ] = useState ( generateBoxShadow ( 400 ) )
16+ const [ bigShadows ] = useState ( generateBoxShadow ( 200 ) )
17+ return (
18+ < section className = "absolute top-0 left-0" >
19+ < section className = { styles . stars } style = { { '--box-shadow' : smallShadows } } > </ section >
20+ < section className = { styles . medium } style = { { '--box-shadow' : mediumShadows } } > </ section >
21+ < section className = { styles . big } style = { { '--box-shadow' : bigShadows } } > </ section >
22+ </ section >
23+ )
24+ }
25+
26+ export default StarBack
Original file line number Diff line number Diff line change 1+ .stars {
2+ --box-shadow : 0 0 10px 1px rgb (255 255 255 / 50% );
3+
4+ width : 1px ;
5+ height : 1px ;
6+ border-radius : 100% ;
7+ background : transparent ;
8+ box-shadow : var (--box-shadow );
9+ animation : anim- star 50s linear infinite ;
10+
11+ & ::after {
12+ content : ' ' ;
13+ position : absolute ;
14+ top : 2000px ;
15+ width : 1px ;
16+ height : 1px ;
17+ border-radius : 100% ;
18+ box-shadow : var (--box-shadow );
19+ background : transparent ;
20+ }
21+ }
22+
23+ .medium {
24+ --box-shadow : 0 0 10px 1px rgb (255 255 255 / 50% );
25+
26+ width : 2px ;
27+ height : 2px ;
28+ border-radius : 100% ;
29+ background : transparent ;
30+ box-shadow : var (--box-shadow );
31+ animation : anim- star 150s linear infinite ;
32+
33+ & ::after {
34+ content : ' ' ;
35+ position : absolute ;
36+ top : 2000px ;
37+ width : 2px ;
38+ height : 2px ;
39+ border-radius : 100% ;
40+ box-shadow : var (--box-shadow );
41+ background : transparent ;
42+ }
43+ }
44+
45+ .big {
46+ --box-shadow : 0 0 10px 1px rgb (255 255 255 / 50% );
47+
48+ width : 3px ;
49+ height : 3px ;
50+ border-radius : 100% ;
51+ background : transparent ;
52+ box-shadow : var (--box-shadow );
53+ animation : anim- star 30s linear infinite ;
54+
55+ & ::after {
56+ content : ' *' ;
57+ position : absolute ;
58+ top : 2000px ;
59+ width : 3px ;
60+ height : 3px ;
61+ border-radius : 100% ;
62+ box-shadow : var (--box-shadow );
63+ background : transparent ;
64+ }
65+ }
66+
67+ @keyframes anim- star {
68+ from {
69+ transform : translateY (-2000px );
70+ }
71+
72+ to {
73+ transform : translateY (0 );
74+ }
75+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import AnimationTabs from '@stateless/AnimationTabs'
55import LogoSlider from '@stateless/LogoSlider'
66import FloatingIcon , { SocialIcon } from '@stateless/FloatingIcon'
77import Footer from '@stateless/Footer'
8+ import StarBack from '@stateless/StarBackground'
89
910import StickyCard from '@stateless/StickyCard'
1011import SpringPng from '@assets/images/spring.png'
@@ -85,6 +86,7 @@ const tabs = [
8586const ProDemo = ( ) => {
8687 return (
8788 < FixTabPanel >
89+ < StarBack />
8890 < StickyCard cards = { [ ...Array . from ( { length : 4 } , ( ) => ( { id : Math . random ( ) } ) ) ] } />
8991 < div className = "relative w-full overflow-hidden bg-[#0a192f]" >
9092 < div className = "absolute top-0 right-0 h-full w-1/2" >
You can’t perform that action at this time.
0 commit comments