feat(shared-ui): add global CommandBar component with search across apps

- Add reusable CommandBar component to shared-ui package with dark theme
- Integrate CommandBar (Cmd/K) in contacts, calendar, todo, and clock apps
- Implement search functionality for each app:
  - Contacts: search by name, company, email with relevance-based sorting
  - Calendar: search events by title/description within next year
  - Todo: search tasks by title/description
  - Clock: search alarms and timers by label
- Add quick actions for common operations in each app

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2025-12-09 20:35:58 +01:00
parent 2b3f92ff36
commit a4846aea06
8 changed files with 899 additions and 17 deletions

View file

@ -9,6 +9,7 @@ export interface QueryEventsParams {
startDate: string;
endDate: string;
calendarIds?: string[];
search?: string;
}
export async function getEvents(params: QueryEventsParams) {
@ -19,9 +20,25 @@ export async function getEvents(params: QueryEventsParams) {
if (params.calendarIds?.length) {
searchParams.set('calendarIds', params.calendarIds.join(','));
}
if (params.search) {
searchParams.set('search', params.search);
}
return fetchApi<CalendarEvent[]>(`/events?${searchParams.toString()}`);
}
export async function searchEvents(query: string, limit: number = 10) {
// Search events within the next year
const now = new Date();
const oneYearFromNow = new Date();
oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1);
return getEvents({
startDate: now.toISOString(),
endDate: oneYearFromNow.toISOString(),
search: query,
});
}
export async function getEvent(id: string) {
const result = await fetchApi<{ event: CalendarEvent }>(`/events/${id}`);
if (result.error || !result.data) {

View file

@ -3,8 +3,13 @@
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { locale } from 'svelte-i18n';
import { PillNavigation } from '@manacore/shared-ui';
import type { PillNavItem, PillDropdownItem } from '@manacore/shared-ui';
import { PillNavigation, CommandBar } from '@manacore/shared-ui';
import type {
PillNavItem,
PillDropdownItem,
CommandBarItem,
QuickAction,
} from '@manacore/shared-ui';
import { theme } from '$lib/stores/theme';
import { authStore } from '$lib/stores/auth.svelte';
import { userSettings } from '$lib/stores/user-settings.svelte';
@ -19,12 +24,49 @@
import { getLanguageDropdownItems, getCurrentLanguageLabel } from '@manacore/shared-i18n';
import { getPillAppItems } from '@manacore/shared-branding';
import { setLocale, supportedLocales } from '$lib/i18n';
import { searchEvents } from '$lib/api/events';
import { format } from 'date-fns';
import { de } from 'date-fns/locale';
// App switcher items
const appItems = getPillAppItems('calendar');
let { children } = $props();
// CommandBar state
let commandBarOpen = $state(false);
// CommandBar quick actions (no search for calendar yet)
const commandBarQuickActions: QuickAction[] = [
{ id: 'new', label: 'Neuen Termin erstellen', icon: 'plus', href: '/event/new', shortcut: 'N' },
{
id: 'today',
label: 'Zu Heute springen',
icon: 'calendar',
onclick: () => viewStore.goToToday(),
},
{ id: 'agenda', label: 'Agenda anzeigen', icon: 'list', href: '/agenda' },
{ id: 'settings', label: 'Einstellungen', icon: 'settings', href: '/settings' },
];
// CommandBar search - search events
async function handleCommandBarSearch(query: string): Promise<CommandBarItem[]> {
if (!query.trim()) return [];
const result = await searchEvents(query);
if (result.error || !result.data) return [];
return result.data.slice(0, 10).map((event) => ({
id: event.id,
title: event.title,
subtitle: format(new Date(event.startTime), 'dd. MMM yyyy, HH:mm', { locale: de }),
}));
}
function handleCommandBarSelect(item: CommandBarItem) {
goto(`/event/${item.id}`);
}
let isSidebarMode = $state(false);
let isCollapsed = $state(false);
@ -79,6 +121,13 @@
function handleKeydown(event: KeyboardEvent) {
const target = event.target as HTMLElement;
// Cmd/Ctrl+K to open command bar (works even in inputs)
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
event.preventDefault();
commandBarOpen = true;
return;
}
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
return;
}
@ -209,6 +258,18 @@
{@render children()}
</div>
</main>
<!-- Global Command Bar (Cmd/K) -->
<CommandBar
bind:open={commandBarOpen}
onClose={() => (commandBarOpen = false)}
onSearch={handleCommandBarSearch}
onSelect={handleCommandBarSelect}
quickActions={commandBarQuickActions}
placeholder="Termin suchen..."
emptyText="Keine Termine gefunden"
searchingText="Suche..."
/>
</div>
<style>

View file

@ -3,8 +3,13 @@
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { locale } from 'svelte-i18n';
import { PillNavigation } from '@manacore/shared-ui';
import type { PillNavItem, PillDropdownItem } from '@manacore/shared-ui';
import { PillNavigation, CommandBar } from '@manacore/shared-ui';
import type {
PillNavItem,
PillDropdownItem,
CommandBarItem,
QuickAction,
} from '@manacore/shared-ui';
import { theme } from '$lib/stores/theme.svelte';
import { authStore } from '$lib/stores/auth.svelte';
import { userSettings } from '$lib/stores/user-settings.svelte';
@ -16,12 +21,89 @@
import { getLanguageDropdownItems, getCurrentLanguageLabel } from '@manacore/shared-i18n';
import { getPillAppItems } from '@manacore/shared-branding';
import { setLocale, supportedLocales } from '$lib/i18n';
import { alarmsApi } from '$lib/api/alarms';
import { timersApi } from '$lib/api/timers';
// App switcher items
const appItems = getPillAppItems('clock');
let { children } = $props();
// CommandBar state
let commandBarOpen = $state(false);
// CommandBar quick actions
const commandBarQuickActions: QuickAction[] = [
{
id: 'alarm',
label: 'Neuen Wecker erstellen',
icon: 'bell',
href: '/alarms?new=true',
shortcut: 'A',
},
{
id: 'timer',
label: 'Neuen Timer starten',
icon: 'timer',
href: '/timers?new=true',
shortcut: 'T',
},
{ id: 'stopwatch', label: 'Stoppuhr', icon: 'stopwatch', href: '/stopwatch' },
{ id: 'pomodoro', label: 'Pomodoro starten', icon: 'target', href: '/pomodoro' },
{ id: 'worldclock', label: 'Weltzeituhr', icon: 'globe', href: '/world-clock' },
{ id: 'settings', label: 'Einstellungen', icon: 'settings', href: '/settings' },
];
// CommandBar search - search alarms and timers
async function handleCommandBarSearch(query: string): Promise<CommandBarItem[]> {
if (!query.trim()) return [];
const queryLower = query.toLowerCase();
const results: CommandBarItem[] = [];
try {
// Search alarms
const alarms = await alarmsApi.getAll();
const matchingAlarms = alarms
.filter((alarm) => alarm.label?.toLowerCase().includes(queryLower))
.slice(0, 5)
.map((alarm) => ({
id: `alarm-${alarm.id}`,
title: alarm.label || 'Wecker',
subtitle: `⏰ ${alarm.time} ${alarm.enabled ? '(aktiv)' : '(inaktiv)'}`,
}));
results.push(...matchingAlarms);
// Search timers
const timers = await timersApi.getAll();
const matchingTimers = timers
.filter((timer) => timer.label?.toLowerCase().includes(queryLower))
.slice(0, 5)
.map((timer) => {
const mins = Math.floor(timer.durationSeconds / 60);
const secs = timer.durationSeconds % 60;
return {
id: `timer-${timer.id}`,
title: timer.label || 'Timer',
subtitle: `⏱️ ${mins}:${secs.toString().padStart(2, '0')} ${timer.status === 'running' ? '(läuft)' : ''}`,
};
});
results.push(...matchingTimers);
} catch {
// Ignore errors
}
return results.slice(0, 10);
}
function handleCommandBarSelect(item: CommandBarItem) {
if (item.id.startsWith('alarm-')) {
goto('/alarms');
} else if (item.id.startsWith('timer-')) {
goto('/timers');
}
}
let isSidebarMode = $state(false);
let isCollapsed = $state(false);
@ -83,6 +165,13 @@
function handleKeydown(event: KeyboardEvent) {
const target = event.target as HTMLElement;
// Cmd/Ctrl+K to open command bar (works even in inputs)
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
event.preventDefault();
commandBarOpen = true;
return;
}
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
return;
}
@ -206,6 +295,18 @@
{@render children()}
</div>
</main>
<!-- Global Command Bar (Cmd/K) -->
<CommandBar
bind:open={commandBarOpen}
onClose={() => (commandBarOpen = false)}
onSearch={handleCommandBarSearch}
onSelect={handleCommandBarSelect}
quickActions={commandBarQuickActions}
placeholder="Schnellzugriff..."
emptyText="Keine Ergebnisse"
searchingText="Suche..."
/>
</div>
<style>

