Skip to content

Commit 35afcee

Browse files
committed
chore: update home search effect
1 parent 360e92d commit 35afcee

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

app/pages/index.vue

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SHOWCASED_FRAMEWORKS } from '~/utils/frameworks'
33
44
const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch()
55
const isSearchFocused = shallowRef(false)
6+
const inputWrapperRef = useTemplateRef<HTMLDivElement>('inputWrapper')
67
78
async function search() {
89
flushUpdateUrlQuery()
@@ -24,6 +25,16 @@ defineOgImageComponent('Default', {
2425
title: 'npmx',
2526
description: 'a fast, modern browser for the **npm registry**',
2627
})
28+
29+
function onMouseMove(event: MouseEvent) {
30+
const inputWrapper = inputWrapperRef.value
31+
if (!inputWrapper) return
32+
const rect = inputWrapper.getBoundingClientRect()
33+
const x = event.clientX - rect.left
34+
const y = event.clientY - rect.top
35+
inputWrapper.style.setProperty('--mouse-x', `${x}px`)
36+
inputWrapper.style.setProperty('--mouse-y', `${y}px`)
37+
}
2738
</script>
2839

2940
<template>
@@ -75,7 +86,11 @@ defineOgImageComponent('Default', {
7586
/
7687
</span>
7788

78-
<div class="home-input-wrapper relative w-full">
89+
<div
90+
ref="inputWrapper"
91+
class="home-input-wrapper relative w-full"
92+
@mousemove="onMouseMove"
93+
>
7994
<InputBase
8095
id="home-search"
8196
v-model="searchQuery"
@@ -147,19 +162,22 @@ defineOgImageComponent('Default', {
147162
.home-input-wrapper {
148163
&::before {
149164
content: '';
150-
@apply absolute -inset-0.5 rounded-xl -z-1;
151-
animation: glide 1s 0.8s ease-in-out;
165+
@apply absolute -inset-0.5 rounded-[0.875rem] -z-1;
152166
background: linear-gradient(
153-
-30deg,
154-
transparent 40%,
155-
var(--accent) 41%,
156-
var(--accent) 59%,
157-
transparent 60%
167+
-80deg,
168+
transparent 0%,
169+
var(--accent) 5%,
170+
var(--accent) 75%,
171+
transparent 80%
158172
);
159173
background-size: 300% 100%;
160-
background-position: -150% 0;
174+
background-position: var(--mouse-x, 0) var(--mouse-y, 0);
161175
opacity: 0.5;
162176
}
177+
178+
input {
179+
@apply bg-bg-subtle/90 backdrop-blur-sm;
180+
}
163181
}
164182
165183
@keyframes glide {

0 commit comments

Comments
 (0)