feat: update ProjectE application
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
'use client';
|
||||
|
||||
import { Search, Bell, Plus, Menu } from 'lucide-react';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useSidebarStore } from '@/lib/stores/use-sidebar-store';
|
||||
import { CommandPalette } from '@/components/command-palette';
|
||||
|
||||
export function TopBar() {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const { setMobileOpen } = useSidebarStore();
|
||||
const creation = pathname.startsWith('/projects')
|
||||
? { href: '/projects?new=true', label: 'New project' }
|
||||
: pathname.startsWith('/habits')
|
||||
? { href: '/habits?new=true', label: 'New habit' }
|
||||
: pathname.startsWith('/tasks')
|
||||
? { href: '/tasks?new=true', label: 'New task' }
|
||||
: null;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -46,14 +56,16 @@ export function TopBar() {
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
document.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'k', metaKey: true })
|
||||
);
|
||||
if (creation) {
|
||||
router.push(creation.href);
|
||||
return;
|
||||
}
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', metaKey: true }));
|
||||
}}
|
||||
aria-label="Quick add"
|
||||
aria-label={creation ? `Create ${creation.label.toLowerCase()}` : 'Quick add'}
|
||||
>
|
||||
<Plus className="mr-1 h-4 w-4" aria-hidden="true" />
|
||||
Quick add
|
||||
{creation?.label ?? 'Quick add'}
|
||||
</Button>
|
||||
|
||||
<Button variant="ghost" size="icon" aria-label="Notifications">
|
||||
|
||||
Reference in New Issue
Block a user