-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
1,081 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 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
const starsBoxShadow1 = buildBoxShadow(600) | ||
const starsBoxShadow2 = buildBoxShadow(200) | ||
const starsBoxShadow3 = buildBoxShadow(100) | ||
function buildBoxShadow(count: number) { | ||
let shadows = [] | ||
for (let index = 0; index < count; index++) { | ||
const x = Math.floor(Math.random() * 2000 - 1000) | ||
const y = Math.floor(Math.random() * 2000 - 1000) | ||
shadows.push(`${x}px ${y}px var(--theme-star)`) | ||
} | ||
return shadows.join(",") | ||
} | ||
--- | ||
|
||
<div class="stars-wrapper"> | ||
<div class="stars1 stars"></div> | ||
<div class="stars2 stars"></div> | ||
<div class="stars3 stars"></div> | ||
</div> | ||
|
||
<style | ||
define:vars={{ | ||
"stars-box-shadow1": starsBoxShadow1, | ||
"stars-box-shadow2": starsBoxShadow2, | ||
"stars-box-shadow3": starsBoxShadow3, | ||
}} | ||
> | ||
:root { | ||
--theme-star: var(--theme-text, #fff); | ||
} | ||
|
||
.stars-wrapper { | ||
position: absolute; | ||
pointer-events: none; | ||
z-index: 1000; | ||
} | ||
|
||
.stars { | ||
border-radius: 50%; | ||
background: transparent; | ||
|
||
position: relative; | ||
top: 0; | ||
left: 0; | ||
pointer-events: none; | ||
} | ||
.stars:after { | ||
border-radius: 50%; | ||
content: ""; | ||
position: absolute; | ||
top: 2000px; | ||
left: 500px; | ||
background: transparent; | ||
} | ||
@keyframes star { | ||
from { | ||
transform: translate(0, 0); | ||
} | ||
to { | ||
transform: translate(-500px, -2000px); | ||
} | ||
} | ||
.stars1 { | ||
width: 1px; | ||
height: 1px; | ||
animation: star 500s linear infinite; | ||
box-shadow: var(--stars-box-shadow1); | ||
} | ||
.stars1:after { | ||
width: 1px; | ||
height: 1px; | ||
box-shadow: var(--stars-box-shadow1); | ||
} | ||
.stars2 { | ||
width: 2px; | ||
height: 2px; | ||
animation: star 200s linear infinite; | ||
box-shadow: var(--stars-box-shadow2); | ||
} | ||
.stars2:after { | ||
width: 2px; | ||
height: 2px; | ||
box-shadow: var(--stars-box-shadow2); | ||
} | ||
.stars3 { | ||
width: 3px; | ||
height: 3px; | ||
animation: star 100s linear infinite; | ||
box-shadow: var(--stars-box-shadow3); | ||
} | ||
.stars3:after { | ||
width: 3px; | ||
height: 3px; | ||
box-shadow: var(--stars-box-shadow3); | ||
} | ||
</style> |
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.