Skip to content

Commit

Permalink
interaction improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Tropix126 committed Jan 12, 2024
1 parent f0da6f1 commit 0425fab
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 13 deletions.
13 changes: 12 additions & 1 deletion src/components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
padding-inline: 24px;
padding-block: 12px;
gap: 8px;
border: none;
outline: none;
/* text-transform: uppercase; */
transition: 0.15s ease;
}
Expand All @@ -58,6 +58,17 @@
color: var(--background-primary);
}
.button.variant-accent-yellow:active,
.button.variant-accent-red:active {
background-color: #fff;
color: var(--background-primary);
}
.button:focus {
outline: 2px solid var(--foreground-secondary);
outline-offset: 2px;
}
.button.disabled {
cursor: not-allowed;
opacity: 0.6;
Expand Down
60 changes: 60 additions & 0 deletions src/components/CircuitsPattern.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script lang="ts">
let element: HTMLElement | null = null;
let mouse = {
x: 0,
y: 0,
};
function handleMouseMove({ target, clientX, clientY }: MouseEvent) {
let rect = element?.getBoundingClientRect();
if (rect && clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom) {
mouse = {
x: clientX - rect.left,
y: clientY - rect.top
};
}
}
</script>

<svelte:window on:mousemove={handleMouseMove} />

<div class="circuits-mask" bind:this={element} role="presentation">
<div class="circuits-pattern" style:--mouse-x="{mouse.x}px" style:--mouse-y="{mouse.y}px"></div>
</div>

<style>
.circuits-mask {
mask: linear-gradient(#000, transparent);
overflow: hidden;
contain: strict;
position: absolute;
inline-size: 100%;
block-size: 100%;
inset: 0;
z-index: -1;
}
.circuits-pattern {
position: relative;
inline-size: 100%;
block-size: 100%;
background-image: linear-gradient(hsl(var(--base-hue), 12%, 30%), var(--background-secondary), transparent);
mask: url("/images/pattern_circuits.svg");
}
.circuits-pattern::after {
content: "";
position: absolute;
left: var(--mouse-x);
top: var(--mouse-y);
transform: translate(-50%, -50%);
transition: 150ms ease;
opacity: 0.25;
background-image: radial-gradient(var(--foreground-secondary), transparent 50%);
inline-size: 100vw;
block-size: 100vw;
border-radius: 50%;
}
</style>
5 changes: 5 additions & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ const {
box-sizing: border-box;
}

:focus-visible {
outline: 2px solid var(--foreground-secondary);
outline-offset: 2px;
}

code {
font-family: var(--font-monospace);
}
Expand Down
29 changes: 17 additions & 12 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import { GITHUB_REPO_URL } from "~/config";
import BaseLayout from "~/layouts/BaseLayout.astro";
import Button from "~/components/Button.svelte";
import PageSection from "~/components/PageSection.astro";
import Button from "~/components/Button.svelte";
import CircuitsPattern from "~/components/CircuitsPattern.svelte";
---

<BaseLayout>
Expand Down Expand Up @@ -33,7 +35,9 @@ import PageSection from "~/components/PageSection.astro";
<div class="hero-right">

</div>
<div class="background-pattern" slot="outer"></div>
<Fragment slot="outer">
<CircuitsPattern client:load />
</Fragment>
</PageSection>
</main>
</BaseLayout>
Expand All @@ -51,16 +55,6 @@ import PageSection from "~/components/PageSection.astro";
padding-block: 96px;
}

.background-pattern {
position: absolute;
inline-size: 100%;
block-size: 100%;
inset: 0;
background-image: linear-gradient(hsl(var(--base-hue), 12%, 30%), var(--background-secondary), transparent);
mask: url("/images/pattern_circuits.svg");
z-index: -1;
}

.title {
font-size: 7.2rem;
font-weight: 200;
Expand All @@ -76,6 +70,17 @@ import PageSection from "~/components/PageSection.astro";
color: var(--foreground-secondary);
}

.subtext a {
color: var(--foreground-accent-red);
text-decoration: none;
border-bottom: 1px solid currentColor;
transition: 250ms ease;
}

.subtext a:hover {
opacity: 0.8;
}

.hero-left,
.hero-right {
display: flex;
Expand Down

0 comments on commit 0425fab

Please sign in to comment.