Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search UI polish #131

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions src/app/pages-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@
margin-right: max(1vw, 1rem);
}

.search-menu-result-link {
font-size: max(clamp(1.6625vh, 2.0625vw, 1.1875em), 3.75vh);
padding-left: max(0.2vh, 0.2vw);
padding-right: max(0.2vh, 0.2vw);
}

.search-menu-result-link h3 {
font-size: max(clamp(1.82875vh, 2.26875vw, 1.1875em), 4.125vh);
}

.search-menu-result-link mark {
background-color: hsl(var(--primary));
padding: 0 0.2em;
color: white;
}

@media only screen and (max-width: 1024px) {
.search-menu-tabslist-item {
height: max(4vw, 4vh);
Expand Down Expand Up @@ -110,6 +126,14 @@
font-size: max(clamp(1.45vh, 2.35vw, 1.1875em), max(2.35vh, 2.35vw));
}

.search-menu-result-link {
font-size: max(clamp(1.45vh, 2.35vw, 1.1875em), max(2.35vh, 2.35vw));
}

.search-menu-result-link h3 {
font-size: max(clamp(1.595vh, 2.585vw, 1.1875em), max(2.585vh, 2.585vw));
}

.search-menu-tabslist-item {
font-size: max(clamp(1.45vh, 2.35vw, 1.1875em), max(2.35vh, 2.35vw));
}
Expand All @@ -121,6 +145,14 @@
padding: clamp(3.90625vh, 5.15625vw, 1.1875em) clamp(1.5625vh, 2.0625vw, 1.1875em);
}

.search-menu-result-link {
font-size: max(clamp(2.9vh, 4.7vw, 1.1875em, max(4.7vh, 4.7vw)));
}

.search-menu-result-link h3 {
font-size: max(clamp(3.19vh, 5.17vw, 1.1875em, max(5.17vh, 5.17vw)));
}

.search-menu-tabslist-item {
font-size: max(clamp(2.9vh, 4.7vw, 1.1875em), max(4.7vh, 4.7vw));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ const NavbarSearchButtonInner = <AllTabValues extends typeof navbarSearchBtnProp
>
{prevScreenBtn}
<Tabs
onValueChange={(v) => updateMemorizedTabValueAndSetTabValue(v as TabValue)}
onValueChange={(v) => {
computeAndSetResults(searchText, tabValue, setResults);
updateMemorizedTabValueAndSetTabValue(v as TabValue);
}}
className="search-menu-gap-y flex w-full flex-col lg:px-5"
orientation={isLargeScreen ? 'horizontal' : 'vertical'}
value={tabValue}
Expand Down Expand Up @@ -311,7 +314,8 @@ const NavbarSearchButtonInner = <AllTabValues extends typeof navbarSearchBtnProp
</DialogHeader>
<div
className={cn('flex-1 rounded-md', {
'min-h-0 overflow-y-auto break-words border border-input px-2 [&>*>*]:pb-2 first:[&>*>*]:py-2': results !== null,
"min-h-0 overflow-y-auto break-words border border-input px-8 [&>*>*]:mb-8 first:[&>*>*]:my-8 last:[&>*>*]:after:block last:[&>*>*]:after:h-8 last:[&>*>*]:after:content-['']":
results !== null,
"after:block after:h-10 after:content-['']": searchText === SEARCH_TEXT_INITIAL_STATE
})}
>
Expand Down
17 changes: 14 additions & 3 deletions src/components/ui/search/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { usePathname } from 'next/navigation';
import { cn } from '@/lib/tailwind';
import Link from 'next/link';

import { CardContent, CardHeader, CardTitle, Card } from '../Card';

interface ResultProps extends Partial<WithClassname> {
metaTitle: string;
excerpt: string;
Expand All @@ -19,7 +21,8 @@ const Result: FunctionComponent<ResultProps> = ({ className, metaTitle, excerpt,
return (
<Link
className={cn(
'w-full',
'search-menu-result-link',
'flex h-full w-full flex-col transition-transform duration-300 hover:delay-0 hover:duration-100 focus:delay-0 focus:duration-100 dark:hover:brightness-125 dark:focus:brightness-125',
{
'pointer-events-none opacity-50': exactMatch
},
Expand All @@ -28,8 +31,16 @@ const Result: FunctionComponent<ResultProps> = ({ className, metaTitle, excerpt,
aria-current={exactMatch ? 'page' : undefined}
href={href}
>
<h3>{metaTitle}</h3>
<p dangerouslySetInnerHTML={{ __html: excerpt }} />
<Card className="overflow-hidden rounded shadow-lg transition-[box-shadow] duration-300 hover:shadow-xl focus:shadow-xl">
<CardHeader className="pb-2">
<CardTitle className="flex justify-between" titleType="h3">
{metaTitle}
</CardTitle>
</CardHeader>
<CardContent>
<p dangerouslySetInnerHTML={{ __html: excerpt }} />
</CardContent>
</Card>
</Link>
);
};
Expand Down