Skip to content

Commit c0975c2

Browse files
committed
add search and update active navigation color
1 parent 4bdd057 commit c0975c2

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

app/[locale]/dashboard/components/main-nav.tsx

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,28 @@
33
import React from 'react';
44
import Image from 'next/image';
55
import Link from 'next/link';
6+
import { usePathname } from 'next/navigation';
67
import { useMetaKeyPress } from '@/hooks/use-meta-key-press';
78
import { Session } from 'next-auth';
89
import { signIn, signOut, useSession } from 'next-auth/react';
910
import {
1011
Avatar,
1112
Button,
13+
CommandDialog,
14+
CommandEmpty,
15+
CommandGroup,
16+
CommandInput,
17+
CommandItem,
18+
CommandList,
1219
Divider,
1320
IconButton,
1421
Popover,
22+
SearchInput,
1523
Spinner,
1624
Text,
1725
} from 'opub-ui';
1826

27+
import { Icons } from '@/components/icons';
1928
import Sidebar from './sidebar';
2029

2130
const profileLinks = [
@@ -26,6 +35,8 @@ const profileLinks = [
2635
];
2736

2837
export function MainNav({ hideSearch = false }) {
38+
const pathname = usePathname();
39+
2940
const [isLoggingOut, setIsLoggingOut] = React.useState(false);
3041
const searchRef = React.useRef<HTMLInputElement>(null);
3142
const { data: session, status } = useSession();
@@ -85,7 +96,9 @@ export function MainNav({ hideSearch = false }) {
8596
</div>
8697
<Link href="/">
8798
<div className="flex items-center gap-2">
88-
<Image src={'/logo.png'} width={38} height={38} alt="logo" />
99+
<div className="group relative h-[38px] w-[38px] overflow-hidden">
100+
<Image src={'/logo.png'} width={38} height={38} alt="logo" />
101+
</div>
89102
<Text variant="headingXl" className="text-surfaceDefault" as="h1">
90103
CivicDataSpace
91104
</Text>
@@ -94,55 +107,47 @@ export function MainNav({ hideSearch = false }) {
94107
</div>
95108

96109
<div className="flex items-center gap-8">
97-
{/* {!hideSearch && (
98-
<SearchInput
99-
placeholder="Search"
100-
name="Search"
101-
className="hidden h-8 w-full max-w-[350px] md:block"
102-
label="Search"
103-
ref={searchRef}
104-
suffix={
105-
<div className="relative">
106-
<Divider
107-
orientation="vertical"
108-
className="absolute left-[-4px] top-[3px] h-6"
109-
/>
110-
<IconButton
111-
size="slim"
112-
icon={Icons.terminal}
113-
withTooltip
114-
onClick={() => setCommandOpen(true)}
115-
>
116-
Command palette
117-
</IconButton>
110+
<div className="relative">
111+
<IconButton
112+
size="slim"
113+
icon={Icons.search}
114+
withTooltip
115+
color="onBgDefault"
116+
onClick={() => setCommandOpen(true)}
117+
>
118+
Search
119+
</IconButton>
120+
121+
<CommandDialog open={commandOpen} onOpenChange={setCommandOpen}>
122+
<CommandInput placeholder="search..." />
123+
<CommandList>
124+
<CommandEmpty>No results found</CommandEmpty>
125+
<CommandGroup heading="Suggestions">
126+
<CommandItem>
127+
<Link href="/datasets">Explore Datasets</Link>
128+
</CommandItem>
129+
<CommandItem>
130+
<Link href="/dashboard/user/datasets">
131+
Go to User Dashboard
132+
</Link>
133+
</CommandItem>
134+
</CommandGroup>
135+
</CommandList>
136+
</CommandDialog>
137+
</div>
118138

119-
<CommandDialog
120-
open={commandOpen}
121-
onOpenChange={setCommandOpen}
122-
>
123-
<CommandInput placeholder="search..." />
124-
<CommandList>
125-
<CommandEmpty>No results found</CommandEmpty>
126-
<CommandGroup heading="Suggestions">
127-
<CommandItem>Create Dataset</CommandItem>
128-
<CommandItem>Create new Organisation</CommandItem>
129-
<CommandItem>Go to profile</CommandItem>
130-
</CommandGroup>
131-
</CommandList>
132-
</CommandDialog>
133-
</div>
134-
}
135-
/>
136-
)}
137-
*/}
138139
<div className="flex items-center gap-5">
139140
{Navigation.map((item, index) => (
140141
<div className="hidden lg:block" key={index}>
141142
<Link href={item.href}>
142143
<Text
143144
variant="headingMd"
144145
as="h1"
145-
className="uppercase text-surfaceDefault"
146+
className={`uppercase ${
147+
pathname === item.href
148+
? 'text-[#84DCCF]'
149+
: 'text-surfaceDefault'
150+
}`}
146151
>
147152
{item.title}
148153
</Text>

0 commit comments

Comments
 (0)