Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 54 additions & 13 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SHOWCASED_FRAMEWORKS } from '~/utils/frameworks'

const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch()
const isSearchFocused = shallowRef(false)
const inputWrapperRef = useTemplateRef<HTMLDivElement>('inputWrapper')

async function search() {
flushUpdateUrlQuery()
Expand All @@ -24,6 +25,16 @@ defineOgImageComponent('Default', {
title: 'npmx',
description: 'a fast, modern browser for the **npm registry**',
})

function onMouseMove(event: MouseEvent) {
const inputWrapper = inputWrapperRef.value
if (!inputWrapper) return
const rect = inputWrapper.getBoundingClientRect()
const x = event.clientX - rect.left
const y = event.clientY - rect.top
inputWrapper.style.setProperty('--mouse-x', `${x}px`)
inputWrapper.style.setProperty('--mouse-y', `${y}px`)
}
Comment on lines +29 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I even touched this somewhere. Thanks for the tip ❤️

Let's see if we need this effect and if so I'll update it then

</script>

<template>
Expand Down Expand Up @@ -75,19 +86,25 @@ defineOgImageComponent('Default', {
/
</span>

<InputBase
id="home-search"
v-model="searchQuery"
type="search"
name="q"
autofocus
:placeholder="$t('search.placeholder')"
no-correct
size="large"
class="w-full ps-8 pe-24"
@focus="isSearchFocused = true"
@blur="isSearchFocused = false"
/>
<div
ref="inputWrapper"
class="home-input-wrapper relative w-full"
@mousemove="onMouseMove"
>
<InputBase
id="home-search"
v-model="searchQuery"
type="search"
name="q"
autofocus
:placeholder="$t('search.placeholder')"
no-correct
size="large"
class="w-full ps-8 pe-24 bg-bg-subtle/90! backdrop-blur-sm"
@focus="isSearchFocused = true"
@blur="isSearchFocused = false"
/>
</div>

<ButtonBase
type="submit"
Expand Down Expand Up @@ -141,4 +158,28 @@ defineOgImageComponent('Default', {
background-color: CanvasText;
}
}

.home-input-wrapper::before {
content: '';
@apply absolute -inset-0.5 rounded-[0.875rem] -z-1;
background: linear-gradient(
-80deg,
transparent 0%,
var(--accent) 5%,
var(--accent) 75%,
transparent 80%
);
background-size: 300% 100%;
background-position: var(--mouse-x, 0) var(--mouse-y, 0);
opacity: 0.5;
}

@keyframes glide {
0% {
background-position: 0 0;
}
100% {
background-position: -150% 0;
}
}
</style>
Loading