Skip to content

Commit

Permalink
add background
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Nelson committed Oct 3, 2023
1 parent c031947 commit 2cc8a8c
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/layouts/components/Background.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

<div class="">
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
<div class="dark:light-particle"></div>
</div>
5 changes: 4 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import Base from "@/layouts/Base.astro";
import Background from "@/components/Background.astro";
import { markdownify } from "@/lib/utils/textConverter";
import type { Button, Feature } from "@/types";
import { getEntryBySlug } from "astro:content";
Expand All @@ -22,13 +23,15 @@ const { title, meta_title, banner }: Homepage = homepage.data;
title={title}
meta_title={meta_title}
>
<Background />
<!-- Banner -->
<section class="section pt-14">
<section class="section pt-14 background-area">
<div class="container">
<div class="row justify-center">
<div class="mb-16 text-center lg:col-7">
<h1 set:html={markdownify(banner.title)} class="mb-4" />
<p set:html={markdownify(banner.content)} class="mb-8" />

</div>
</div>
</div>
Expand Down
84 changes: 84 additions & 0 deletions src/styles/background.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
$quantity: 32;

.light-particle {
position: fixed;
left: 50%;
top: 50%;
width: 0.4vw;
height: 0.4vw;
margin: -0.2vw 0 0 9.8vw;
animation: ease 200s alternate infinite;
pointer-events: none;

&::before,
&::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
transform-origin: -10vw;
}

&::before {
background: black;
opacity: 0;
animation: drift ease alternate infinite;
}

&::after {
background: white;
opacity: 0;
box-shadow: 0 0 0vw 0vw yellow;
animation: drift ease alternate infinite, flash ease infinite;
}
}

// Randomize Motion
@for $i from 1 through $quantity {
$steps: random(12) + 16;
$rotationSpeed: random(10) + 8s;

.light-particle:nth-child(#{$i}){
animation-name: move#{$i};

&::before {
animation-duration: #{$rotationSpeed};
}

&::after {
animation-duration: #{$rotationSpeed}, random(6000) + 5000ms;
animation-delay: 0ms, random(8000) + 500ms;
}
}

@keyframes move#{$i} {
@for $step from 0 through $steps {
#{$step * calc(100 / $steps)}% {
transform: translateX(random(100) - 50vw) translateY(random(100) - 50vh) scale(calc(random(75) / 100) + .25);
}
}
}

}

@keyframes drift {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

@keyframes flash {
0%, 30%, 100% {
opacity: 0;
box-shadow: 0 0 0vw 0vw yellow;
}
5% {
opacity: 1;
box-shadow: 0 0 2vw 0.4vw yellow;
}
}

2 changes: 1 addition & 1 deletion src/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ a:hover {

hr {
@apply dark:border-light;
}
}
1 change: 1 addition & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@import "components";
@import "navigation";
@import "buttons";
@import "background";
}

@layer utilities {
Expand Down

0 comments on commit 2cc8a8c

Please sign in to comment.