Final cmd-k adjustments

This commit is contained in:
Sam Becker 2024-02-21 18:01:34 -06:00
parent fdd02f1978
commit 79248a17f2
4 changed files with 14 additions and 4 deletions

View File

@ -32,9 +32,11 @@ export type CommandKSection = {
export default function CommandKClient({ export default function CommandKClient({
onQueryChange, onQueryChange,
sections = [], sections = [],
footer,
}: { }: {
onQueryChange?: (query: string) => Promise<CommandKSection[]> onQueryChange?: (query: string) => Promise<CommandKSection[]>
sections?: CommandKSection[] sections?: CommandKSection[]
footer?: string
}) { }) {
const { const {
isCommandKOpen: isOpen, isCommandKOpen: isOpen,
@ -231,6 +233,10 @@ export default function CommandKClient({
</div> </div>
</Command.Item>)} </Command.Item>)}
</Command.Group>)} </Command.Group>)}
{footer && !queryLive &&
<div className="text-center text-dim pt-3 sm:pt-4">
{footer}
</div>}
</Command.List> </Command.List>
</div> </div>
</Modal> </Modal>

View File

@ -1,5 +1,6 @@
import CommandKClient, { CommandKSection } from '@/components/CommandKClient'; import CommandKClient, { CommandKSection } from '@/components/CommandKClient';
import { import {
getPhotosCountCached,
getUniqueCamerasCached, getUniqueCamerasCached,
getUniqueFilmSimulationsCached, getUniqueFilmSimulationsCached,
getUniqueTagsCached, getUniqueTagsCached,
@ -17,7 +18,7 @@ import {
import { formatCameraText } from '@/camera'; import { formatCameraText } from '@/camera';
import { authCached } from '@/auth/cache'; import { authCached } from '@/auth/cache';
import { getPhotos } from '@/services/vercel-postgres'; import { getPhotos } from '@/services/vercel-postgres';
import { titleForPhoto } from '@/photo'; import { photoQuantityText, titleForPhoto } from '@/photo';
import PhotoTiny from '@/photo/PhotoTiny'; import PhotoTiny from '@/photo/PhotoTiny';
import { formatDate } from '@/utility/date'; import { formatDate } from '@/utility/date';
import { formatCount, formatCountDescriptive } from '@/utility/string'; import { formatCount, formatCountDescriptive } from '@/utility/string';
@ -31,10 +32,12 @@ import { HiDocumentText } from 'react-icons/hi';
export default async function CommandK() { export default async function CommandK() {
const [ const [
count,
tags, tags,
cameras, cameras,
filmSimulations, filmSimulations,
] = await Promise.all([ ] = await Promise.all([
getPhotosCountCached().catch(() => 0),
getUniqueTagsCached().catch(() => []), getUniqueTagsCached().catch(() => []),
getUniqueCamerasCached().catch(() => []), getUniqueCamerasCached().catch(() => []),
getUniqueFilmSimulationsCached().catch(() => []), getUniqueFilmSimulationsCached().catch(() => []),
@ -119,7 +122,7 @@ export default async function CommandK() {
]} ]}
onQueryChange={async (query) => { onQueryChange={async (query) => {
'use server'; 'use server';
const photos = (await getPhotos({ title: query })) const photos = (await getPhotos({ title: query, limit: 10 }))
.filter(({ title }) => Boolean(title)); .filter(({ title }) => Boolean(title));
return photos.length > 0 return photos.length > 0
? [{ ? [{
@ -134,5 +137,6 @@ export default async function CommandK() {
}] }]
: []; : [];
}} }}
footer={photoQuantityText(count, false)}
/>; />;
} }

View File

@ -59,7 +59,7 @@ export default function NavClient({
'w-full min-h-[4rem]', 'w-full min-h-[4rem]',
'leading-none', 'leading-none',
)}> )}>
<div className="flex flex-grow items-center gap-4"> <div className="flex-grow">
<ViewSwitcher <ViewSwitcher
currentSelection={switcherSelectionForPath()} currentSelection={switcherSelectionForPath()}
showAdmin={showAdmin} showAdmin={showAdmin}

View File

@ -19,7 +19,7 @@ export default function ViewSwitcher({
const { setIsCommandKOpen } = useAppState(); const { setIsCommandKOpen } = useAppState();
return ( return (
<div className="flex gap-2"> <div className="flex gap-1 sm:gap-2">
<Switcher> <Switcher>
<SwitcherItem <SwitcherItem
icon={<IconFullFrame />} icon={<IconFullFrame />}