mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 07:43:49 +01:00
feat: scroll to view home search
This commit is contained in:
1 parent
be7b00c4be
commit
5d6e864451
1 file changed
+13
-2
+13
-2
@@ -16,7 +16,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import { debounce } from 'lodash';
|
import { debounce, times } from 'lodash';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { Link } from '../components/Link';
|
import { Link } from '../components/Link';
|
||||||
import { NAVBAR_HEIGHT } from '../components/Navbar';
|
import { NAVBAR_HEIGHT } from '../components/Navbar';
|
||||||
@@ -148,8 +148,15 @@ export default function Page() {
|
|||||||
if (!search.current) return;
|
if (!search.current) return;
|
||||||
|
|
||||||
const sanitized = search.current.value.trim();
|
const sanitized = search.current.value.trim();
|
||||||
|
|
||||||
setShowSearch(sanitized.length > 0);
|
setShowSearch(sanitized.length > 0);
|
||||||
|
|
||||||
|
window.scrollTo({
|
||||||
|
top:
|
||||||
|
search.current.getBoundingClientRect().top -
|
||||||
|
NAVBAR_HEIGHT -
|
||||||
|
32,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextField.Slot>
|
<TextField.Slot>
|
||||||
@@ -345,6 +352,10 @@ export default function Page() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
{times(64, () => (
|
||||||
|
<br />
|
||||||
|
))}
|
||||||
|
|
||||||
<div style={{ flex: 1 }} />
|
<div style={{ flex: 1 }} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user