-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: remove sass dependency * style: add more stars to fill empty spaces * chore: optimize stars
- Loading branch information
Showing
8 changed files
with
118 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,129 @@ | ||
import styled from "styled-components"; | ||
import "~/assets/css/stars.sass"; | ||
|
||
const StarsContainer = styled.div` | ||
const getRandomInt = (max: number) => { | ||
return Math.floor(Math.random() * max); | ||
}; | ||
|
||
const generateStars = (stars: number) => { | ||
const width = 2000; | ||
const height = 4000; | ||
|
||
let shadows = `${getRandomInt(width)}px ${getRandomInt(height)}px #fff`; | ||
for (let index = 0; index < stars; index++) { | ||
shadows = `${shadows}, ${getRandomInt(width)}px ${getRandomInt( | ||
height | ||
)}px #fff`; | ||
} | ||
return shadows; | ||
}; | ||
|
||
export interface StarsContainerProps { | ||
smStars: number; | ||
mdStars: number; | ||
lgStars: number; | ||
} | ||
|
||
const StarsContainer = styled.div<StarsContainerProps>` | ||
position: relative; | ||
width: 100%; | ||
top: 0; | ||
left: 0; | ||
& .stars { | ||
width: 0.1rem; | ||
height: 0.1rem; | ||
box-shadow: ${(props) => generateStars(props.smStars)}; | ||
animation: animStar ${getRandomInt(2000) + 1000}ms linear infinite; | ||
z-index: 100; | ||
} | ||
& .stars1 { | ||
width: 0.1rem; | ||
height: 0.1rem; | ||
box-shadow: ${(props) => generateStars(props.smStars)}; | ||
animation: animStar ${getRandomInt(2000) + 1000}ms linear infinite; | ||
z-index: 100; | ||
} | ||
& .stars2 { | ||
width: 0.1rem; | ||
height: 0.1rem; | ||
box-shadow: ${(props) => generateStars(props.smStars)}; | ||
animation: animStar ${getRandomInt(2000) + 1000}ms linear infinite; | ||
z-index: 100; | ||
} | ||
& .stars3 { | ||
width: 0.1rem; | ||
height: 0.1rem; | ||
box-shadow: ${(props) => generateStars(props.smStars)}; | ||
animation: animStar ${getRandomInt(2000) + 1000}ms linear infinite; | ||
z-index: 100; | ||
} | ||
& .stars4 { | ||
width: 0.1rem; | ||
height: 0.1rem; | ||
box-shadow: ${(props) => generateStars(props.smStars)}; | ||
animation: animStar ${getRandomInt(2000) + 1000}ms linear infinite; | ||
z-index: 100; | ||
} | ||
& .stars5 { | ||
width: 0.2rem; | ||
height: 0.2rem; | ||
background: transparent; | ||
box-shadow: ${(props) => generateStars(props.mdStars)}; | ||
animation: animStar 1213ms linear infinite; | ||
} | ||
& .stars6 { | ||
width: 0.3rem; | ||
height: 0.3rem; | ||
background: transparent; | ||
box-shadow: ${(props) => generateStars(props.lgStars)}; | ||
animation: animStar2 747ms linear infinite; | ||
} | ||
& div { | ||
border-radius: 100%; | ||
} | ||
@keyframes animStar { | ||
0% { | ||
opacity: 0.1; | ||
} | ||
50% { | ||
opacity: 0.7; | ||
} | ||
100% { | ||
opacity: 0.1; | ||
} | ||
} | ||
@keyframes animStar2 { | ||
0% { | ||
opacity: 0.5; | ||
} | ||
50% { | ||
opacity: 0.1; | ||
} | ||
100% { | ||
opacity: 0.5; | ||
} | ||
} | ||
`; | ||
|
||
export function StarsBackground() { | ||
return ( | ||
<StarsContainer> | ||
<div id="stars"></div> | ||
<div id="stars1"></div> | ||
<div id="stars2"></div> | ||
<div id="stars3"></div> | ||
<StarsContainer smStars={700} mdStars={700} lgStars={50}> | ||
<div className="stars"></div> | ||
<div className="stars1"></div> | ||
<div className="stars2"></div> | ||
<div className="stars3"></div> | ||
<div className="stars4"></div> | ||
<div className="stars5"></div> | ||
<div className="stars6"></div> | ||
</StarsContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.