managarten/packages/shared-ui/src/navigation/useGlobalSpotlight.svelte.ts
Till JS ffd608cbb9 feat(shared-ui, manacore/web): cross-app navigation enhancement (3 phases)
Phase 1: Enhanced App Drawer in PillNavigation
- appNavigationStore: localStorage-backed favorites, recents, usage counts
- AppDrawer: replaces PillDropdown for apps with search, favorites, recents, grid
- All apps using PillNavigation get this automatically

Phase 2: Cmd+K Command Palette (GlobalSpotlight)
- GlobalSpotlight: modal with app search, quick actions, keyboard navigation
- useGlobalSpotlight: Cmd+K / Ctrl+K keyboard listener
- Integrated into PillNavigation via optional spotlightActions prop

Phase 3: Improved /home page
- AppRow: horizontal scrollable app row for favorites/recents with pin toggle
- ActivityFeed: cross-app timeline (completed tasks, upcoming events, contacts)
- Replaced hardcoded 3-category layout with dynamic favorites, recents, activity
  feed, and usage-frequency sorted app grid

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 11:59:36 +02:00

39 lines
740 B
TypeScript

/**
* Global Spotlight State
*
* Manages open/close state for the Cmd+K command palette.
* Registers a global keydown listener.
*/
export function createGlobalSpotlightState() {
let isOpen = $state(false);
$effect(() => {
function handleKeydown(e: KeyboardEvent) {
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
e.preventDefault();
isOpen = !isOpen;
}
if (e.key === 'Escape' && isOpen) {
isOpen = false;
}
}
window.addEventListener('keydown', handleKeydown);
return () => window.removeEventListener('keydown', handleKeydown);
});
return {
get isOpen() {
return isOpen;
},
open() {
isOpen = true;
},
close() {
isOpen = false;
},
toggle() {
isOpen = !isOpen;
},
};
}