Refine cmd-k menu on mobile
This commit is contained in:
parent
bea16bad60
commit
dea48609a6
@ -158,8 +158,7 @@ export default function CommandKClient({
|
|||||||
</div>
|
</div>
|
||||||
<Command.List className={clsx(
|
<Command.List className={clsx(
|
||||||
'relative overflow-y-scroll',
|
'relative overflow-y-scroll',
|
||||||
'h-36 sm:h-auto',
|
'max-h-48 sm:max-h-72',
|
||||||
'sm:max-h-72',
|
|
||||||
)}>
|
)}>
|
||||||
<Command.Empty className="mt-1 pl-3 text-dim">
|
<Command.Empty className="mt-1 pl-3 text-dim">
|
||||||
{isLoading ? 'Searching ...' : 'No results found'}
|
{isLoading ? 'Searching ...' : 'No results found'}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ReactNode, useEffect, useRef, useState } from 'react';
|
import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { clsx } from 'clsx/lite';
|
import { clsx } from 'clsx/lite';
|
||||||
import useClickInsideOutside from '@/utility/useClickInsideOutside';
|
import useClickInsideOutside from '@/utility/useClickInsideOutside';
|
||||||
@ -8,6 +8,7 @@ import { useRouter } from 'next/navigation';
|
|||||||
import AnimateItems from './AnimateItems';
|
import AnimateItems from './AnimateItems';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
import usePrefersReducedMotion from '@/utility/usePrefersReducedMotion';
|
import usePrefersReducedMotion from '@/utility/usePrefersReducedMotion';
|
||||||
|
import { useTheme } from 'next-themes';
|
||||||
|
|
||||||
export default function Modal({
|
export default function Modal({
|
||||||
onClosePath,
|
onClosePath,
|
||||||
@ -38,6 +39,19 @@ export default function Modal({
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const { resolvedTheme } = useTheme();
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (resolvedTheme === 'light') {
|
||||||
|
// Temporarily create meta tag for overlays in light mode,
|
||||||
|
// which prevents stale headers on theme changes
|
||||||
|
const meta = document.createElement('meta');
|
||||||
|
meta.name = 'theme-color';
|
||||||
|
meta.content = '#333';
|
||||||
|
document.getElementsByTagName('head')[0]?.appendChild(meta);
|
||||||
|
return () => meta.remove();
|
||||||
|
}
|
||||||
|
}, [resolvedTheme]);
|
||||||
|
|
||||||
useClickInsideOutside({
|
useClickInsideOutside({
|
||||||
htmlElements,
|
htmlElements,
|
||||||
onClickOutside: () => {
|
onClickOutside: () => {
|
||||||
@ -57,7 +71,7 @@ export default function Modal({
|
|||||||
className={clsx(
|
className={clsx(
|
||||||
'fixed inset-0 z-50 flex justify-center',
|
'fixed inset-0 z-50 flex justify-center',
|
||||||
anchor === 'top'
|
anchor === 'top'
|
||||||
? 'items-start pt-4 xs:pt-12 sm:pt-24'
|
? 'items-start pt-4 sm:pt-24'
|
||||||
: 'items-center',
|
: 'items-center',
|
||||||
'bg-black',
|
'bg-black',
|
||||||
)}
|
)}
|
||||||
@ -73,7 +87,7 @@ export default function Modal({
|
|||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
key="modalContent"
|
key="modalContent"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'w-[calc(100vw-1.5rem)] xs:w-[min(500px,90vw)]',
|
'w-[calc(100vw-1.5rem)] sm:w-[min(500px,90vw)]',
|
||||||
'p-3 rounded-lg',
|
'p-3 rounded-lg',
|
||||||
'md:p-4 md:rounded-xl',
|
'md:p-4 md:rounded-xl',
|
||||||
'bg-white dark:bg-black',
|
'bg-white dark:bg-black',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user