️ feat: add search dialog on mobile

This commit is contained in:
Wahyu Kurniawan 2024-03-06 10:31:11 +07:00
parent 5a86abd133
commit 1ddc3b81c7
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33

View File

@ -13,6 +13,7 @@ import { Outlet, useParams } from 'react-router-dom';
import { AnimatePresence, motion } from 'framer-motion'; import { AnimatePresence, motion } from 'framer-motion';
import { cn } from 'utils/classnames'; import { cn } from 'utils/classnames';
import { useMediaQuery } from 'usehooks-ts'; import { useMediaQuery } from 'usehooks-ts';
import { ProjectSearchBarDialog } from 'components/projects/ProjectSearchBar';
export interface DashboardLayoutProps export interface DashboardLayoutProps
extends ComponentPropsWithoutRef<'section'> {} extends ComponentPropsWithoutRef<'section'> {}
@ -23,7 +24,9 @@ export const DashboardLayout = ({
}: DashboardLayoutProps) => { }: DashboardLayoutProps) => {
const { orgSlug } = useParams(); const { orgSlug } = useParams();
const isDesktop = useMediaQuery('(min-width: 1024px)'); const isDesktop = useMediaQuery('(min-width: 1024px)');
const [isSidebarOpen, setIsSidebarOpen] = useState(false); const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const [isSearchOpen, setIsSearchOpen] = useState(false);
useEffect(() => { useEffect(() => {
if (isDesktop) { if (isDesktop) {
@ -32,6 +35,7 @@ export const DashboardLayout = ({
}, [isDesktop]); }, [isDesktop]);
return ( return (
<>
<section <section
{...props} {...props}
className={cn( className={cn(
@ -76,7 +80,11 @@ export const DashboardLayout = ({
<Button iconOnly variant="ghost"> <Button iconOnly variant="ghost">
<NotificationBellIcon size={18} /> <NotificationBellIcon size={18} />
</Button> </Button>
<Button iconOnly variant="ghost"> <Button
iconOnly
variant="ghost"
onClick={() => setIsSearchOpen(true)}
>
<SearchIcon size={18} /> <SearchIcon size={18} />
</Button> </Button>
<Button <Button
@ -113,5 +121,10 @@ export const DashboardLayout = ({
</motion.div> </motion.div>
</div> </div>
</section> </section>
<ProjectSearchBarDialog
open={isSearchOpen}
onClose={() => setIsSearchOpen(false)}
/>
</>
); );
}; };