View file

@ -21,23 +21,59 @@ export class ContactService {
async findByUserId(userId: string, filters: ContactFilters = {}): Promise<Contact[]> {
const { search, isFavorite, isArchived = false, limit = 50, offset = 0 } = filters;
let query = this.db
// When searching, use relevance-based sorting (name matches first, then company/email)
if (search) {
const searchLower = search.toLowerCase();
const query = this.db
.select({
contact: contacts,
// Relevance score: name matches get higher priority than company/email
relevance: sql<number>`
CASE
WHEN LOWER(${contacts.firstName}) LIKE ${`${searchLower}%`} THEN 100
WHEN LOWER(${contacts.lastName}) LIKE ${`${searchLower}%`} THEN 100
WHEN LOWER(${contacts.displayName}) LIKE ${`${searchLower}%`} THEN 90
WHEN LOWER(${contacts.firstName}) LIKE ${`%${searchLower}%`} THEN 80
WHEN LOWER(${contacts.lastName}) LIKE ${`%${searchLower}%`} THEN 80
WHEN LOWER(${contacts.displayName}) LIKE ${`%${searchLower}%`} THEN 70
WHEN LOWER(${contacts.email}) LIKE ${`%${searchLower}%`} THEN 50
WHEN LOWER(${contacts.company}) LIKE ${`%${searchLower}%`} THEN 40
ELSE 0
END
`.as('relevance'),
})
.from(contacts)
.where(
and(
eq(contacts.userId, userId),
eq(contacts.isArchived, isArchived),
isFavorite !== undefined ? eq(contacts.isFavorite, isFavorite) : undefined,
or(
ilike(contacts.firstName, `%${search}%`),
ilike(contacts.lastName, `%${search}%`),
ilike(contacts.displayName, `%${search}%`),
ilike(contacts.email, `%${search}%`),
ilike(contacts.company, `%${search}%`)
)
)
)
.orderBy(sql`relevance DESC`, desc(contacts.updatedAt))
.limit(limit)
.offset(offset);
const results = await query;
return results.map((r) => r.contact);
}
// Without search, just order by updatedAt
const query = this.db
.select()
.from(contacts)
.where(
and(
eq(contacts.userId, userId),
eq(contacts.isArchived, isArchived),
isFavorite !== undefined ? eq(contacts.isFavorite, isFavorite) : undefined,
search
? or(
ilike(contacts.firstName, `%${search}%`),
ilike(contacts.lastName, `%${search}%`),
ilike(contacts.displayName, `%${search}%`),
ilike(contacts.email, `%${search}%`),
ilike(contacts.company, `%${search}%`)
)
: undefined
isFavorite !== undefined ? eq(contacts.isFavorite, isFavorite) : undefined
)
)
.orderBy(desc(contacts.updatedAt))

View file

@ -3,8 +3,13 @@
import { page } from '$app/stores';
import { onMount } from 'svelte';
import { locale } from 'svelte-i18n';
import { PillNavigation } from '@manacore/shared-ui';
import type { PillNavItem, PillDropdownItem } from '@manacore/shared-ui';
import { PillNavigation, CommandBar } from '@manacore/shared-ui';
import type {
PillNavItem,
PillDropdownItem,
CommandBarItem,
QuickAction,
} from '@manacore/shared-ui';
import { authStore } from '$lib/stores/auth.svelte';
import { userSettings } from '$lib/stores/user-settings.svelte';
import { projectsStore } from '$lib/stores/projects.svelte';
@ -17,12 +22,48 @@
import { THEME_DEFINITIONS } from '@manacore/shared-theme';
import { getLanguageDropdownItems, getCurrentLanguageLabel } from '@manacore/shared-i18n';
import { getPillAppItems } from '@manacore/shared-branding';
import { getTasks } from '$lib/api/tasks';
// App switcher items
const appItems = getPillAppItems('todo');
let { children } = $props();
// CommandBar state
let commandBarOpen = $state(false);
// CommandBar quick actions
const commandBarQuickActions: QuickAction[] = [
{ id: 'new', label: 'Neue Aufgabe erstellen', icon: 'plus', href: '/task/new', shortcut: 'N' },
{ id: 'kanban', label: 'Kanban-Board', icon: 'list', href: '/kanban' },
{ id: 'stats', label: 'Statistiken', icon: 'chart', href: '/statistics' },
{ id: 'settings', label: 'Einstellungen', icon: 'settings', href: '/settings' },
];
// CommandBar search - search tasks
async function handleCommandBarSearch(query: string): Promise<CommandBarItem[]> {
if (!query.trim()) return [];
try {
const tasks = await getTasks({ search: query });
return tasks.slice(0, 10).map((task) => ({
id: task.id,
title: task.title,
subtitle: task.isCompleted
? '✓ Erledigt'
: task.dueDate
? new Date(task.dueDate).toLocaleDateString('de-DE')
: 'Kein Datum',
}));
} catch {
return [];
}
}
function handleCommandBarSelect(item: CommandBarItem) {
goto(`/task/${item.id}`);
}
let isSidebarMode = $state(false);
let isCollapsed = $state(false);
@ -78,6 +119,13 @@
function handleKeydown(event: KeyboardEvent) {
const target = event.target as HTMLElement;
// Cmd/Ctrl+K to open command bar (works even in inputs)
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
event.preventDefault();
commandBarOpen = true;
return;
}
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
return;
}
@ -232,6 +280,18 @@
{@render children()}
</div>
</main>
<!-- Global Command Bar (Cmd/K) -->
<CommandBar
bind:open={commandBarOpen}
onClose={() => (commandBarOpen = false)}
onSearch={handleCommandBarSearch}
onSelect={handleCommandBarSelect}
quickActions={commandBarQuickActions}
placeholder="Aufgabe suchen..."
emptyText="Keine Aufgaben gefunden"
searchingText="Suche..."
/>
</div>
<style>

View file

@ -0,0 +1,601 @@
<script lang="ts">
import { goto } from '$app/navigation';
export interface CommandBarItem {
id: string;
title: string;
subtitle?: string;
icon?: string;
imageUrl?: string;
isFavorite?: boolean;
}
export interface QuickAction {
id: string;
label: string;
href?: string;
icon: string;
shortcut?: string;
onclick?: () => void;
}
interface Props {
open: boolean;
onClose: () => void;
onSearch: (query: string) => Promise<CommandBarItem[]>;
onSelect: (item: CommandBarItem) => void;
quickActions?: QuickAction[];
placeholder?: string;
emptyText?: string;
searchingText?: string;
}
let {
open = $bindable(),
onClose,
onSearch,
onSelect,
quickActions = [],
placeholder = 'Suchen...',
emptyText = 'Keine Ergebnisse gefunden',
searchingText = 'Suche...',
}: Props = $props();
let searchQuery = $state('');
let results = $state<CommandBarItem[]>([]);
let loading = $state(false);
let selectedIndex = $state(0);
let searchTimeout: ReturnType<typeof setTimeout>;
let inputElement: HTMLInputElement;
// Reset state when modal opens
$effect(() => {
if (open) {
searchQuery = '';
results = [];
selectedIndex = 0;
setTimeout(() => inputElement?.focus(), 50);
}
});
async function handleSearch() {
clearTimeout(searchTimeout);
if (!searchQuery.trim()) {
results = [];
loading = false;
return;
}
loading = true;
searchTimeout = setTimeout(async () => {
try {
results = await onSearch(searchQuery);
selectedIndex = 0;
} catch (e) {
console.error('Search error:', e);
results = [];
} finally {
loading = false;
}
}, 150);
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
event.preventDefault();
onClose();
return;
}
if (event.key === 'ArrowDown') {
event.preventDefault();
const maxIndex = searchQuery.trim() ? results.length - 1 : quickActions.length - 1;
selectedIndex = Math.min(selectedIndex + 1, maxIndex);
return;
}
if (event.key === 'ArrowUp') {
event.preventDefault();
selectedIndex = Math.max(selectedIndex - 1, 0);
return;
}
if (event.key === 'Enter') {
event.preventDefault();
if (searchQuery.trim() && results.length > 0) {
selectItem(results[selectedIndex]);
} else if (!searchQuery.trim() && quickActions.length > 0) {
const action = quickActions[selectedIndex];
if (action.href) {
goto(action.href);
onClose();
} else if (action.onclick) {
action.onclick();
onClose();
}
}
return;
}
}
function selectItem(item: CommandBarItem) {
onSelect(item);
onClose();
}
function getInitials(item: CommandBarItem): string {
const parts = item.title.split(' ');
if (parts.length >= 2) {
return (parts[0][0] + parts[1][0]).toUpperCase();
}
return item.title.substring(0, 2).toUpperCase();
}
function handleBackdropClick(e: MouseEvent) {
if (e.target === e.currentTarget) {
onClose();
}
}
function handleQuickAction(action: QuickAction) {
if (action.href) {
goto(action.href);
} else if (action.onclick) {
action.onclick();
}
onClose();
}
</script>
{#if open}
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<div
class="command-backdrop"
role="dialog"
aria-modal="true"
aria-label="Suchen"
onclick={handleBackdropClick}
onkeydown={handleKeydown}
>
<div class="command-modal">
<!-- Search Input -->
<div class="command-input-wrapper">
<svg class="command-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>
<input
bind:this={inputElement}
type="text"
{placeholder}
bind:value={searchQuery}
oninput={handleSearch}
class="command-input"
/>
<kbd class="command-shortcut">ESC</kbd>
</div>
<!-- Results -->
{#if searchQuery.trim()}
<div class="command-results">
{#if loading}
<div class="command-loading">
<div class="loading-spinner"></div>
<span>{searchingText}</span>
</div>
{:else if results.length === 0}
<div class="command-empty">
<span>{emptyText}</span>
</div>
{:else}
{#each results as item, index (item.id)}
<button
type="button"
class="command-result"
class:selected={index === selectedIndex}
onclick={() => selectItem(item)}
onmouseenter={() => (selectedIndex = index)}
>
<div class="result-avatar">
{#if item.imageUrl}
<img
src={item.imageUrl}
alt={item.title}
class="w-full h-full rounded-full object-cover"
/>
{:else}
{getInitials(item)}
{/if}
</div>
<div class="result-info">
<div class="result-name">{item.title}</div>
{#if item.subtitle}
<div class="result-details">
<span>{item.subtitle}</span>
</div>
{/if}
</div>
{#if item.isFavorite}
<svg class="result-favorite" fill="currentColor" viewBox="0 0 24 24">
<path
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"
/>
</svg>
{/if}
</button>
{/each}
{/if}
</div>
{:else if quickActions.length > 0}
<!-- Quick Actions when no search -->
<div class="quick-actions-list">
{#each quickActions as action, index (action.id)}
<button
type="button"
class="quick-action"
class:selected={index === selectedIndex}
onclick={() => handleQuickAction(action)}
onmouseenter={() => (selectedIndex = index)}
>
<svg class="quick-action-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
{#if action.icon === 'plus'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 4v16m8-8H4"
/>
{:else if action.icon === 'heart'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
/>
{:else if action.icon === 'tag'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
/>
{:else if action.icon === 'upload'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"
/>
{:else if action.icon === 'calendar'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
/>
{:else if action.icon === 'clock'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
/>
{:else if action.icon === 'check'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
{:else if action.icon === 'settings'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
/>
{:else if action.icon === 'list'}
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 10h16M4 14h16M4 18h16"
/>
{/if}
</svg>
<span>{action.label}</span>
{#if action.shortcut}
<kbd>{action.shortcut}</kbd>
{/if}
</button>
{/each}
</div>
{/if}
<!-- Footer -->
<div class="command-footer">
<div class="footer-hints">
<span><kbd>↑↓</kbd> Navigation</span>
<span><kbd></kbd> Öffnen</span>
<span><kbd>ESC</kbd> Schließen</span>
</div>
</div>
</div>
</div>
{/if}
<style>
.command-backdrop {
position: fixed;
inset: 0;
z-index: 100;
display: flex;
align-items: flex-start;
justify-content: center;
padding-top: 15vh;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.command-modal {
width: 100%;
max-width: 560px;
margin: 0 1rem;
background: #1a1a1a;
border: 1px solid #333;
border-radius: 12px;
box-shadow:
0 25px 50px -12px rgba(0, 0, 0, 0.5),
0 0 0 1px rgba(255, 255, 255, 0.1);
overflow: hidden;
animation: slideIn 0.2s ease;
color: #e5e5e5;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.command-input-wrapper {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem 1.25rem;
border-bottom: 1px solid #333;
}
.command-icon {
width: 1.25rem;
height: 1.25rem;
color: #888;
flex-shrink: 0;
}
.command-input {
flex: 1;
border: none;
background: transparent;
font-size: 1rem;
color: #fff;
outline: none;
}
.command-input::placeholder {
color: #666;
}
.command-shortcut {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-family: inherit;
background: #2a2a2a;
border: 1px solid #444;
border-radius: 4px;
color: #888;
}
.command-results {
max-height: 320px;
overflow-y: auto;
}
.command-loading,
.command-empty {
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
padding: 2rem;
color: #888;
font-size: 0.875rem;
}
.loading-spinner {
width: 1.25rem;
height: 1.25rem;
border: 2px solid #333;
border-top-color: #3b82f6;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.command-result {
display: flex;
align-items: center;
gap: 0.75rem;
width: 100%;
padding: 0.75rem 1.25rem;
background: transparent;
border: none;
cursor: pointer;
text-align: left;
transition: background 0.1s ease;
color: #e5e5e5;
}
.command-result:hover,
.command-result.selected {
background: #2a2a2a;
}
.result-avatar {
width: 40px;
height: 40px;
min-width: 40px;
border-radius: 9999px;
background: #3b82f6;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 0.875rem;
}
.result-info {
flex: 1;
min-width: 0;
}
.result-name {
font-weight: 500;
color: #fff;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.result-details {
display: flex;
gap: 0.5rem;
font-size: 0.8125rem;
color: #888;
}
.result-details span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.result-favorite {
width: 1rem;
height: 1rem;
color: #ef4444;
flex-shrink: 0;
}
.quick-actions-list {
padding: 0.5rem;
}
.quick-action {
display: flex;
align-items: center;
gap: 0.75rem;
width: 100%;
padding: 0.75rem 1rem;
border-radius: 8px;
color: #e5e5e5;
background: transparent;
border: none;
cursor: pointer;
text-align: left;
transition: background 0.1s ease;
}
.quick-action:hover,
.quick-action.selected {
background: #2a2a2a;
}
.quick-action-icon {
width: 1.25rem;
height: 1.25rem;
color: #888;
}
.quick-action span {
flex: 1;
font-size: 0.9375rem;
}
.quick-action kbd {
padding: 0.125rem 0.375rem;
font-size: 0.6875rem;
font-family: inherit;
background: #2a2a2a;
border: 1px solid #444;
border-radius: 4px;
color: #888;
}
.command-footer {
padding: 0.75rem 1.25rem;
border-top: 1px solid #333;
background: #141414;
}
.footer-hints {
display: flex;
gap: 1rem;
font-size: 0.75rem;
color: #666;
}
.footer-hints kbd {
padding: 0.125rem 0.25rem;
font-family: inherit;
background: #2a2a2a;
border: 1px solid #444;
border-radius: 3px;
margin-right: 0.25rem;
}
@media (max-width: 640px) {
.command-backdrop {
padding-top: 5vh;
}
.footer-hints {
flex-wrap: wrap;
gap: 0.5rem;
}
}
</style>

View file

@ -0,0 +1,2 @@
export { default as CommandBar } from './CommandBar.svelte';
export type { CommandBarItem, QuickAction } from './CommandBar.svelte';

View file

@ -71,5 +71,9 @@ export {
GlobalSettingsSection,
} from './settings';
// Command Bar
export { CommandBar } from './command-bar';
export type { CommandBarItem, QuickAction } from './command-bar';
// Pages
export { default as AppsPage } from './pages/AppsPage.svelte';